blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
029a5d5df2dba07d003c0c2179de276d3f63658d | priyankaonly1/PythonDSA | /List/larElement.py | 242 | 3.578125 | 4 | def getMax(l):
if not l:
return None
else:
res = l[0]
for i in range(1,len(l)):
if l[i] > res:
res = l[i]
return res
l = [int(x) for x in input().split()]
print(getMax(l)) |
874c2930d3f4e55b6ab4547e4720663a19fc5404 | Aasthaengg/IBMdataset | /Python_codes/p03545/s103931584.py | 1,003 | 3.546875 | 4 | def operator(x):
if x < 0:
return '-'
else:
return '+'
def main():
abcd = str(input())
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
lst = []
for op_1 in range(2):
for op_2 in range(2):
for op_3 in range(2):
... |
83deae323957c85e9ea0bd589a5ae4e606eacf9e | dhanudhanusha99/Python-Programming | /zerodivision.py | 258 | 3.671875 | 4 | try:
a=int(input("Enter the numerator : "))
b=int(input("Enter the denominator : "))
print("Result after division : "%(a/b))
except(ZeroDivisionError,ValueError) as er:
print(er)
else:
print("Successfully Executed ")
finally:
print("Executed") |
4743dc11174ff5ad4d91ff50ac18b2e04a75655f | Marat200/python_task | /задание 2 к уроку 7.py | 806 | 3.9375 | 4 | from random import randint
MAX_SIZE = 50
def merge_sort(array):
if len(array) < 2:
return array
mid = len(array) // 2
left_part = array[:mid]
right_part = array[mid:]
left_part = merge_sort(left_part)
right_part = merge_sort(right_part)
return merge_list(left_... |
8eebb7a2842e0d2aae9ea3f014b600acbc762a4e | codingspecialist/RaspberryPi4-Book-Example | /ch03/for01.py | 183 | 3.78125 | 4 | for i in range(0, 5, 1):
print(i)
print("----------")
for j in[1,3,5,7,9]:
print(j)
print("----------")
for k in range(0, 3, 1):
print("꿈은 이루어 진다.")
|
6da1527d1ec8329eb07b481ca2f78f4e73734e0b | tchinyamakobvu/Assignments | /pythondata/readwrite.py | 211 | 3.984375 | 4 | #Reads name.txt
with open('name.txt') as f:
my_name = f.read()
greeting = 'Hello my name is ' + my_name + '.'
print(greeting)
#write that to a file
with open('Hello.txt',"w") as g:
g.write(greeting) |
be8f5c80e2f07bf03598e7acc7babe8eb1399594 | DragonfireX/python-_exercises_and-notes | /python_query_processes.py | 443 | 3.796875 | 4 | tags = ['python', 'development', 'tutorials', 'code'] # database query here
#big difference between index and length---index starts with 0 ---length starts with 1
number_of_tags = len(tags)
last_item = tags[-1] #value of the last item using negative index
index_of_last_item = tags.index(last_item) #once you have value ... |
7ab79d760d20ca352468ee79aaec48225f095db1 | AleksaArsic/ProjektovanjeAlgoritama | /vezba07/hashTable/hashFunctions.py | 2,101 | 3.796875 | 4 | import math
# hashSize should be defined by the user
def divisionMethod(keyVal, hashSize):
return keyVal % hashSize
def multiplyMethod(keyVal, hashSize):
A = (math.sqrt(5) - 1 ) / (2)
return int((hashSize * (keyVal * A % 1)))
def doubleHashing(keyVal, hashSize):
return ((divisionMethod(keyVal, hashS... |
06679787cb3396ff2b42e6c5a34e2e3d69dc47da | hut/dotfiles | /pythonlib/formats.py | 510 | 3.609375 | 4 | def opencsv(filename):
import csv
fstream = open(filename, "r")
reader = csv.reader(fstream)
data = []
for entry in reader:
data.append(entry)
fstream.close()
return data
def columns(data, *columns):
newdata = []
for entry in data:
newdata.append([entry[i] for i in ... |
13f771cda5b5698d0a782e81dfe2c8cd6725db97 | GreyLove/DataStructureAndAlgorithm | /18-1.py | 902 | 3.765625 | 4 | # // 面试题18(一):在O(1)时间删除链表结点
# // 题目:给定单向链表的头指针和一个结点指针,定义一个函数在O(1)时间删除该
# // 结点。
class node(object):
def __init__(self,val):
self.val = val
self.next = None
def deleteNode(root,node):
if not root or not node:
return
if root == node and node.next == None:
return
eli... |
fcf5b0528070e2bf461afc3f97f4ba7545dc2213 | VladAdmin0/Trainer | /getsum.py | 1,752 | 4.09375 | 4 | # Given two integers, which can be positive and negative, find the sum of all the numbers between including them
# too and return it. If both numbers are equal return a or b.
a = int(input('enter a:'))
b = int(input('enter b:'))
def get_sum(a,b):
if a == b:
# return a
print(a)
elif a < 0 and b... |
82899902560dfe0c6e998219da43747ae9d27a47 | pragatirahul123/list | /Column_Row.py | 275 | 4.03125 | 4 | row=int(input("enter a row ="))
column=int(input("enter a column="))
index=1
a=1
empty=[]
while index<=column:
empty1=[]
b=a
j=1
while j<=row:
empty1.append(b)
j+=1
b+=1
empty.append(empty1)
index+=1
a+=column
print(empty)
|
c48488acf1b5ed2d9241d25de853cb6dd908d9b3 | novayo/LeetCode | /For Irene/Hash/0036_Valid_Sudoku.py | 862 | 3.75 | 4 | class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
length = len(board)
rows = [set() for i in range(length)] # x
cols = [set() for i in range(length)] # y
blocks = [set() for i in range(length)] # x // 3 * 3 + y // 3 => block index
... |
9243413b092ab761be6044db031aedd31bc44bed | sudheerachary/Kaggle | /digit_recognizer/script.py | 18,192 | 3.53125 | 4 |
# coding: utf-8
# # MNIST using CNN Keras - Acc 0.996 (TOP 4%)
# ### **Sudheer Achary**
#
# * **1. Introduction**
# * **2. Data preparation**
# * 2.1 Load data
# * 2.2 Check for null and missing values
# * 2.3 Normalization
# * 2.4 Reshape
# * 2.5 Label encoding
# * 2.6 Split training and val... |
a0f42f9387b1d3c70924a956d602d5a45801b574 | shubhamkumar27/Leetcode_solutions | /50. Pow(x, n).py | 1,043 | 3.71875 | 4 | '''
Implement pow(x, n), which calculates x raised to the power n (xn).
Example 1:
Input: 2.00000, 10
Output: 1024.00000
Example 2:
Input: 2.10000, 3
Output: 9.26100
Example 3:
Input: 2.00000, -2
Output: 0.25000
Explanation: 2-2 = 1/22 = 1/4 = 0.25
Note:
-100.0 < x < 100.0
n is a 32-bit signed integer, within the r... |
b5f1e09f3beba9cc72f301708ef5af4a36456648 | lovehhf/LeetCode | /473. 火柴拼正方形.py | 2,703 | 3.84375 | 4 | # -*- coding:utf-8 -*-
"""
还记得童话《卖火柴的小女孩》吗?现在,你知道小女孩有多少根火柴,请找出一种能使用所有火柴拼成一个正方形的方法。不能折断火柴,可以把火柴连接起来,并且每根火柴都要用到。
输入为小女孩拥有火柴的数目,每根火柴用其长度表示。输出即为是否能用所有的火柴拼成正方形。
示例 1:
输入: [1,1,2,2,2]
输出: true
解释: 能拼成一个边长为2的正方形,每边两根火柴。
示例 2:
输入: [3,3,3,3,4]
输出: false
解释: 不能用所有火柴拼成一个正方形。
注意:
给定的火柴长度和在 0 到 10^9之间。
火柴数组的长度不超过15。
"""
from ... |
e30f37d0c9b24ec8403f066958d3440518bc0655 | a2606844292/vs-code | /test2/高阶内置函数/Lambda表达式介绍/lambda.py | 213 | 4.03125 | 4 | # def add(num1,num2):
# result=num1+num2
# return result
# print(add(1,2))
#相加
super_add=lambda num1,num2:num1+num2
#相乘
multiply=lambda a,b:a*b
print(super_add(1,2))
print(multiply(1,2)) |
772a20c6a9bfb34237023103516daf5b8c8f6190 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2252/60616/246505.py | 776 | 3.765625 | 4 | def equal(str1,str2):
list1=list(str1)
list2=list(str2)
bo1=True
bo2=True
for item1 in list1:
if(item1 not in list2):
bo1=False
break
else:
if(list1.count(item1)!=list2.count(item1)):
bo1=False
break
for item2 in... |
1eab756b91109eedde9759649f097190749013d1 | torvigoes/Exercicios-Python3 | /Mundo 1/ex017.py | 323 | 3.671875 | 4 | from time import sleep
from math import hypot
print('=' * 30)
print(' ')
b = float(input('Digite o comprimento do cateto oposto: '))
c = float(input('Agora, do cateto adjacente: '))
print(' ')
print('Calculando...')
sleep(0.5)
print(f'O comprimento da hipotenusa é de: {hypot(b, c):.2f}')
print(' ')
print('=' * 30)... |
49798b437f753831ecd6813f46fade067d01f4b7 | ryuldashev/student_project | /init.py | 4,488 | 3.9375 | 4 | def init():
print("\n----------")
print("\nDeveloper: Malik Khodjaev / Разработчик: Малик Ходжаев")
print("\n----------")
print("\nHello. To choose English just type: eng")
print("\nIf you want to exit just type: exit")
print("\nПривет. Чтобы выбрать русский язык введи: рус")
print("\... |
24d0a41c6f9fb8b47dd90e027dbf63ec6f3be40a | Jamp-H/Neural-Network | /neural_network.py | 6,742 | 3.65625 | 4 | ###############################################################################
#
# AUTHOR(S): Joshua Holguin
# DESCRIPTION: program that will inplement stochastic gradient descent algorithm
# for a one layer neural network
# VERSION: 0.0.1v
#
############################################################################... |
1a9db869ce4c8253505b40d88a912a7d3ad804c1 | jickyi521/LeetCode | /LeetCode/python/maxdepth_0908.py | 735 | 3.625 | 4 |
class TreeNode(object):
def __init__(self, x):
set.val = x
self.left = None
self.right = None
def maxDepth(self, root):
if root is None:
return 0
else:
left_height = self.maxDepth(root.left)
right_height = self.maxDepth(root.right)
return max(left_h... |
68d7fbffaf21bb55bc4f87b06accb70e3a2f90a9 | jroca72/eltao | /python/mysql/inicio.py | 392 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def letra_nif(dni):
mi_lista=["T","R","W","A","G","M","Y","F","P","D","X","B","N","J","Z","S","Q","V","H","L","C","K","E","O"]
valor = dni / 23
valor = valor * 23
valor = dni - valor
return mi_lista[valor]
dninumero = input("dame el número de dni : ... |
5f76d936bc8c8ff3702a0b15e787e5e3f994947b | gilmp/python-development | /python-strings/string_negative.py | 223 | 4.03125 | 4 | #!/usr/bin/env python
################################
# THIS IS ABOUT STRING METHODS #
################################
astring = "Hello world!"
print(astring.startswith("Hello"))
print(astring.endswith("asdfasdfasdf"))
|
a7d2559a4329b505dac935b533c571dbe5f8d8bc | EdnaMota/python3_estudos | /desafio011.py | 249 | 3.75 | 4 | l = float(input('Largura da parede: '))
a = float(input('Altura da parede: '))
print(f'Sua parede tem a dimensão de {l:.1f} x {a:.1f} e sua área é de {l * a:.1f}m².\nPara pintar essa parede, você precisará de {(l * a) / 2} litros de tinta.') |
5b09821907d3f8bebd48c2c371520833a6a3226e | nerozenJL/My-LeetCode-solutions | /53-maximum subarray.py | 1,188 | 3.640625 | 4 | class Solution(object):
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
max=0
sum=0
if nums:
max=nums[0]
for num in nums:
"""
ÿһλԪأֻ뵽ԭеУԭУ
ʱҪԭУлĿܣܼˣֻ
ʱԭе... |
cf8ac4aac0049005be39feaf6c0ccbb316b8b384 | nobinson20/codingChallenges | /NotInInteger.py | 378 | 3.65625 | 4 | # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(nums):
# write your code in Python 3.6
nums = list(set(nums))
nums.sort()
cnt = 1
for e in nums:
if e < 0:
continue
if e != cnt:
return cnt
... |
640d458328b630c6ebb3e302b006949f9b3dd3d9 | prodigiousnishu/Advance_Python_Batch3 | /Puthon Basics List_Organising day-7.py | 1,249 | 4.4375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
a = ['dog','cat','fish','duck']
# In[2]:
#pop -- its a function which is used to delete a element from the last of a list
a.pop()
# In[3]:
a
# In[4]:
a.pop(0)
# In[5]:
a
# In[6]:
motorcycles = ['honda','yamaha','suzuki','ducati']
motorcycles
# In[7... |
3c84571cdff8c4789dce826efdf901eb241a9974 | Hank02/capstone | /previous_versions/test.py | 698 | 3.515625 | 4 | import sys
def func1():
commands = len(sys.argv)
if commands == 2:
name = sys.argv[1]
elif commands == 3:
name = sys.argv[2]
print("hello {}".format(name))
def func2():
print("Yep!")
print("That did it!")
def func3():
print("Oh my...")
print("It seems you git this down... |
31ec1d061c747bf311c5ba022522cc579018be29 | eezhal92/flask-sqlalchemy | /book_lib/application/service/borrowing.py | 680 | 3.765625 | 4 | """."""
class Borrowing:
"""."""
def __init__(self, book_repo):
"""."""
self.book_repo = book_repo
def borrow(self, book_title):
"""."""
available_copies = self._find_available_copies(book_title)
if (len(available_copies) == 0):
raise Exception(
... |
9667ccf5af99d1a0a267ef0af658ac7c50316b66 | mak705/Python_interview | /python_prgrams/testpython/if2.py | 124 | 3.96875 | 4 | #num=("enter the one digit number")
num = 7
if num > 3:
print("3")
if num >= 5:
print("5")
if num == 7:
print("7")
|
ec886cfe93e365b85a34a2f6a82fde99183cb280 | TMJUSTNOW/Algorithm-Implementations | /4. Linear-Time Selection/dSelect.py | 9,452 | 4.03125 | 4 | # Michael D. Salerno
def dSelect(A, k):
'''
My implementation of an O(n) deterministic selection algorithm.
Input: A list of comparable elements, A, and the order of the element to
be selected, k.
Output: The kth order statistic (the kth smallest element in A).
The deterministic sel... |
7a3a1eb145660ce5689c40a910789ee6963da092 | Vinod096/learn-python | /lesson_02/personal/chapter_5/21_RPS_game.py | 2,245 | 4.65625 | 5 | #Write a program that lets the user play the game of Rock, Paper, Scissors against the computer.
#The program should work as follows:
#1. When the program begins, a random number in the range of 1 through 3 is generated.
#If the number is 1, then the computer has chosen rock. If the number is 2, then the computer
#has ... |
c09b845b6b1afa1787f144840caa0b2185691e55 | kayedavi/fpinpython | /src/chapter01/cafe.py | 1,259 | 3.515625 | 4 | from __future__ import annotations
from dataclasses import dataclass
from functools import reduce
from itertools import groupby
@dataclass(frozen=True)
class CreditCard:
def charge(self, price: float) -> None:
pass
@dataclass(frozen=True)
class Coffee:
price: float = 5.0
@dataclass(frozen=True)
c... |
55c785aacb9d3805041f34050775d9dddf1f64cd | sergio-lira/data_structures_algorithms | /project_2/submission/problem_2.py | 1,952 | 4.53125 | 5 | import os
def find_files(suffix, path):
"""
Find all files beneath path with file name suffix.
Note that a path may contain further subdirectories
and those subdirectories may also contain further subdirectories.
There are no limit to the depth of the subdirectories can be.
Args:
suffi... |
8d33594f74c58174b463aba1f3b365e4ef01fd5e | micgainey/Towers-of-Hanoi | /towers_of_hanoi_count.py | 1,979 | 4.15625 | 4 | """
Towers of Hanoi rules
1. You can't place a larger disk onto a smaller disk.
2. Only 1 disk can be moved at a time.
Towers of Hanoi moves is:
2^n - 1
OR
2 * previous + 1
example with 3 disks
3 towers: A. B. C.
Starting point:
1
2
3
A B C
... |
d2fbf30db61168c9609f200197e857a92a8fe29b | Chetanrajput161194/AWS-Devops | /Multiply.py | 152 | 4.15625 | 4 | def multiply(a,b):
return a*b
num1=int(input("ENter the First number :"))
num2=int(input("ENter the second number :"))
print(multiply(num1,num2))
|
396539d6f9fc1de95b699a08c65b6ed21be1dc02 | Addlaw/Python-Cert | /gas_prices.py | 1,062 | 3.640625 | 4 | ################################################################################
# Author: Addison Lawrence
# Date: 4/19/2020
# Reads file of gas prices over 52 weeks and plots them
################################################################################
import matplotlib.pyplot as plt#import matplotlib... |
f0c7059d76c15bc6b0d2abce0fd222aab9455efe | shuxu94/submarine | /src/main/submarine/navigation.py | 837 | 3.6875 | 4 | class Course(object):
def __init__(self, desx, desy):
self.desx = desx
self.desy = desy
def setStart(self, startx, starty):
self.startx = startx
self.starty = starty
def distanceOffCourse(self, currentx, currenty): # using the projection forumla to find the distance
# away from the intended course
... |
45ed44673a3c46e0e5065af64a568f4c2e45a794 | aslamsikder/Complete-Python-by-Aslam-Sikder | /Aslam_07_conditinal_logic.py | 351 | 4.21875 | 4 | # If Else statement
print("Enter your marks: ")
number = int(input())
if (number>=1 and number<=100):
if (number<=100 and number>=80):
grade = 'A+'
elif (number<=80 or number>=70):
grade = 'A'
else:
grade = 'less than 70% marks!'
print("You got", grade)
else:
print("You h... |
a7c3e3ee1788aea459a14118c8a5ab9e7d545487 | Nevermind7/codeeval | /easy/lettercase_percentage_ratio.py | 452 | 3.75 | 4 | import sys
from string import ascii_uppercase as upper, ascii_lowercase as lower
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
chars = [x for x in test.strip()]
small = [x for x in chars if x in lower]
big = [x for x in chars if x in upper]
print('lowercase: {:.2f} uppercase: {:.2f}'.form... |
0a1160cdb0c9d2d944693b098eaba9043d794ed0 | friedman97/uchi | /diversity.py | 10,433 | 3.515625 | 4 | #CS121: PA 7 - Diversity Treemap
#
# Code for reading Silicon Valley diversity data, summarizing
# it, and building a tree from it.
#
# YOUR NAME: _______
import argparse
import csv
import json
import pandas as pd
import sys
import numpy as np
import treenode
import treemap
import textwrap
class TreeNode(object):
... |
f10a866f8ee17c9ff122446bff7dc223d55cad24 | dev-dougie/curso_em_video-python | /Módulo 1/EX_050.py | 194 | 3.78125 | 4 | a1 = int(input('Digite o primeiro termo: '))
r = int(input('Digite a razão da PA: '))
an = a1 + (10 - 1) * r
for c in range(a1, an + r, r):
print('{}'.format(c), end=' -> ')
print('FINISH') |
2b562aef25095c472298fbb920a5288e941ec9d8 | XingXing2019/LeetCode | /LinkedList/LeetCode 2 - AddTwoNumbers/AddTwoNumbers_Python/main.py | 765 | 3.734375 | 4 | class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
res = ListNode()
point = res
cur, car = 0, 0
while l1 is not None and l2 is not None:
... |
5feb4c0555fa708a02118ec71b0b7adb5ccb2c78 | Atheelah/FileHandling_Counting-Lines | /main.py | 195 | 3.625 | 4 | f = open("zen_text.txt")
Count = 0
Content = f.read()
CoList = Content.split("\n")
for i in CoList:
if i:
Count += 1
print("This is the number of lines in the file :")
print(Count)
|
e3eb1cc0bfdfaa689ed91bf1333963aa5f59120d | MaximilianSchnatterer/Assignements | /Assignments1/exercise3.py | 200 | 4.0625 | 4 | list = [1,2,3]
list.append(4)
print(list)
list.clear()
print(list)
list = [1,2,3]
list.pop(0)
print(list)
list = [1,2,3]
list.reverse()
print(list)
list = [3,1,2]
list.sort(reverse=1)
print(list) |
272c8db43a7b42239726f75f70523a735b646bd1 | sujanchory/Online-Py | /Extra_Candies.py | 188 | 3.609375 | 4 | candies=list(map(int,input().split()))
ec=int(input())
l=list()
for i in candies:
if i+ec>=max(candies):
l.append('true')
else:
l.append('false')
print(l)
|
72df413026cf7cf863065994956932ca41c6e304 | JohanRivera/Python | /bases.py | 6,701 | 4.09375 | 4 | a = "hola"
b = 5
c = 3.3
d = True
print (type(a), type(b), type(c), type(d))
c = True
print('\n', type(c))
b = "mundo"
saludo = a + b
print(saludo)
#OPERADORES
b = 5
c = 3.3
print(b+c)
print(b-c)
print(b*c)
print(b/c)
print(b//c) # aproximación para darun entero
print(b**c) # potencia
print(b%c) # modulo
print(b a... |
d56618884e7a38473c7324d0fde345bf93c31f15 | prasoonjain123/DSA | /Sorting Algo/SelectionSort.py | 369 | 4.0625 | 4 | # By setting the min of array at start
def selectionSort(arr):
for i in range(len(arr)-1):
for j in range(i+1,len(arr)):
if arr[j]<arr[i]:
temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
print(arr)
selectionSort([5,6,2,9,7,3])
selectionSort(['idhf... |
4d8bb7d38f8cf702fd9e99996c31cd6836d948f9 | shobhit20091995/MLDL-iNeuron | /Assignmnet_python/assignment 2.py | 450 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Oct 21 02:56:46 2021
@author: shobhit kumar
"""
# star pattern code -- part 1
for i in range(5):
for j in range(i+1):
print("* ",end="")
print("\n")
for i in reversed(range(5)):
for j in range(i-1):
print("* ",end="")
print("\... |
987f59d573f52a399f03b633592e858284474665 | cforee/juxt | /juxt.py | 962 | 3.84375 | 4 | #!/usr/bin/python
import sys, random
# "juxtaposer" - Christopher S. Foree
# Takes a series of arguments specifying syntactic categories of English speech
# and generates a random juxtaposition of words resembling a sentence (of sorts)
word_set = []
allowed_syntactic_categories = ['adj','adv','art','nou','pre','pro',... |
5f20ef7638ef6f27b41cf30f70c28fbf3fb387f9 | jasolovioff/combat_sys_magic | /Creature.py | 1,154 | 3.5625 | 4 | from Card import Card
'''
Creatures
Creatures fight for you: they can attack during the combat phase of your turn and block during the combat phase of an
opponent’s turn. You can cast a creature as a spell during your main phase, and it remains on the battlefield as a
permanent. Creatures enter the battlefield with ... |
bcc153ca42653a3aeacdc99bd30239ec9403fbc7 | srinanpravij/DevPython | /multiIFGrading.py | 310 | 3.875 | 4 | # @Author : Vijayalakshmi K @Time : 12/5/2020 8:16 PM
num = int(input("Enter the number:"))
#print(type(num))
if num >= 90:
print("Grade A")
elif num >= 80:
print("Grade B")
elif num >= 70:
print("Grade C")
elif num >= 60:
print("Grade D")
else:
print("score not enough to grade")
exit(0)
|
f552b8937c2c4f2bbe83da63c2a6398d2379f2bb | starrcaft/InformationProtection | /assignment/[IS00]_03_201603867_조성환/bruteforce/프로그램/bruteforce.py | 1,159 | 3.8125 | 4 | MAX_KEY_SIZE = 26
def getMode():
while True:
print('Enter either "encrypt" or "e" or "decrypt" or "d". ')
mode = input().lower()
if mode in 'encrypt e decrypt d'.split():
return mode
else:
print('The value you entered its invalid')
def getFileName():
print('Enter your file name:'... |
5d36998f5fcfaf962aa6a01b87229e814cd97059 | hunterkorgel/Advent-of-Code-2019 | /day1.py | 853 | 3.90625 | 4 | ### Advent of Code
### Day 1
fuel_total = 0
additional_fuel = 0
filename = 'day1input.txt'
def fuelcalc(number):
answer = ((number / 3)//1) - 2
return answer
def fuelsum(number):
total = 0
number = int(number)
while fuelcalc(number) > 0:
total += fuelcalc(number)
... |
8b83e0a5e44f6de326dc1e673cb3e258142fd2c1 | soultalker/workon | /TuLingXueYuan/爱因斯坦阶梯问题.py | 835 | 3.75 | 4 | #爱因斯坦阶梯问题:有一个长阶梯,若每次上2阶,最后剩1阶;若每次上3阶,最后剩2阶;若每次上5阶,最后剩4阶;若每次上
#6阶,最后剩5阶;若每次上7阶,最后正好不剩。阶梯至少多少阶
#1、自编
i = 1
while i:
if i % 2 != 1:
i += 1
continue
elif i % 3 != 2:
i += 1
continue
elif i % 5 != 4:
i += 1
continue
elif i % 6 != 5:
i += 1
conti... |
ede74bf15d9dcabb138aa839caafe63140299d2e | frinellkd/ListsSlicing | /test.py | 151 | 3.703125 | 4 | new_list = [1,2,3,4,5,6,7,8]
value = 3
def cust_inst(new_list):
new_list[:] = new_list[::-1]
print new_list
cust_inst(new_list)
print new_list |
b46e85ec17c3af76c7133cd8e54425effea0b01b | IsauraRs/PythonInter | /Basico/Jueves/ProgFuncional/Decoradores2.py | 573 | 3.78125 | 4 | #3
# decorador que agrega un mensaje con el nombre de la funcion
def nombre(funcion):
def decorada(*parms): # * se usa para indicar que la funcion puede tener 0 o mas parametros
# acciones nuevas de la funcion
print("Se ha iniciado la funcion %s"%(funcion.__name__))
return funcion(*parms)... |
443f43d8573c1f93becc0c91150fcc81f5a82634 | fly8764/LeetCode | /sort/insert_sort.py | 9,983 | 3.5625 | 4 | class Solution1:
def __init__(self):
self.size = 0
def insetSort(self,nums):
#T(n) = n**2
#从前往后遍历
size = len(nums)
if size < 2:
return nums
for i in range(1,size):
j = i-1
temp = nums[i]
#扫描,从后往前扫描
whil... |
cea032ce90b96197d9792740dc5a8953df65c8a5 | hanas001/Stepik | /3.2_7_v01.py | 393 | 3.890625 | 4 | x = [5, 5, 12, 9, 20, 12, 3, 5, 12]
def f(x):
'''
Function makes square root from the given number
:param x: is number
:return: square root from the number
'''
return (x**2)
dictionary = {}
result = ()
for i in x:
if result not in dictionary:
result = f ( i )
print (dictio... |
e74abbba141a9de6c5b0755f83c7d0aac722a8d7 | abhay-jagtap/Learning-Python | /csv_Read.py | 252 | 3.5625 | 4 | import csv, os
if os.path.isfile('emp.csv'):
f = open('emp.csv','r')
r = csv.reader(f)
data = list(r)
for line in data:
for word in line:
print(word,'\t',end='')
print('')
else:
print('File is missing')
|
b5c755fefa7a26e80f0a3a39f7e2489e4035f611 | soojeong-DA/pre-education | /quiz/pre_python_03.py | 1,085 | 4 | 4 | """3.Enter key를 눌러 주사위를 던지게 한 후, 주사위의 눈이 높은 사람이 승리하는
간단한 주사위 게임을 만드세요
예시
<입력>
첫번째 참가자 엔터키를 눌러 주사위를 던져 주세요 : 1~6 랜덤숫자 출력
두번째 참가자 엔터키를 눌러 주사위를 던져 주세요 : 1~6 랜덤숫자 출력
<출력>
첫 번째(두 번째) 참가자의 승리입니다. or 비겼습니다.
"""
import random
dice = [1,2,3,4,5,6]
input1 = input('첫번째 참가자 엔터키를 눌러 주사위를 던져 주세요 : ')
if input1 ==... |
4e7633005dbb3ff2d8c35785220c13a875386757 | jameshilliard/PythonCode | /PythonCourseliaoxuefeng/函数式编程/ 装饰器/decorator_log.py | 890 | 3.71875 | 4 | #!/usr/bin/env python
#coding=utf-8
import functools
"""
请编写一个decorator,能在函数调用的前后打印出'begin call'和'end call'的日志。
再思考一下能否写出一个@log的decorator,使它既支持:
@log
def f():
pass
又支持:
@log('execute')
def f():
pass
"""
def log(text):
if isinstance(text, str):
def decorator(func):
@fun... |
741160dd0bc2246f47281deb54e99d9ac88cb142 | samuel-santos3112/Exercicios-Python | /CalculoSalario.py | 175 | 3.9375 | 4 | valorHora = input("Informe valor hora : ")
hora = input("Informe quantidade de horas trabalhadas: ")
salario = float (valorHora) * int (hora)
print ("Salário :",salario)
|
fb7ce1e1a6e471c022dfabfe4fc853f513cb5f0b | bssrdf/pyleet | /C/ConstructTargetArrayWithMultipleSums.py | 2,088 | 3.6875 | 4 | '''
-Medium-
*Priority Queue*
*Greedy*
Given an array of integers target. From a starting array, A consisting of all 1's,
you may perform the following procedure :
let x be the sum of all elements currently in your array.
choose index i, such that 0 <= i < target.size and set the value of A at index i to x.
You may ... |
b2fd900500a01b4ce27a70080fd2be408e76de83 | kulterryan/Py | /HCF2NUMBER/main.py | 384 | 3.953125 | 4 | # Source: CodeWithHarry via Youtube
# URL: https://www.youtube.com/watch?v=DePWIOK1STg
# HCF/GDP using Python
num1 = int(input("Enter first number\n"))
num2 = int(input("Enter second number\n"))
if num1 > num2:
mn = num1 #mn=minimum number
else:
mn = num2
for i in range(1, mn+1):
if num1%i==0 and num2... |
95ab2b9b9adf4422c5c68a53218b718fb8a38f4c | Mariasnezh/mariasnezh | /front_x.py | 663 | 4.1875 | 4 | list1 = []
list2 = []
emp = ""
while True:
line = input()
if line.strip() == emp:
break
a = line.startswith('x')
if a:
list1.append(line)
list1.sort()
else:
list2.append(line)
list2.sort()
list3 = list1 + list2
#print(list1)
#print(list2)
print(list3)
# B.... |
db75d5a3c8800a72849afe1cf4084d7e7d40333d | ybear90/coding_dojang_solution-practice- | /Lv1/DecimalNumSum.py | 436 | 3.71875 | 4 | """
각 자릿수의 합을 구할 수 있나요?
초보자 프로그래머 홍길동은 사용자가 입력한 양의정수(범위는 int)각 자리수를 더해 출력하는 프로그램을 만들고 싶어한다.
ex) 5923의 결과는 5+9+2+3인 19이다 ex) 200의 결과는 2+0+0인 2이다 ex) 6719283의 결과는 6+7+1+9+2+8+3인 36이다.
"""
iNum = input()
summ = list()
for i in iNum:
summ.append(int(i))
print(sum(summ))
|
b364ed1a4c4cac63030c3020dbf24a015469a400 | sallamander/ktorch | /examples/addition_rnn.py | 8,298 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""Sequence to sequence learning for performing addition
Reference Implementation:
https://github.com/keras-team/keras/blob/master/examples/addition_rnn.py
Input: "535+61"
Output: "596"
Padding is handled by using a repeated sentinel character (space)
Input may optionally be reversed, sho... |
6a9074729bb71a7376275f6f369d6eccd85965e2 | luarbo/HackerRank | /Day 13: Abstract Classes.py | 329 | 3.625 | 4 | #Write MyBook class
class MyBook(Book):
def __init__(self, title, author, price):
self.title=title
self.author=author
self.price=str(price)
def display(self):
print ("Title: " + self.title)
print ("Author: " + self.author)
print ("Price: " + self.price)
... |
f60f4bb620cb53363e4284312655033e0be05ea4 | uqchenxi/Traffic-Flow-Prediction-Flask-App | /project/outcome_visualization.py | 4,003 | 3.671875 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
NUMLIST = [str(i) for i in range(10)] # the number str from 1 to 9
"""
Construct a function to extract passenger flow and corresponding date from a stop
Parameters:
dataframe: The traffic dataframe to be extract
stop_id: The stop to be an... |
94b7163ac01ac841b075d6aab9096c09cf776286 | ColtW27/Command_line_book_search | /get_book_data.py | 1,972 | 4 | 4 | def list_authors_in_string(authors): # adds "and" and makes the output a string
authors = " and ".join(authors)
return authors
def get_authors(volume): # returns the list of authors for the volume
if "authors" in volume["volumeInfo"]:
authors = list_authors_in_string(volume["volumeInfo"]["author... |
f683209bf47adfb3b32690f64301d1fabfeaf07f | Zhoodarbeshim/CH2TASK17 | /task17.py | 1,332 | 3.78125 | 4 | greet = input()
google_office = [
'1 google_kazakstan'
'2 google_paris'
'3 google_uar'
'4 google_kyrgystan'
'5 google_san_francisco'
'6 google_germany'
'7 google_moscow'
'8 google_sweden'
]
if greet == 'Hello':
for x in google_office:
print(x)
choice_of_office... |
49e0d904854b85d800633292f0477680f98c571a | ARUNDHATHI1234/Python | /co1/program14.py | 120 | 3.984375 | 4 | n=int(input("enter a number:"))
s=str(n)
nn=s+s
nnn=s+s+s
temp=n+int(nn)+int(nnn)
print("the valueof n+nn+nnn is:",temp) |
37ec81bb8e7aee380a2c8a71b3cf7c597d952178 | AkashSDas/Mini-Projects | /sudoku.py | 3,329 | 3.5625 | 4 | import random
board = [
[0, 0, 0, 2, 6, 0, 7, 0, 1],
[6, 8, 0, 0, 7, 0, 0, 9, 0],
[1, 9, 0, 0, 0, 4, 5, 0, 0],
[8, 2, 0, 1, 0, 0, 0, 4, 0],
[0, 0, 4, 6, 0, 2, 9, 0, 0],
[0, 5, 0, 0, 0, 3, 0, 2, 8],
[0, 0, 9, 3, 0, 0, 0, 7, 4],
[0, 4, 0, 0, 5, 0, 0, 3, 6],
[7, 0, 3, 0, 1, 8, 0, 0, 0]... |
7108b758f2544184a102ebc52caab00334bc57c7 | rahulwadhwa238/LoadTruckSelection | /LoadDeliverySelection.py | 2,081 | 3.796875 | 4 | import datetime
class LoadTruck:
TruckList = []
def __init__(self,num, r, s, e, l):
self.number = num
self.rate = r
self.start = s
self.end = e
self.left = l
self.status = True
LoadTruck.TruckList.append(self)
def set_days_left(self,days_left):
self.days_left = days_left
def cycle_... |
12bc8a9321d919ad44d6921105b77b1523d2bad8 | Sarastro72/Advent-of-Code | /2019/10/puzzle2.py | 1,476 | 3.828125 | 4 | #!/usr/local/bin/python
import math
filepath = 'input'
# Best position from puzzle 1
ox = 23
oy = 19
def getAngle(dx, dy):
a = math.atan2(dx, dy)
if (a < 0):
a = a + (2*math.pi)
return a * 360 / (2 * math.pi)
class Asteroid:
def __init__(self, x, y):
self.x = x
self.y = y
... |
7b32237309feacc9dcf0a584835927b3c6cac30f | thinkphp/seeds.py | /reverse2.py | 514 | 4 | 4 | '''
Reverse number
@thinkphp
MIT Style License
'''
import sys
#iterative version
def reverse(n):
s = 0
x = n
while x:
s = s*10 + x%10
x = int(x/10)
return s
#recursive solution
def reverse_rec(s,n):
if n == 0:
return s
else:
return reverse_rec(s*1... |
76d53da1184e990fca80449193c0f5e73b89c690 | kiranani/playground | /Python3/0617_Merge_2_BTs.py | 700 | 4.0625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def mergeTrees(self, t1, t2):
"""
:type t1: TreeNode
:type t2: TreeNode
:rtype: TreeNode
"""
... |
e0404972a67ea770543455110994fdcbbd8da62c | mtharanya/python-programming- | /minimum.py | 401 | 3.90625 | 4 | while True:
inp = raw_input('Enter a number: ')
if inp == 'done' :
break
try:
num = float(inp)
except:
print 'Invalid input'
continue
numbers = list(num)
minimum = None
for num in numbers :
if minimum =... |
1da03c2af2ca069a957c6537d737cd8d02d5e504 | SensehacK/playgrounds | /python/PF/Extra/Assignment45.py | 563 | 3.703125 | 4 | #PF-Tryout
def find_armstrong(number):
original_number = number # save original number here
temp=0
while(number!=0):
remainder=number%10
number=number//10 # perform integer division
temp+=(remainder*remainder*remainder)
if(original_number==temp): # compare with the origin... |
24fdd6a818c04cdfe0628caca1209d7bf5fda017 | hasnain-khan1/downloader_video | /create_video_list.py | 5,363 | 3.5 | 4 | import tkinter as tk
import tkinter.scrolledtext as tkst
import video_library as lib
import font_manager as fonts
def set_text(text_area, content):
text_area.delete("1.0", tk.END)
text_area.insert(1.0, content)
def set_playlist_text(text_area, content):
text_area.delete("1.0", tk.END)
for x in ... |
ebdfa1b6cac1619088ba779f2bd5907d0a3d78fd | Sahithipalla/pythonscripts | /csvfile.py | 718 | 3.53125 | 4 | pwd
import csv
data=open("test.csv")
data
csv_data=csv.reader(data)
csv_data
data_lines=list(csv_data)
data_lines
#create or overwrite a csv.file
file_output=open("new_file.csv","w",newline="")
csv_writer=csv.writer(file_output,delimiter=",")
csv_writer.writerow(["col1","col2","col3"])
csv_writer.writerows([[1,2,3],[4,... |
f1068ab1a5ca9d430adfac63347025244b504264 | yamauchih/shitohichi-tools | /graphfetcher/vectorextractor/test_call_argument.py | 737 | 3.953125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2013 Yamauchi, Hitoshi
# For Rebecca from Hitoshi the fool
#
# function argument behavior test.
#
def func(alist):
listlen = len(alist)
if (listlen < 3):
raise StandardError('list length is too short.')
# alist is passed by a kin... |
974ae7a08eb01f22492c35d527043d3ebcccf851 | sevenhe716/LeetCode | /Mock/m4131_microsoft.py | 2,269 | 3.78125 | 4 | # Time: O(n)
# Space: O(1)
# Ideas:
# mark
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
from common import TreeNode
class Solution:
def trimBST(self, root: 'TreeNode', L: int, R: int) -> 'TreeNo... |
ca3c063234cc3ef126caf33bef40352ab751fdba | LuisHenrique01/Questoes_URI | /uri2369.py | 174 | 3.640625 | 4 | qtd = int(input())
valor = 7
for i in range(11, qtd+1):
if i < 31:
valor += 1
elif i < 101:
valor += 2
else:
valor += 5
print("%d"%valor) |
a4e31579248138c45117541dba680987262836ce | LEO147/list | /3list/range.py | 678 | 3.796875 | 4 | nums = list(range(5,0,-1))
print(nums)
nums[2] = 100
print(nums)
#range是一個類別(class),藍圖,給參數就做出這個類別的物件。沒有定義中括號,所以拿不到東西。
#List也是一種類別,把range放在nums裡面,就是建立一個新List把Range的質放在心的list,就是nums裡面。
a=[1,2,3,4,5]
total = 0
for el in a:
total+=el
total2=sum(a)
print(total,total2)
b = range(5,0,-1)
print(sum(b))
strA = 'Stone'
str... |
3d2beee7278c4df1610a275b2bf4ce1a1f69ff99 | Aptoppole/LaTech-CSC-132-Final-Project-Tutoial-keyboard | /piano_lesson.py | 1,343 | 3.828125 | 4 | ######################################################################################
# This file is for creating the lesson GUI. These be the libraries we used.
from Tkinter import *
######################################################################################
#the main part of the program
class Lesson(Fram... |
be49f994e8fafa0da3f36e686c3cef0e00f005f9 | mikalaikarol/Hangman-Python-Project | /Hangman/task/hangman/hangman.py | 3,564 | 3.96875 | 4 | import random
print("H A N G M A N")
new_word_list = ["java", "kotlin", "python", "javascript"]
new_word = random.choice(new_word_list)
hidden_word = ("-" * len(new_word))
number_of_tries = 8
used_letters = []
decision = input('Type "play" to play the game, "exit" to quit: ')
result = "".join(hidden_word)
while decis... |
392d857f71be44f3ab5a6a8ddba445ddc1c494d7 | christopher-burke/warmups | /python/misc/missing_third_angle.py | 1,204 | 4.8125 | 5 | #!/usr/bin/env python3
"""Missing Third Angle.
You are given 2 out of 3 of the angles in a triangle, in degrees.
Write a function that classifies the missing angle as either "acute", "right",
or "obtuse" based on its degrees.
Source:
https://edabit.com/challenge/PKPmS5zwefc7M5emK
"""
def calc_missing_angle(a: in... |
5fbbf55aaaf64ca3756f1621679d3985a625ac53 | sebarias/python_classes_desafioltm | /ejercicios_ciclos/desafio_ciclos_metodos/generar_patron.py | 140 | 3.875 | 4 | numero_usuario = int(input("Ingrese un numero: "))
cadena = ""
for i in range(numero_usuario):
cadena += str(i + 1)
print(cadena)
|
5e060740996a12a8fda890d7381d5d3c1ee05562 | dblueblood/ROLL-THE-DICE | /Dictionary Extract.py | 3,125 | 3.6875 | 4 | """
Author: Ayo Asekun
Date Created: Oct 18th, 2019
Last Date Modified: Oct 19th, 2019
Program Description: Extracting & Analyzing a python dictionary
PsuedoCode:
<START PROGRAM>
INPUTS: Using provided files; Extract source files & save data to reachable directory
"path" = file path of data on OS HD
... |
826d1cd20816cb12bd7a5d90fd317714aaf978a4 | IoanaMelinte/Beginner-Projects | /Computer_guessing.py | 557 | 4.25 | 4 | # the computer will guess the number that we provide
import random
inf= int(input("Minimum value of the number to guess: "))
sup= int(input("Maximum value of the number to guess: "))
feedback= ""
while feedback != "c":
guess = random.randint(inf,sup) #this variable will return the guesses of the computer
f... |
528c3ddebccee21a1f09a6ee0f49bc23ee9e9fd3 | lamvdoan/challenge | /learning/encapsulation/customer.py | 1,607 | 3.859375 | 4 | class Customer(object):
customer_id = None
name = None
age = None
gender = None
nickname = None
username = None
password = None
def __init__(self, customer_id):
self.customer_id = customer_id
def set_username(self, customer_id, username):
"""
Update username... |
c72f53ddae11dca755891b2a8b75c9f7d20b6d07 | mmdaz/python_course | /codes-2021/prime.py | 238 | 4.0625 | 4 | def is_prime(n):
for i in range(2, n):
if n % i == 0:
return False
return True
n = int(input("Enter Your Number: "))
for i in range(2, n + 1):
if is_prime(i):
print("Prime Number: {}".format(i))
|
d421fc1f784f84f364cd124f235218708ed9a242 | joestalker1/leetcode | /src/main/scala/PowerSetWithoutDuplicates.py | 452 | 3.5 | 4 | def powerset_without_dup(nums):
def get_power_set(start, res, buf):
if buf:
res.append(buf[::])
for i in range(start, len(nums)):
if i > start and nums[i-1] == nums[i]:
continue
buf.append(nums[i])
get_power_set(i+1, res, buf)
... |
45f71d944e5255dc199826addd031a87505e87f9 | coucoulesr/leetcode | /033-search-in-rotated-array/033-search-in-rotated-array.py | 2,468 | 3.78125 | 4 | class Solution:
def search(self, nums, target):
def binarySearch(nums, target, left_bound = 0):
if not nums or (len(nums) == 1 and nums[0] != target):
return -1
if len(nums) == 2:
if nums[0] == target:
return left_bound
... |
1a45e5e364e80034670e5e9f6733b4316bfc871a | jdleo/Leetcode-Solutions | /solutions/1379/main.py | 942 | 3.578125 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def getTargetCopy(self, original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode:
if not original: return None
# stack f... |
3bb6fe5414a507449862b6dbd51e2d48e2c1d8ec | xuan-linker/linker-python-study | /demo/TryExcept.py | 769 | 4 | 4 | while True:
try:
x = int(input("please input a number:"))
break
except ValueError:
print("your input not number , please try again")
import sys
try:
# raise Exception("error exception")
f = open('myfile,txt')
s = f.readline()
i = int(s.strip())
except OSError as err:
... |
77d46997ccafc64e8fab2b239b6bddc67f275d14 | Omega094/lc_practice | /reverse_nodes_in_k_group/ReverNodesInKGroup.py | 1,484 | 3.578125 | 4 | import sys
sys.path.append("/Users/jinzhao/leetcode/")
from leetcode.common import *
class Solution(object):
#this helper returns reversed linked list with start and end node.
'''
def reverseHelper(self, startNode, endNode):
if not startNode.next or not startNode:
return (startNode, st... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.