blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
439852f59f12796a21981b8fd47e005ac336606c
IronPeach/SKA-Tools
/迴文數.py
2,676
3.90625
4
import time #Make main func def Main(Num): t = 0 n1 = int(Num[::-1]) n2 = int(Num) a = n1+n2 while True: print(a) t += 1 a = str(a) if a == a[::-1]: print("You got a Palindromic number by reverse adding %d times!" % (t)) t = 0 while True: answer = input("Wanna try again? type y/n:") if an...
ff6273b26692d467a506db6fe2746beda227ee6b
hyqggl/py-tech-study
/n05_python_advanced_features/demo3_Generators.py
418
3.96875
4
singular = ('dog', 'cat', 'bird') print type(singular) plural = [string + 's' for string in singular] print plural print type(plural) # Generator Functions def f(): yield 'start' yield 'middle' yield 'end' gen = f() print next(gen) print next(gen) print next(gen) print next(gen) #STOP def g(x): whil...
d139ef8eb41b0ab887ec91a5dd046795d28f0ab9
hyqggl/py-tech-study
/n09_Pandas/demo2_DataFrames.py
720
3.5625
4
import pandas as pd import matplotlib.pyplot as plt df = pd.read_csv('test_pwt.csv') # print type(df) # print df # # print df[2:5] # print df[['country', 'tcgdp']] # print df.ix[2:5, ['country', 'tcgdp']] keep = ['country', 'POP', 'tcgdp'] df = df[keep].copy() # print df countries = df.pop('country') # print type(c...
74c1d1fa19a49b7f22add8673efcbe5f83b30f64
hyqggl/py-tech-study
/n04_Data_Variables_and_Names/demo5.py
120
3.671875
4
def f(x): x += 1 return x x = 1 print(f(x), x) def f2(x): x[0] += 1 return x x = [1] print(f2(x), x)
4b29eca253988bf75c6c8cfd1ef0e959e9d5b5c6
jahanzebhaider/Python
/OOP/protected.py
533
3.625
4
class shape: def __init__(self,length,breath): self._length=length self._breath=breath def displaysize(self): print("Length:",self._length) print("Breath:",self._breath) class rectangle(shape): def __init__(self, length, breath): # calling the const...
307cabfc949ee7f6af494726552b2228f09249d5
jahanzebhaider/Python
/if\else/else.py
1,841
4.15625
4
#THIS CODE WILL PRINT THR HONDA CAR WITH UPPER CASE AND REST WITH LOWER CASE ALPHABETS cars=['audi','bmw','honda','toyota','suzuki'] for car in cars: if car =='Honda': print(car.upper()) else: print(car.lower()) # checking nother of checking in list if 'ponks' in cars: print("it'...
4f5f9751a14819ed2b0bced8beba34e8c2c975cc
vivianhoang/Practice-Problems
/rotate.py
791
3.90625
4
# rotating matrix clockwise # returns list of lists def rotate(matrix): if matrix is None or len(matrix)<1: return else: if len(matrix)==1: return matrix else: # solution matrix soln = [row[:] for row in matrix] # size of matrix ...
8c96256c7b85a8789f0b8eda1b84a4b5b1b036dd
BryanV2A/Adivina-Juegos
/JuegoAdivinaNumero.py
3,884
3.96875
4
from Juego import * #Del archivo Juego importa su contenido class JuegoAdivinaNumero(Juego): #la clase JuegoAdivinaNumero deriva de la clase padre Juego, dejándolo acceder a su contenido. """ Declaración del método constructor que toma como parámetros el número ingresado por el usuario y el número de vida...
fbaf8da495bcb781c3942c98e8f9cb7828c4d5d2
hirosuzuki/procon
/atcoder/abc/summerfes2018_a.py
227
3.515625
4
X, Y, Z = [int(_) for _ in input().split()] def solve(X, Y ,Z): for i in range(1, 6): if X == 0 or Y == 0 or Z == 0: return i X, Y, Z = Y - Z, Z - X, X - Y return -1 print(solve(X, Y, Z))
8ef517c30dac8553ff40874f66583a38b38637b6
hirosuzuki/procon
/atcoder/abc110/c.py
255
3.734375
4
S = input() T = input() def normalize(s): pos = {} for i, c in enumerate(s): if not c in pos: pos[c] = i yield pos[c] if all(x == y for x, y in zip(normalize(S), normalize(T))): print("Yes") else: print("No")
eb3887cbd4325380c66f51d461309b2d3511849f
hirosuzuki/procon
/atcoder/abc/abc002_3.py
300
3.546875
4
import math X1, Y1, X2, Y2, X3, Y3 = [int(_) for _ in input().split()] dX2 = (X2-X1) dX3 = (X3-X1) dY2 = (Y2-Y1) dY3 = (Y3-Y1) p = dX2 * dX3 + dY2 * dY3 d2 = math.sqrt(dX2 ** 2 + dY2 ** 2) d3 = math.sqrt(dX3 ** 2 + dY3 ** 2) c = p / d2 / d3 s = math.sqrt(1 - c ** 2) r = s * d2 * d3 / 2 print(r)
f1d3f5242d72b0b1bb42d1b0df8e4736b4ed0b94
hirosuzuki/procon
/atcoder/abc127/abc127_a.py
138
3.625
4
A, B = [int(_) for _ in input().split()] if A >= 13: result = B elif A >= 6: result = B // 2 else: result = 0 print(result)
f6516feb22bec6f5044c4a4f977d8538ed993b68
hirosuzuki/procon
/atcoder/abc/abc060_b.py
178
3.546875
4
A, B, C = [int(_) for _ in input().split()] def check(A, B, C): return any((i * B + C) % A == 0 for i in range(A)) if check(A, B, C): print("YES") else: print("NO")
1a93a936c0426592ebd7de92737d2f9502ecacdc
hirosuzuki/procon
/atcoder/nikkei2019-qual/nikkei2019-qual_b.py
230
3.78125
4
N = int(input()) A = input() B = input() C = input() result = 0 for a, b, c in zip(A, B, C): if a == b == c: pass elif a == b or b == c or a == c: result += 1 else: result += 2 print(result)
a959399658b588d9da9b32f1157c9ba3547c45c7
hirosuzuki/procon
/atcoder/abc132/abc132_a.py
150
3.703125
4
S = input() from collections import Counter cs = Counter(S) result = list(cs.values()) == [2, 2] if result: print("Yes") else: print("No")
c99fc05a22c60d9b0e8d745790573ce965c02352
hirosuzuki/procon
/atcoder/abc/agc003_a.py
194
3.546875
4
S = input() from collections import Counter cs = Counter(S) result = not (((cs["N"] > 0) ^ (cs["S"] > 0)) | ((cs["W"] > 0) ^ (cs["E"] > 0))) if result: print("Yes") else: print("No")
05223fa1984e2e6dc8c5303a7fd2e4adb4768322
hirosuzuki/procon
/atcoder/cpsco2019-s3/cpsco2019_s3_a.py
166
3.671875
4
S = input() def conv(c): if c == "O": return "A" elif c == "A": return "O" return c result = "".join(conv(c) for c in S) print(result)
4e341386c287a6e3dcaa4bd0728f13622f0fa126
TheCoderIsBibhu/Spectrum_Internship
/Task1(PythonDev)/prgm7.py
468
3.671875
4
# 7 Given an array ‘a[ ]’ and a value ‘k’, find if there is a triplet in the array whose sum # is equal to the value. a=[] n=int(input("Enter the range of array: ")) print("Enter the elements: ") for i in range(n): a.append(int(input())) k=int(input("Enter the particuar number:")) for i in range(n): ...
5db7c26589e626757b3bd3c34f6470a4667b4508
TheCoderIsBibhu/Spectrum_Internship
/Task1(PythonDev)/prgm2.py
232
4.25
4
#2 Given a number find the number of zeros in the factorial of the number. num=int(input("Enter a Number: ")) i=0 while num!=0: i+=int(num/5) num=num/5 print("The Number of zeros in factorial of the number is ",i)
6669aa61d731b83f6b7b8645261d8363a9e2bf0c
Soumajit2000/Project-Euler
/#3(Largest prime factor).py
396
3.765625
4
import math def primefactor(n): ans = 0 while(n%2==0): ans = 2 n = n/2 for i in range(3, int(math.sqrt(n))+1, 2): while(n%i==0): ans = i n=n/i if(n>2): ans = n return ans t = int(input()) for i in range(t): n ...
97a5dee3dbafd091e7bc0ab5f220efb61797f5eb
azataiot/LovU
/LovU/main.py
1,493
3.5625
4
from .getName import TA from .me import sender from .message import( show_all_langs_available, message ) def LovU(TA='',TA=False, New_line=False, default_lang=False, seperater=':', sender=False, sender_name=''): """ This is the main part of the functions. :param str TA: The person who you want to send th...
e0088fd3f63ec8c3340e2062e0d8ba9f96be4793
dedeco/write-a-better-code
/programming_skills/knapsack/01_knapsack.py
914
3.515625
4
def knapsack(capacity, weights, values): n = len(values) # quantity itens M = [[0 for x in range(capacity + 1)] for x in range(n + 1)] weights, values = zip(*sorted(zip(weights, values))) #sort weights/values (referencing weights) for i in range(n + 1): for w in range(capacity + 1): ...
004990d403414579b6079817fff6dfb311838f9c
nipalmi/Python
/coroutine.py
1,357
3.578125
4
import math import os import random import re import sys res = math.floor(math.sqrt(28)) print(res) res1 = math.sqrt(28) print(res1) def printer(): while True: x = yield print(x) def co_generator(n): for _ in range(n): x = int(input()) yield x def get_roo...
dd2203fe3867099c933500e09d4b8e8e70933cb8
fran-byte/python_exercises
/tests/excepciones/ValueError.py
921
4.21875
4
# (_ _ _ _ __ |_ |_ _ # | | (_|| ) |_)\/|_(- # / # Realiza una función llamada agregar_una_vez() que reciba una lista y un elemento, uno a uno. # La función debe añadir el elemento al final de la lista con la condición de no repetir ningún elemento. lista=[] def agregar_una_vez(lista...
a610bd39e56755f7e15ad8a9f214a987dee73db7
fran-byte/python_exercises
/tests/class_herencias/3mostrar_str.py
809
3.890625
4
# (_ _ _ _ __ |_ |_ _ # | | (_|| ) |_)\/|_(- # / # Método str devolviendo una cadena de texto formateada. class Pelicula: # Constructor de Clase def __init__(self, titulo,duracion,lanzamiento): # Acción o Método self.titulo = titulo self.duracion = duracion self.lanzamiento = l...
7357433e681ddfb1acceff547d8f8889e1c20107
fran-byte/python_exercises
/tests/class_herencias/eje.py
3,873
3.90625
4
# (_ _ _ _ __ |_ |_ _ # | | (_|| ) |_)\/|_(- # / # # Ejercicio: # Crea una clase llamada Punto con sus dos coordenadas X e Y. # Añade un método constructor para crear puntos fácilmente. Si no se reciben una coordenada, su valor será cero. # Sobreescribe el método string, para que al imprim...
836bb06f31059b148003b57f66039e93810f484f
DerDomee/Morpheus-Coding-Challenges
/challenges/chall5.py
712
3.875
4
""" This solves Coding Challenge 04: Evaluate a postfix notation string """ import json def solve(data): """Solving from plain text to json token""" ops = { "+": (lambda a, b: a + b), "-": (lambda a, b: a - b), "*": (lambda a, b: a * b), "/": (lambda a, b: a / b)} tokens ...
01b731523092c9bb9a28417de1d932609e31ef1a
DerDomee/Morpheus-Coding-Challenges
/challenges/chall6.py
323
3.859375
4
""" This solves Coding Challenge 06: Convert integer to binary string. """ import json def solve(data): """Solving from plain text to json token""" i = int(data) s = "" while i: s = str(i % 2) + s i = i >> 1 payload = {"token": s} payload = json.dumps(payload) return paylo...
85cb6c3b52a66b6e2d39ed0d680ace1788d3ec6e
vbl2108/Ultimate-Pong
/PONGBUTITWORKSSKASMKA.py
1,979
3.6875
4
import turtle import random from turtle import * #screen setup screen = turtle.Screen() turtle.title('Pong but bad') turtle.bgcolor('grey') #ball setup ball = turtle.Turtle() ball.shape('square') ball.penup() #player setup player = turtle.Turtle() player.penup() player.color('black') player.setpo...
e9211dab2b9295f7db239cb8e41a11f1246ba79e
blackPanther39/algorithms
/fib.py
320
3.640625
4
''' Created on Feb 21, 2018 @author: nirmal ''' def calc_fib(n): if n == 0: return 0 if n == 1: return 1 fb = [0] * (n+1) fb[0] = 0 fb[1] = 1 for i in range(2,n+1): fb[i] = fb[i-1] + fb[i-2] return fb[n]%10 n = int(input()) print(calc_fib(n))
567a1dfdd80e4e39cb300891143cc9bf4ca0ab12
blackPanther39/algorithms
/Divide Conquer problems/binary_search.py
1,218
3.984375
4
''' Created on Mar 11, 2018 @author: nirmal ''' # Uses python3 import sys import math def binary_search(a, x): left, right = 0, len(a)-1 while left <= right: mid = (left+ math.floor((right-left)/2)) if x == a[mid]: return mid elif x < a[mid]: right...
644c4006a662fded80ca0536b982c8bcb9c9fa87
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 7/7-9-NoPastrami.py
687
3.53125
4
#Chapter 7 ex 9 date : 18/06/17. #Variables sandwhich_orders = ["tuna","chicken&stuffing","pastrami","egg&bacon","pastrami"] finished_sandwhichs = [] #Main Body print("\n\nSeems as though we have run out of pastrami.") while "pastrami" in sandwhich_orders: sandwhich_orders.remove("pastrami") while ...
d838a9aebae75e0eaf7ddf8efba66c10442d0db9
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 5/5-4-AlienColors#2.py
398
3.546875
4
#Chapter 5 ex 4 date : 11/06/17. #Variables alien_color = "red" #Main Body if(alien_color == "green"): print("\nPlayer has earned 5 points.") elif(alien_color != "green"): print("\nPlayer has earned 10 points.") alien_color = "green" if(alien_color == "green"): print("\nPlayer has earned 5 poin...
c33def97afff545464952faa066c663e1d472491
RyanMolyneux/Learning_Python
/tutorialPointWork/lab5/test2.py
1,186
4.5625
5
#In this session we will be working with strings and how to access values from them. print("\nTEST-1\n----------------------------\n"); """Today we will test out how to create substrings, which will involve slicing of an existing string.""" #Variables variable_string = "Pycon" variable_substring = variable_string[2...
43d1d68bec9b9a16768732ac1b6c369abe6b368f
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 3/3-11-IntentionalError.py
296
3.921875
4
#Chapter 3 ex 11 date : 10/06/17. #Variables my_list = ["Ryan","M","Dublin","Ireland","19"] #Index out of range error intentional down to off by one error needs -1 to correct. #print(my_list[len(my_list)]) #easiest way to access last value if you do not know index. print(my_list[-1])
be98f8641b9826f3af23f5d0416fec95fdbd708e
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 9/12/admins.py
646
3.515625
4
#Imports from users import User #Classes class Admin(User): """Specific type of user with special privileges.""" #Constructor def __init__(self,first_name,last_name,age,email,pet_name,password,priveledges): super().__init__(first_name,last_name,age,email,pet_name,password) self.priveledges = priveled...
bd22c05089954a7006c1c97f6b42ec36c94c0829
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 10/ex12/main.py
820
4
4
"""Used to store & display your favourite number.""" #Chapter 10 ex 12 DATE : 17/07/17. #Import import json #Variables file = "favourite_number.txt" favourite_num = 0 #Objects - EMPTY #Functions def store_num(): """Simple function used to store your favourite number.""" num = input("\n\nPlease ent...
20d19ed63a0dd22c377a915facdb707c2b069732
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 8/8-8-UserAlbums.py
844
4.1875
4
#Chapter 8 ex 8 date : 21/06/17. #Variables albums = [] #Functions def make_album(artistName,albumTitle,num_tracks = ""): "Creates a dictionary made up of music artist albums." album = {"artist" : artistName,"album title": albumTitle} if num_tracks: album["number of tracks"] = num_tracks retu...
fb1d53e7017f486e714eddac20e43876f1cad09a
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 6/6-9-FavouritePlaces.py
735
3.671875
4
#Chapter 6 ex 9 date : 14/06/17. #Variables NYC = {"friends" : ["james","derek","jane"], "attraction" : "statue of liberty", "common weather" : "mild heat", } Tokoyo = {"friends" : ["derek","jamie","jules","samantha"], "attraction" : "roppongi", "common weather" : "hot", } Egypt = {"fri...
d3a6eb743cb4a78b5f9be2df915df9f0f18221d6
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 5/5-2-MoreConditionalTests.py
787
3.90625
4
#Chapter 5 ex 2 date : 11/06/17. #Variables my_food = "Chicken Wrap" my_shopping_tuple = ("Ham","Cheese","Chicken","Beef") my_shopping_tuple2 = ("Onion","Peper","Parsley") #TEST - Equality&Inequality print("\nAm i Eating Pizza ? Answer -> ",(my_food == "Pizza")) print("\n\nAm i not Eating a Chicken Wrap ?...
c06f4c76379b7cc0788d1b2b8667cf2697f31f0b
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 10/ex6&7/main.py
821
4.03125
4
"""This is the main file which will be the starting point of control for this addition program.""" #Chapter 10 ex 6&7 DATE : 17/07/18. #Imports from functions import add_values #Variables num1 = 0 num2 = 0 #Functions def check_choice(num): if (num == "quit") or (num == "exit"): return True else: ...
01cb8a39730aca55603be93355359da08d0a453e
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 10/ex10/main.py
526
4.25
4
"""This will be a basic program which just consists of code counting the number of times 'the' appears in a text file.""" #Chapter 10 ex 10 DATE:17/07/18. #Import - EMPTY #Variables file_name = "" text = "" #Objects - EMPTY #Functions - EMPTY #Body file_name = input("\n\nPlease enter name of the fil...
8d1bb14e3ea2315a1011b0abf715739c4e9b710a
darkleave/python-test
/Test/venv/Example/2/5.py
267
4.28125
4
#序列相加,只有相同类型的序列才能进行链接操作 addList = [1,2,3] + [4,5,6] print(addList) addString = 'Hello, ' + 'world!' print(addString) #字符串和列表类型不同,无法进行链接 addListString = [1,2,3] + 'world!' print(addListString)
ea6ca20ffa5cab53d063838c00ff94ba6541913e
darkleave/python-test
/Test/venv/Example/6/1.py
4,345
4
4
#第6章 抽象 #斐波那契数列 def fibs(num): fibs = [0,1] for i in range(num): fibs.append(fibs[-2] + fibs[-1]) return fibs print(fibs(10)) #6.3 创建函数 #函数是可调用的(可能带有参数,也就是放在圆括号中的值),它执行某种行为并且返回一个值, #一般来说,内建的callbale函数可以用来判断函数是否可调用 import math x = 1 y = math.sqrt ''' #函数callable在Python3.0中不再可用,需要使用表达式hasattr(fun...
9a011f2aa664971b668c671ff09df378b9616546
darkleave/python-test
/Test/venv/Example/5/4.py
6,298
3.890625
4
#5.5 循环 #5.5.1 while 循环 x = 1 while x <= 100: print(x) x +=1 ''' name = '' while not name or name.isspace(): name=input('Please enter your name:') print('Hello,%s!' % name) ''' #5.5.2 for 循环 words = ['this','is','an','ex','parrot'] for word in words: print(word) numbers = [0,1,2,3,4,5,6,7,8,9] for n...
a3f8a89e9b807ba8276c4990bacc519ffeb4e215
darkleave/python-test
/Test/venv/Example/6/2.py
7,178
3.703125
4
#6.4.3 关键字参数和默认值 #不带参数名的参数我们称为位置参数 #在参数很多,参数顺序难以记住的时候,可以使用关键字参数 #使用参数名提供的参数叫做关键字参数,,它的主要作用在于可以明确每个参数的作用 def hello_l(greeting,name): print('%s ,%s!' % (greeting,name)) hello_l(greeting='Hello',name='world') hello_l(name='world',greeting='Hello') #使用关键字函数 可以给参数提供默认值 def hello_3(greeting='Hello',name='world!'): ...
182c3617675992814e9548d390db913b2f08fb7e
darkleave/python-test
/Test/venv/Example/2/4.py
525
4.15625
4
#步长示例 #步长通常都是隐式设置的,默认步长为1,分片操作就是按照这个步长逐个遍历序列的元素,然后返回开始和 #结束点之间的所有元素 numbers = [1,2,3,4,5,6,7,8,9,10] num1 = numbers[0:10:2] print(num1) num2 = numbers[3:6:3] print(num2) num3 = numbers[::4] print(num3) num4 = numbers[8:3:-1] print(num4) num5 = numbers[10:0:-2] print(num5) num6 = numbers[0:10:-2] print(num6) num7 = numb...
b45bb420f7493f34b30aae537682abe433e3434c
darkleave/python-test
/Test/venv/Example/2/2.3/1.py
220
3.9375
4
#因为字符串不能像列表一样被修改,所以有时根据字符串创建列表会很有用,list函数可以实现这个操作 listTest = list('Hello') print(listTest) strTest = '$'.join(listTest) print(strTest)
7694fe65590f429966a4315ed28b3dfaf1be8b6b
darkleave/python-test
/Test/venv/Example/4/5.py
791
4.125
4
#使用get()的简单数据库 people = { 'Alice':{ 'phone':'2341', 'addr':'Foo drive 23' }, 'Beth':{ 'phone':'9102', 'addr':'Bar street 42' }, 'Cecil':{ 'phone':'3158', 'addr':'Baz avenue 90' } } #针对电话号码和地址使用的描述性标签,会在打印输出的时候用到 labels = { 'phone':'phone num...
f8b1084a263d373dcd01a212096dfb84ad7db56b
shubhampatil23/Python
/Python Chapter 13 Enumerate () Function.py
5,698
4.6875
5
## ENUMERATE FUNCTION # ========================== #============================================================================== # We use enumerate function with for loop to track position of our item # in iterable # When we use for loop in list,tuple in that we just # track...
ac62ec139cacf1875342ded7003bd91e0dc87652
shubhampatil23/Python
/Python Chapter 3 If-Statement.py
12,271
4.28125
4
## IF - STATEMENT : #=================== # > If condition is true the the code will run. # for eg. ##age= int(input('enter your age')) ##if age >= 18: ## print('your age is eligible to play') ## O/P==> enter your age20 ## your age is eligible to play #=========================================...
839c06988a2cb989b704b61be62e691eaf1efbdc
Gustacro/learning_python
/become_python_developer/1_programming_foundations_algorithms/6 Other Algorithms/Filter_start.py
546
4.0625
4
# use a hashtable to filter out duplicate items # define a set of items that we want to reduce duplicates items = ["apple", "pear", "orange", "banana", "apple", "orange", "apple", "pear", "banana", "orange", "apple", "kiwi", "pear", "apple", "orange"] # TODO: create a hash table to perform a filter...
4bc87ec0732a1bbae109667d396bc02610ecb6c7
Gustacro/learning_python
/become_python_developer/3_Ex_Files_Learning_Python/Exercise Files/Ch3/calendars_start.py
1,776
4.25
4
# # Example file for working with Calendars # # import the calendar module import calendar # create a plain text calendar c = calendar.TextCalendar(calendar.SUNDAY) # st = c.formatmonth(2019, 12, 0, 0) # "formatmonth" method allow format a particular month into a text string # print(st) # create an HTML formatted ca...
cd6cabf1cec2544259587ab19b9c9c8bacb06146
Gustacro/learning_python
/become_python_developer/4_Ex_Files_Python_Essentials/Exercise Files/Chap07/function.py
291
3.734375
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ def main(): x = 5 kitten(x) # will call the function kitten() print(f"in main: x in {x}") def kitten(a): a = 3 print('Meow.') print(a) if __name__ == '__main__': main() # will call the default function called main()
f5fa3f146ac0000cc1eed5027d9bf1dd2f9e06b9
Xizted/TODO-LIST-TKINTER
/views/main_views.py
2,770
3.796875
4
#Importamos todo el modulo de tkinter from tkinter import * #Importamos el Widget TreeView from tkinter.ttk import Treeview #Importamos los controladores from controllers.todosList import TodosList class Main_Views: def __init__(self, window): self.wind = window self.wind.title('Todo List App') ...
072967ca416c121a1d7f2fb0320dbcbe49a605f3
nikitarybkin/mathmodels
/lab5/lab5.py
8,381
3.515625
4
import itertools import re from collections import Counter import matplotlib.pyplot as plt # from progressbar2 import * import progressbar import numpy as np source_str = open('karenina.txt', 'r').read() source_words = re.findall('(\w+)|\n\n+|[.?!]', source_str, re.UNICODE) # print('Список слов:',source_words[:10]) #...
45d2829fb0d92f6440060205a67e0aea29293d24
Ammaramjad/DSPAssignment1
/thinkdsp1.py
2,807
3.53125
4
def read_wave(filename='sound.wav'): """Reads a wave file. filename: string returns: Wave """ fp = open_wave(filename, 'r') #To Read the Audio File nchannels = fp.getnchannels() #Returns number of audio channels nframes = fp.getnframes() #Returns number of audio frames sam...
a212f533bf41ef324030787837c59924207f7b9d
bansal-ashish/hackerR
/Python/Introduction/division.py
1,753
4.34375
4
#!/usr/bin/env python """ In Python, there are two kinds of division: integer division and float division. During the time of Python 2, when you divided one integer by another integer, no matter what, the result would always be an integer. For example: >>> 4/3 1 In order to make this a float division, you would need...
f09a315e1cfea9c0d21621372053235254a89b9e
ramyabsu/simple-python-practice-programs
/PyPratice .py
7,736
4.28125
4
#!/usr/bin/env python # coding: utf-8 # # Python practice # Write a Python program to calculate the length of a string # In[6]: len('Hello there') # In[7]: mystr = "Hello there" length = 0 for i in mystr: length +=1 length # #Write a Python program to sum all the items in a list. # In[14]: #Write a Pyt...
b5d50929226e23c0c54ae453a8f674a60a185b8e
itsPav/Python
/Sillycase/sillycase.py
140
3.875
4
def sillycase(word): half = round(len(word)/2) return word[0:half].lower() + word[half:].upper() print(sillycase("Treehouse"))
35815caac7564a6be04e75a3af3b12139b97eced
jaredcooke/CP1404Practicals
/prac1/fromscratch.py
442
4.15625
4
number_of_items = int(input("Number of items: ")) total_cost = 0 while number_of_items <= 0: print("Invalid number of items!") number_of_items = int(input("Number of items: ")) for i in range(number_of_items, 0, -1): price_of_item = float(input("Price of item: ")) total_cost += price_of_item if total_co...
b3a841beefb5ca45f44b8ce655549724807134c9
fengxuetaohua/test-program-for-the-classic-triangle-problem
/UnitTest/test_txt.py
623
3.640625
4
# 导包 import unittest from Code.triangle import Triangle from ReadData.read_txt import Read_Txt # 实例化 sjx = Triangle() read_txt = Read_Txt() # 建立测试用例 class Test_Json(unittest.TestCase): def test003(self): for list in read_txt.readTxt(): result=sjx.type(int(list[0]),int(list[1]),int(list[2])) ...
46968b5e3c6b5e976c7610dceae4f1033294c6a4
15cs026priyanka/kannangeetha123
/5.py
181
4.34375
4
num = int(input('How many numbers: ')) total_sum = 0 for n in range(num): numbers = float(input('Enter number : ')) total_sum += numbers print("display the numbers")
39bf9d1169faa0d1b280f54faa34131c0c13ca29
urvalla/automata-task
/automata/machine_rotation.py
611
3.65625
4
class MachineRotation: TOP = 0 RIGHT = 1 BOTTOM = 2 LEFT = 3 MOVES = ( (0, 1), (1, 0), (0, -1), (-1, 0), ) def __init__(self): self.rotation = self.RIGHT def rotate_clockwise(self): if self.LEFT == self.rotation: self.rotatio...
83c5ca575080d40239965538d37df3c46a50f6b3
jathinraju/module-3
/python module 3/prgm3.py
83
3.984375
4
i = 0 while i<=6 : if (i ==3 or i==6) : i+=1 continue else : print(i) i+=1
a90ca0253478d5f3ed76ae32ed0b59607ba40d9c
jathinraju/module-3
/python module 3/prgm9.py
257
4.3125
4
#prgm on to check is palindrome are not n = int(input("enter a number:")) rev = 0 while(n != 0): remi = n%10 rev = rev*10+remi n = n//10 print("reverse of the number:",rev) if n==rev : print(n,"is a palindrome ") else : print("it is not a palindrome")
d04d1e651343b4932fc70347329e34baddab00bf
damtung2000/BusDokoAPU
/LCD tests/testLCD.py
763
3.5
4
#!/usr/bin/python # Example using a character LCD connected to a Raspberry Pi import time import Adafruit_CharLCD as LCD # Raspberry Pi pin setup lcd_rs = 26 lcd_en = 19 lcd_d4 = 25 lcd_d5 = 24 lcd_d6 = 22 lcd_d7 = 27 lcd_backlight = 4 # Define LCD column and row size for 16x2 LCD. lcd_columns = 16 lcd_rows = 2 lcd...
fdab662d7a7d4f589fe30497005c5ec3cd0687f3
ogbautista/FaceTheater
/add_user.py
459
4.09375
4
import sqlite3 #Open or Creates de database file conn = sqlite3.connect('users.sqlite') cur = conn.cursor() #Creates the table "Users" with 3 fields cur.execute('''CREATE TABLE IF NOT EXISTS Users (id INTEGER PRIMARY KEY, name TEXT UNIQUE, memberId TEXT UNIQUE)''') name = input("Name: ").upper() mId = input("Mem...
6e2c24d079c6b62fc208f4483ee8d99d703ca10e
LorennCa/Laboratorios
/tema1-IAI/tema_1/temaUno.py
3,777
3.921875
4
#Se importan las bibliotecas que se van a usar en los diferentes códigos from random import randint import matplotlib.pyplot as plt import pandas as pd import numpy as np from IPython.display import display, HTML #La celda 5 se divide en dos columnas con el objetivo de mostrar el datagrama y el pie chart horizontalmen...
8b348d1a210524f7884e2602f3fe820adb0398e0
KoretsValentyn/py_zoo
/zoo.py
1,035
4.15625
4
"""There are three kinds of animals in a zoo. """ class Zoo: """implementation zoo object""" def __init__(self): self.animals = [] def get_animals(self): """return all animals in zoo""" return self.animals def add(self, animal): """add new animal in zoo""" sel...
b3ad90611ac121229bbff424377be34a41e40cd8
ZechenM/CART
/CART.py
20,984
3.59375
4
from ast import get_docstring from pickle import LIST from typing import Callable import numpy as np from collections import Counter import copy from numpy.core.numeric import indices # Below is a class that implement the binary tree search. # It shows how recursion is done in a typical binary tree structure. # You m...
b926faaa697ef0f97adbc7ccc1eebd43844a6fcf
ServerBaby/Weather-App
/archived modules/weather_app_photo.py
1,331
3.609375
4
#!/usr/bin/env python3 import requests # to get image from the web import shutil # to save file locally import base64 # to convert the jpg to base64 # URL of the image being used: image_url = "https://weathercams.airservicesaustralia.com/wp-content/uploads/airports/041529/041529_045.jpg" # Retrieve the ...
a3af7a2a970e81045dfc09b7efcd54e8107f203c
melrjcr/GIT_DailyChall
/Caesar_Cipher.py
521
4.25
4
text = input('insert text to encrypt: ') pattern = int(input('choose a shift pattern: ')) alphabet = abcdefghijklmnopqrstuvwxyz def encrypt(text, pattern): result = "" for i in range(len(text)): char = text[i] if char.isupper(): result += chr((ord(char) + pattern - (ord('A'))) % le...
f63d7e3aa1cd15a097fff6e1d94a7621629232a2
iamNitin16/programming-assignment
/second.py
1,497
3.515625
4
import math import json from operator import itemgetter class Second(): """ Class to identify friends within some distance """ def __init__(self): self.friends_data = [] self.friends_to_invite_data = [] self.SOURCE_LOCATION = [float(12.9611159), float(77.6362214)] self.INVITATION_DISTANCE = 101 self.EARTH...
a783bf2776b59bc2d708b6fa8e80316563a1b6bd
SocioDroid/leetcode
/code/113.path-sum-ii.py
809
3.65625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def pathSum(self, root: TreeNode, sum: int) -> List[List[int]]: paths = list() self.findPath...
aa5bbb7a83741f42263211a45298d2b7447d1b8b
petershen0307/OnlineJudge
/sphereOnlineJudge/_2PrimeGenerator.py
1,892
3.75
4
import math def is_prime_number(number): assert 0 < number if 1 == number: return False root_int = math.floor(math.sqrt(number)) for i in range(2, root_int + 1): if number % i == 0: return False return True def enhance_prime_detect(number, prime_numbers): if len(p...
ccbb190a165d301f9cd96107670034e4ea156df9
gabriel-rc-201/Trabalhos-Inteligencia-Computacional
/Trabalho_02/Trabalho/KNN.py
3,337
3.578125
4
#!-*- conding: utf8 -*- #coding: utf-8 """ Aluno: Gabriel Ribeiro Camelo Matricula: 401091 """ import math # Matemática import re # expressões regulares # Funções acessórias #calcula a distancia entre os pontos dist = lambda x1, y1, z1, w1 , x2, y2, z2, w2: math.sqrt((x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2 + ...
5de69f375f1d221d878bbd229cb36a49c2422a73
mattfields98/INMT443
/tkinter v3.py
4,082
3.703125
4
from tkinter import * from tkinter import ttk from tkinter import messagebox root = Tk() textBox1=Text(root, height=2, width=30) textBox1.insert(END,"Filing Status") textBox1.pack() textBox2=Text(root, height=2, width=30) textBox2.insert(END,"Taxable Income") textBox2.pack() ttk.Label(root, text = "Please...
0f47f8ce96ef25f38a6a0ef22120966f78303e1f
RobotNo42/old_coed
/project/python_fullstack/day13/抽象.py
467
4
4
import abc class AbstractClass(metaclass=abc.ABCMeta): @abc.abstractmethod def walk(self): print("caonima") @abc.abstractmethod def speak(self): pass class People(AbstractClass): def __init__(self, name, age): self.name = name self.age = age def walk(self):...
3c3b08fa5627b38d5d04430059efd68ddac7a91e
RobotNo42/old_coed
/project/python_fullstack/day15/test1.py
446
3.59375
4
class Open: def __init__(self, name): self.name = name def __enter__(self): print('出现with语句,对象的__enter__被触发,有返回值则赋值给as声明的变量') # return self def __exit__(self, exc_type, exc_val, exc_tb): print('game over') print(exc_type) print(exc_val) print(exc_tb)...
81cd25d6478bab66fcf83af0596607fcaa7f1921
RobotNo42/old_coed
/project/python_fullstack/day2/homework1.py
1,438
3.625
4
items = ["Macbook", "剃须刀", "cherry", "ps4pro", "switch", "xboxone"] price = [10000, 300, 1600, 2500, 3000, 2000] buy_items = [] buy_price = [] total_money = int(input("输入你的工资")) first_money = total_money while True: print("你能买的东西如下") for i in range(len(items)): print(i+1, "\t", items[i], "\t", (price[i...
3454de088e546d5946b0f1b81c77e2a9729daec0
Termilator/Binary-clock
/GraphicBinaryClock.py
2,516
3.8125
4
import datetime from tkinter import * from tkinter.ttk import * # creating the graphic window window = Tk() window.title("Binary clock [hours:minutes]") timelabel = Label(window, font=("courier", 30, "bold"),foreground ="white", background = "black") timelabel.pack(anchor="center") # defining when the hour...
a735509157dfefff1dd45c035996a5d365541282
santiagojagua/programas-upb
/ejercicios-17-marzo.py
1,083
3.765625
4
#ejercicio1 for n in range(10): print(n) #ejercicio2 for n in range(100,200): print(n) #ejercicio3 for n in range(5,20,3): print(n) #ejercicio4 n=int(input("Número: ")) for x in range(n, n*2): print(x) #ejercicio5 c=int(input("Cantidad de números: ")) total=0 for variable in range(c): numero=int(input(...
3ab079835d01ce177a9909f73b82e1973796e86a
fullstackalexle/Coding-Dojo---Python-Django
/python/fundamentals/for_loop_basic2.py
1,266
3.859375
4
def biggie_size(arr): for i in range(0,len(arr)): if arr[i] > 0: arr[i] = "big" return arr def count_positives(arr): count = 0 for i in arr: if i > 0: count += 1 arr[-1] = count return arr def sum_total(arr): total = 0 for i in arr: total += i return total def average(arr): total = 0 avg = 0.0...
e13b5c469ffa7f8b2c76f69c735fa55a21dc806f
AndrewDuncan/Doublecoset
/working/ex_K_j4-x-g.py
858
3.5
4
import copy from graph import * #edge labels: a=x1, b=x2, c=x3, r=y1,s=y2, t=y3, x=z1,y=z2,z=z3 #nothing to add to theta to form theta1: so theta1=theta2 J=Graph(rooted=True,label='J') J.addLoop(J.root,'bCaySrtxzAB') J.addLoop(J.root,'yyxacaXyrUXYZYA') J.addLoop(J.root,'zYY') while J.fold() is True: J.fold() y...
6fab6454a3c09a21c8dba5ea22d821a2c5ba90f5
AndrewDuncan/Doublecoset
/python/scratchpad.py
706
3.65625
4
import os import itertools inedges = {} inedgesList = [] def addInEdge(label,v): if (label,v) in inedgesList: return else: inedgesList.append((label,v)) if not label in inedges: inedges[label] = [v] elif not v in inedges[label]: inedges[label].append(v) def addVertex(...
121618e769aea61c747cee0bedfebb70c4fb29f7
AndrewDuncan/Doublecoset
/python/genfold/mihailova.py
6,406
3.53125
4
from wordmap import * #set the name of the output file for the relators of Collins' example outfile='mihailova/collins.txt' #open this file and write some initial text with open(outfile, "w") as out: #create outfile out.write("output file for Collins relators from mihailova.py \n\n") #and write text to it #out....
66976de4fdaa47fb3986cc9ca06751dbb4868ba9
AndrewDuncan/Doublecoset
/python/genfold/hd.py
499
3.53125
4
from graph import * G=Graph() a=G.addVertex() b=G.addVertex() c=G.addVertex() d=G.addVertex() e=G.addVertex() f=G.addVertex() G.addEdge(a,b,'x') G.addEdge(a,b,'y') G.addEdge(b,c,'x') G.addEdge(b,c,'y') G.addEdge(c,d,'x') G.addEdge(c,d,'y') G.addEdge(d,a,'x') G.addEdge(d,a,'y') G.addEdge(a,e,'w') G.ad...
a0a6b7cd19263c451e2b4e8e2c4eb9c5d85ebe25
LimonJuice/Solutions
/Strings.py
1,530
3.515625
4
#Super Reduced String import sys def super_reduced_string(s): st = [] for i in s: if st and st[len(st)-1] == i: st.pop() else: st.append(i) st = ''.join(st) return st or 'Empty String' s = input().strip() result = super_reduced_string(s) print(res...
457697a509b6342523f3735fb8c015a521206251
Warvito/Urban-Mind-Location-Link-with-Air
/assign_air_pollution.py
3,778
3.765625
4
"""Script to find the nearest gridpoints (with air pollution measures) to the Urban Mind dataset. In order to find the nearest point, first we remove all gridpoints with missing values. Then we convert the OSGB 1936 British National Grid measures to the WGS 84 (GPS) latitude and longitude values. Finally, we compute t...
82ea1c3d867fbb82bb14532dde3c6053b791c672
Crimson25/IndependentStudy395
/BucketSort.py
1,383
3.65625
4
import random import time l1 = [] time_tracker = [] def bucket_sort(input): maxval = max(input) size = maxval / len(input) buckets = [] for x in range(len(input)): buckets.append([]) for i in range(len(input)): j = int(input[i] / size) if j != len(input): buc...
8ecf318834b8f93255764f90ebc0f8a4bbb5493a
AKILANMayavan/sj_pythonlearning
/data_structures/datastructures_dictionary.py
889
3.796875
4
# dictionary {"key":value} - pairs "json kind" # NoSQL database| json for # information of profile information = {"name":"csk", "age":27, "city":["bangalore"], "area":{"btm":"street"}} # print(information) # # accessing the value of dictionary # print(information["name"]) ...
fad1f66e1cc6881be21f566ab1fa012d639b9241
siddhantbarua/Sorting-Visualizer
/algorithm/mergeSort.py
1,412
3.546875
4
import time from colors import * def merge(nums, l, mid, r, draw_array, timeTick): left = nums[l : mid + 1] right = nums[mid + 1 : r + 1] n1 = len(left) n2 = len(right) i = 0 j = 0 k = l while i < n1 and j < n2: if left[i] >= right[j]: nums[k] = right[j] ...
f1ab00012dd8db67346ea713ad78c7cd07f61552
EleazarLopezOsuna/COMPI2-PROYECTO1
/Modelos/Simbolo.py
696
3.84375
4
from enum import Enum class Simbolo(): # Constructor, pide tipo y valor def __init__(self, tipo, valor, fila, columna): self.tipo = tipo self.valor = valor self.fila = fila self.columna = columna def getTipo(self): return self.tipo def getValor(sel...
7634729bd1ebdd70394083e70fe93c31d3cedd1d
uttam-12/Analyze_UniPlast_Data
/extract_unique.py
727
3.578125
4
file = open("B31_UNI.txt", "r") oldfile_lines = file.readlines() tempfile_lines = [] #flag = 1 for key_line in oldfile_lines: for i in range(len(oldfile_lines)): if key_line.split()[0] == oldfile_lines[i].split()[0]: if key_line.split()[2] <= oldfile_lines[i].split()[2]: ...
d2a8c0a00e2744da9d6b14956d753dc24c45d452
DeivyCQ/minimarket
/controllers/categoria_controller.py
4,237
3.84375
4
from classes.categoria import Categoria from helpers.menu import Menu from helpers.helper import print_table, input_data, pregunta class Categoria_controller: def __init__(self): self.categoria = Categoria() self.salir = False def menu(self): while True: try: ...
049734fcf2d5c260d5637f46bda497b63cfbb4ef
DeivyCQ/minimarket
/controllers/venta_controller.py
10,219
3.5
4
from classes.venta import Venta_cabecera, Venta_detalle from classes.producto import Producto from classes.tipo_venta import Tipo_venta from helpers.helper import input_data, print_table, pregunta from helpers.menu import Menu class Venta_controller: def __init__(self): self.venta_cabecera = Venta_cabecera...
4b9d3ad5882ef0c81d66243f50f411a3976168f1
tomnguyen103/Coding_Dojo
/python_stack/python/fundamentals/user1b.py
2,452
3.796875
4
class User: def __init__(self, username, email): self.name = username self.email = email self.account = BankAccount(int_rate=0.02, balance=0) def make_deposit(self, amount): self.account.deposit(amount) return self def make_withdrawal(self, amount): self.accou...
fe352aab68e259865cc88ec65637ed4be66b3bf0
tomnguyen103/Coding_Dojo
/python_stack/python/fundamentals/linkedlist.py
533
3.65625
4
class SLNode: def __init__(self,value): self.val = value self.next = None class SLList: def __init__(self): self.head = None def addToFront(self,val): #create a node to hold the value new_node = SLNode(val) #set the new node's next to the current head ...
e14e1f59fd89b1243094a180e80e4bbd9d6f8a68
YOOOOONA/algorithm_study
/asdf.py
142
3.625
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 30 14:22:07 2019 @author: 융 """ str='0' str1='01230' idx=str1.find(str) print("index=",idx)