blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
e5ce39c12304f06f6abc8433752593ce3b611381
hungair0925/note-toy-program
/TerminalBookShelf/book_shelf.py
1,390
3.8125
4
class BookShelf: def __init__(self, name): self.bk_sh = {} self.name = name def __str__(self): message = "本棚[{0}]".format(self.name) return message def add_book(self, title, author): self.bk_sh[title] = author print("追加したよ( ̄・ω・ ̄)") def list_...
47d3da207a88d5a2da4b9048427e0ae04c7f1f37
benwhale/word-squares
/word_squares/solver/recursive_solver.py
9,218
3.8125
4
from word_squares.solver.solver_util import SolverUtil class RecursiveSolver: """Recursive solver class which traverses the grid and builds a solution""" def __init__(self, dimension, letters, dawg, grid): self.dimension = dimension self.letters = letters self.dawg = dawg self...
0ff2709b707158fcad9441d591b13a5964abeac5
naveens33/python_tutorials
/strings/example3.py
198
3.546875
4
# split function extended behaviour name = "MS Dhoni" print(name.split()) print(name.split(' ')) # if you are not provided anything inside the split, then it will split according to any whitespace,
1f711a10d7b490fe9fb1fb838c86ffe6ec65baee
naveens33/python_tutorials
/Misc/assert_statement.py
166
3.671875
4
# Assertion vs Verification ''' age = 15 if age == 18: print("Yes") print("Thanks for using code") ''' age = 15 assert age == 18 print("Thanks for using code")
a912bca81664abc29b5a09b287d8dffab28478bd
naveens33/python_tutorials
/conditional_statements/ifelse_statement.py
148
3.53125
4
if __name__=='__main__': age = int(input("Enter the age: ")) if age >= 18: print("Eligible") else: print("Not Eligible")
763643acc64451c58fd791f3618c6e3dbb9a865e
naveens33/python_tutorials
/strings/example2.py
454
3.734375
4
# Swap Case without using method text = "Process Finished With Exit Code 0" result = "" for i in range(len(text)): if text[i].isupper(): result += text[i].lower() elif text[i].islower(): result += text[i].upper() else: result += text[i] print(result) name = "Mr. Karthick BA. BL." ...
db5d5360c56a47f44c1b9615e1cc389c144d5fe5
naveens33/python_tutorials
/list_tuple_set_dict/dict_functions.py
295
3.578125
4
d={"Name":"John","Class":2,"Rank":1,"FeeStatus":["paid","paid","paid"]} #get print(d.get("FeeStatus")) print(d["FeeStatus"]) #dict item related fucntions print(d.keys()) print(d.values()) print(d.items()) #popitem pop del d.popitem() print(d) d.pop("Class") print(d) del(d["Name"]) print(d)
0f5f7eac09fdeaecee1f50e3a4422e78f546fceb
naveens33/python_tutorials
/looping_statements/exmaple6.py
273
3.9375
4
#Triangle pattern * if __name__=='__main__': n=6 for i in range(1,n): for k in range(i,n-1): print(' ',end="") for j in range(i): print('*',end="") for j in range(i-1): print('*',end="") print()
4c6c163680bf31b7f34dce1957a1b458315578a3
naveens33/python_tutorials
/list_comprehension/example1.py
187
3.9375
4
sentence = "amazing" #print(list(sentence)) ''' li = [] for c in sentence: li.append(c) print(li) ''' #Syntax #[expression for item in items] li = [c for c in sentence] print(li)
76e3e82c3817f367155bfc53d2257e2a8a2c24ae
naveens33/python_tutorials
/list_comprehension/example6.py
104
3.921875
4
# Find the cube of numbers in a list li = [5, 3, 6, 8, 2, 0, 7, 1] li = [i ** 3 for i in li] print(li)
8f1f43ea4e81107852b2e40178d2a4978bb20c09
estineali/RISC_V_Simulation
/LabWeek7/Lab04/Task1/randomBitGen.py
654
3.53125
4
import random array_name = "Registers" ##Name of array of registers register_len = 64 ##size of each register in that array file_len = 32 ## Number of registers in the array number_systems = {2 : ["'b", 2], 8 : ["'o", 8], 10 : ["'d", 10], 16 : ["'h", 16]} ##Work in progress selected_base = 2 ## a part of the work in...
efe78ea947d5f580d38c9684d67349b3ce4abeee
victoire4/Introductory-Programming-with-Python
/Exercise5.py
370
3.671875
4
import math as m S=2117519.73 xo=2000 EV=m.sqrt(S) Xn=1/2*(xo+(S/xo)) n=0 print("S=",S) print("The exact answer to square root of S is",EV) print("When we use Hero's method, we have:") while EV!=Xn : Xn=1/2*(Xn+(S/Xn)) n+=1 print("X",n,"=",Xn) print("For the number S, the answer is the same that the exact...
044227e03794710c8377b8e77a8699d12f35cbcc
victor-da-costa/Aprendendo-Python
/Curso-Em-Video-Python/Mundo-1/EXs/EX014.py
137
3.859375
4
c = float(input('Informe a temperatura em °C: ')) f = ((9*c)/5) + 32 print('A temperatura correspondente a {}°C é {}°F'.format(c, f))
956348c08220ff07108152d7a8b76618ad9a03a2
victor-da-costa/Aprendendo-Python
/Curso-Em-Video-Python/Mundo-2/EXs/EX038.py
272
4
4
num1 = int(input('Digite o 1º número: ')) num2 = int(input('Digite o 2º número: ')) if num1 > num2: print('O {} é maior que {}'.format(num1, num2)) elif num1 < num2: print('O {} é maior que4 {}'.format(num2, num1)) else: print('Os números são iguais')
6dec8ea622eaa11c427254df9a7ce44d5d5241a2
victor-da-costa/Aprendendo-Python
/Curso-Em-Video-Python/Mundo-2/EXs/EX061.py
215
3.796875
4
termo = int(input('Primeiro termo: ')) razão = int(input('Razão: ')) cont = 0 while cont < 10: print('{}'.format(termo), end='') print(' >> ' if cont < 9 else '', end='') cont += 1 termo += razão
bcf0ea0073f1ff6635e224542e025db935224de2
victor-da-costa/Aprendendo-Python
/Curso-Em-Video-Python/Mundo-3/EXs/EX079.py
413
4.15625
4
numeros = [] while True: num = int(input('Digite um número: ')) if num in numeros: print(f'O número {num} já existe na lista, portanto não será adicionado') else: numeros.append(num) continuar = str(input('Quer adicionar mais um número na lista? S/N ')).upper() if continuar == 'N': ...
f97586be28e08bfc87a74a7a28c0b3e60764c999
victor-da-costa/Aprendendo-Python
/Curso-Em-Video-Python/Mundo-1/EXs/EX004.py
390
4
4
algo = input('Digite algo: ') print('''O tipo primitivo do que foi digitado é {}, Só tem espaço? {}; É um número? {}; É alfabético? {}; É alfanumérico? {}; Está em letras maiúsculas? {}; Está em letras minusculas? {}; Está capitalizada? {}.'''.format(type(algo), algo.isspace(), algo.isnumeric(), algo.isalpha(), algo.is...
df0974adbb3ceadeaabb40abcc0ef8409a2fa27b
victor-da-costa/Aprendendo-Python
/Curso-Em-Video-Python/Mundo-3/EXs/EX085.py
377
3.875
4
numeros = [[], []] for n in range(0, 7): num = int(input(f'Digite o {n+1}º número: ')) if num % 2 == 0: numeros[0].append(num) else: numeros[1].append(num) print(f'Números adicionados à lista: {numeros}') print(f'Números pares adicionados à lista: {numeros[0]}') print(f'Núm...
da100cf4a30bed21264a673ed585ce508ca89115
victor-da-costa/Aprendendo-Python
/Curso-Em-Video-Python/Mundo-2/EXs/EX037.py
579
4.1875
4
num = int(input('Digite um número inteiro qualquer: ')) print('''Escolha uma base de conversão: [1] Converter para Binário [2] Converter para Octal [3] Converter para Hexadecimal''') escolha = int(input('Converter para: ')) if escolha == 1: print('{} convertido para Binário é igual a {}'.format(num, bin(num) [2:]))...
e8df8f6730c4083dc53a4ccd472ff26b85e89e01
victor-da-costa/Aprendendo-Python
/Curso-Em-Video-Python/Mundo-2/EXs/EX054.py
335
3.84375
4
from datetime import date atual = date.today().year maior = 0 menor = 0 for nasc in range(1, 8): ano = int(input('Em que ano a {}º nasceu? '.format(nasc))) idade = atual - ano if idade >= 18: maior += 1 else: menor += 1 print('{} pessoas são de menor e {} são maiores de idade!'.format(me...
c409417437ec4b8179f981f20b731c3c06199435
Vslamer/1_DL_CV_Book
/1_python_tutorial/5.function.py
1,788
4.09375
4
def say_hello(): print("hello chenyong") def greetings(x='good morning'): print(x) say_hello() greetings() greetings("cao ni") a=greetings() def create_a_list(x,y=2,z=3): return [x,y,z] b=create_a_list(1) c=create_a_list(3,3) d=create_a_list(6,7,8) print(b,'\n',c,'\n',d) #*args是可变参数,args接收的是一个tuple, #可变参数允许你传入0个或任...
15c14dc1cb66a93e1374f7deaeed40b558242142
Vslamer/1_DL_CV_Book
/1_python_tutorial/13.plt.py
798
3.78125
4
import numpy.random as random random.seed(42) n_tests=10000 winning_doors=random.randint(0,3,n_tests) change_mind_wins=0 insist_wins=0 for winning_door in winning_doors: first_try=random.randint(0,3) remaining_choices=[i for i in range(3) if i!=first_try] wrong_choices=[i for i in range(3) if i!=winning_door] if f...
62e30686d10a88934fce06bbc457f08e5390152e
sramirezh/Corona_crawler
/Covid_19_v2.py
4,490
3.578125
4
#!/Users/simon/opt/anaconda3/bin/python # -*- coding: utf-8 -*- """ Created on Sun Apr 5 11:51:27 2020 Code based on: https://towardsdatascience.com/web-scraping-html-tables-with-python-c9baba21059 @author: simon """ import requests import lxml.html as lh import pandas as pd import numpy as np def get_main_table...
d6e4880fd81231918ca9c02a03b622a1f1d43151
GitSmurff/LABA-2-Python
/laba8/laba2.py
238
3.953125
4
import datetime day = int(input("Введите день ")) month = int(input("Введите месяц ")) year = int(input("Введите год ")) d = datetime.date(year, month, day) print(d.day, d.month, d.year)
9a16c181418ba0fb5d6118d89d95a179942b7f05
GitSmurff/LABA-2-Python
/laba6/laba1.py
1,002
4.21875
4
import abc class Abstract(abc.ABC): @abc.abstractmethod def __init__(self, x): self.x = 0 class Queen(Abstract): def __init__(self): self.x = int(input('Введите число от 1 до 9: ')) if self.x >= 1 and self.x <= 3: s =str(input("Введите строку: ")) n...
eb2672431ec79ee7a316806869318e8a586a5635
GitSmurff/LABA-2-Python
/Laba4/mathpack/gg1.py
306
3.65625
4
def gg1(): x = int(input("Введите число от 4 до 6: ")) if x >= 4 and x <= 6: m = int(input("Введите степень, в которую следует возвести число: ")) print(x**m) else: print("Ошибка ввода!")
5a80d705ec034b8139ca4c32beefff2f2852bf7c
pymatix/pyhton
/display logarithmic values for user input.py
128
3.734375
4
import math x=int(input("enter a numeric value to find log:")) print (math.log(x)) print (math.log(x,10)) print (math.log10(x))
8ad193780c081b95b0ff9129ec6c43b1c8b8d0a7
jlglearn/Code
/heap.py
2,058
3.71875
4
HeapLeft = lambda i : i*2; HeapRight = lambda i : i*2+1; HeapParent = lambda i : i//2; class Heap: def __init__(self): self.A = []; self.nElements = 0; def Value(self, i): assert((i > 0) and (i <= self.nElements)); return self.A[i-1]['key']; def Swap(self,...
2a265aa3683301252b6193920c57da2eb8ef943d
Amel294/amel
/ml/sddsds/ml5.py
569
3.578125
4
import matplotlib.pyplot as plt import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn import metrics data=pd.read_csv("/home/ai31/Desktop/common/ML/Day3/Questions/city.csv") #print(data) #print(data.head()) data=data.a...
16d142413e3b150cc842b9efe5032a44076eb3c3
Amel294/amel
/nlp/ass2/q1.py
180
3.578125
4
#!/usr/bin/python from textblob import Word theword = Word("watch") print(theword.pluralize()) from textblob import Word theword = Word("watches") print(theword.singularize())
37f3a5d3adbb3eda568f72b34bd44e8264e59fb8
Amel294/amel
/python/bank.py
369
3.65625
4
class bank: def add(self): us=1 a=self.acno=input('\n Enter account number:\t') b=self.acbal=input('\n Enter account bal\t') c=self.acno=raw_input('\n Enter account type:\t') d=self.noac=input('\n number of accounts:\t') e=self.aname=raw_input('\n name:\t') f=self.addre=raw_input('\n address:\t') li=[...
159fe63cfca5b1d83c6a412528be3abdd77371f5
Amel294/amel
/python/day9/q1.py
285
3.71875
4
#!/usr/bin/python class vect: def __init__(self,px,py): self.x=px self.y=py def dispv(self): print"(%f,%f)"%(self.x,self.y) def __add__(self,a): newx=self.x+a.x newy=self.y+a.y return vect(newx,newy) v1=vect(10,5) v2=vect(5,10) v3=v1+v2 v1.dispv() v2.dispv() v3.dispv()
afe5c40fa2cd2030009b7f5a211b21516a8b19a3
kaiyaprovost/algobio_scripts_python
/prob21_mergeSort_full.py
1,074
3.734375
4
def mergeSort(n,array): x = "" if n > 1: mid = n//2 left = array[:mid] right = array[mid:] mergeSort(len(left),left) mergeSort(len(right),right) i=0 j=0 k=0 while i < len(left) and j < len(right): if left[i] ...
0f626ce09d8e57b18275baa874f0917abdc21c97
kaiyaprovost/algobio_scripts_python
/prob27_rootedtrees.py
501
4
4
import math ## num rooted trees: ## (2n - 3)!! ## = ## (2n - 3)! / (n-2)! * 2^(n-2) ## math.factorial(2n - 4) ## / ## math.factorial(n-2) * math.pow(2,(n-2)) n = int(input("number of leaves: ")) def rootTreeCalc(n): num = int(math.factorial(2*n - 3)) den = int(math.factorial(n-2)) * int(math.po...
3ed6e13c885c7e666fd318e32e3b20278581df18
kaiyaprovost/algobio_scripts_python
/windChill.py
1,076
4.1875
4
import random import math def welcome(): print("This program computes wind chill for temps 20 to -25 degF") print("in intervals of 5, and for winds 5 to 50mph in intervals of 5") def computeWindChill(temp,wind): ## input the formula, replacing T with temp and W with wind wchill = 35.74 + 0.62...
dc12be1a75d335fbc764bee2ae11f759b7f22697
kaiyaprovost/algobio_scripts_python
/dna_to_rna.py
87
3.671875
4
dna = str(input("dna string to convert")) rna = dna.replace("T","U") print(rna)
89a6afcaabb168d3cf9988733987e7ec003d49ba
kaiyaprovost/algobio_scripts_python
/prob7_rosalind_substring.py
136
3.640625
4
string = "NbCEJ9e2QcLPf2JUmXNztSDlgpFGlmsJSci2gX04MHLhzKtyMV1TnoZV0rCFZ3dPSLtfnOPterinochilusMoqaDWpWejUhi2tjCLjNn8mYAdWKuPA3V6QRjpmyHwzmsalamandraTVy77qBxVLoKtWTnj2DdgTL9MjT8HCOGQe." print(len(string)) a=70 b=82 c=127 d=136 sub1 = string[a:(b+1)] sub2 = string[c:(d+1)] print sub1,sub2
811057a34fb5b59acf1f123ad850dafd421b010e
kaiyaprovost/algobio_scripts_python
/prob11_searchforsubstring.py
225
3.5
4
full = str(input("full string ")) motif = str(input("motif ")) ## wants 1 based numbers counti = 1 for i in range(len(full)): if full[i:i+len(motif)] == motif: print counti, counti = counti + 1
42b3e8b6194acad8057c5f10d1b2144887c5744a
Ekimkuznetsov/My_projects
/ex_11.py
296
3.90625
4
import re file = input("Enter the file: ") read = open(file) summ = 0 for line in read: num = re.findall("[0-9]+", line) #list of numbers in the line for elem in num: #sum by adding elements inside of each line elem = int(elem) summ = summ + elem print(summ)
7f5e66623babc6919733bec982bbd4d4baa10176
Ojhowribeiro/PythonProjects
/exercicios/PycharmProjects/exepython/ex014.py
315
4.125
4
c = float(input('Qual a temperatura em c°:')) f = float((c*1.8)+32) k = float(c+273) print('{}°C é igual a {:.2f}°F e {:.2f}°K'.format(c, f, k)) '''c = float (input('qual o valor em °c: ')) f = float (((9*c) /5 ) + 32) k = float (c + 273) print('{}°C é igual a {:.2f}°F e {:.2f}°K'.format(c, f, k))'''
cd9a5d6b6ed0f9df3733fcec8eced83f7c949e08
Ojhowribeiro/PythonProjects
/exercicios/PycharmProjects/exepython/ex040.py
477
3.828125
4
nome_aluno = str(input('Nome do aluno: ')) nota_1 = float(input('Qual foi sua primeira nota? ')) nota_2 = float(input("Qual foi sua segunda nota? ")) media = float((nota_1 + nota_2) / 2) if media < 5.0: status = 'REPROVADO' elif media >= 5.0 and media <= 6.9: status = 'RECUPERAÇÂO' elif media >= 7.0: status...
f929c42ac31f25d0783f58cd158fd7d3730a4251
Ojhowribeiro/PythonProjects
/exercicios/PycharmProjects/exepython/ex044.py
877
3.84375
4
preco_compras = float(input('Preço das compras: ')) print('''----Forma de Pagamento---- [1] á vista dinheiro/pix [2] á vista no cartão [3] 2x no cartão [4] 3x ou mais no cartão''') opcao = int(input('Qual sua opção? ')) if opcao == 1: s = preco_compras - (preco_compras * 0.10) elif opcao == 2: s = preco_c...
0369b41812b9cdd3bd66f2dacbd728497b6525c8
Ojhowribeiro/PythonProjects
/exercicios/PycharmProjects/exepython/ex006.py
370
4.15625
4
n = int(input('digite um numero: ')) dobro = int(n*2) triplo = int(n*3) raiz = float(n**(1/2)) print('O dobro de {} é {}, o triplo é {} e a raiz é {:.2f}'.format(n, dobro, triplo, raiz)) '''n = int(input('digite um numero: ')) mul = n*2 tri = n*3 rai = n**(1/2) print('o dobro de {} é {}, o triplo é {} e a raiz quad...
d5db4d147d1a96ba1713d98198e9c596b6d9e84c
Ojhowribeiro/PythonProjects
/exercicios/PycharmProjects/exepython/ex008.py
396
4.21875
4
medida = float(input('Qual o valor em metros: ')) cm = float(medida*100) mm = float(medida*1000) km = float(medida/1000) print('{} metros: \n{:.3f} cm \n{:.3f} mm\n{:.3f} km'.format(medida, cm, mm, km)) '''medida = float(input('qual a distancia em metros:')) cm = medida * 100 mm = medida * 1000 km = medida / 1000 pri...
71d253977476a26224ca7786de9883dc05ebe1c0
leyap/python3-tutorial
/Python3Tutorial/tuple.py
157
4.15625
4
tuple1 = () tuple2 = 'tuple', print(tuple2) tuple3 = 'a','b','c' print(tuple3) a,b,c = tuple3 print(b) a,b = '1','2' print(a,b) a,b = b,a print(a,b)
1dc781ac4bc168a9409b2ce2cfbc135987c0b061
leyap/python3-tutorial
/Python3Tutorial/logic.py
567
3.96875
4
# if, else, elif ''' False: False None 0 0.0 '' [] () {} set() others is True ''' ''' == != < <= > >= in ... ''' a = 1 b = 2 if a>b: print("a大于b") else: print("a小于b") # \ print("hello \ world") if (a > b): print("a大于b") elif (a == b): print("a等于b") else: print("a小于b") really = True if really: prin...
27ebd0caa32448dbf96bf0414c337a4d8d31eef4
DanDits/Masterarbeit
/polynomial_chaos/poly.py
12,980
3.671875
4
from functools import lru_cache import numpy as np import numpy.polynomial.polynomial as npoly import math # Pretty general implementation for a recursively defined polynomial basis in function form, so it is not optimized # as terms that cancel out are still calculated and may lead to inaccuracies. # For higher accur...
9de3fd928aecb53938eb1ced384dfb9deeb3a5b9
lzaugg/giphy-streamer
/scroll.py
1,426
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Console Text Scroller ~~~~~~~~~~~~~~~~~~~~~ Scroll a text on the console. Don't forget to play with the modifier arguments! :Copyright: 2007-2008 Jochen Kupperschmidt :Date: 31-Aug-2008 :License: MIT_ .. _MIT: http://www.opensource.org/licenses/mit-license.php """ ...
f8f775245f38f0553c139bf3253c449e7bf851d8
judeinno/CodeInterview
/test/test_Piglatin.py
941
4.15625
4
import unittest from app.Piglatin import PigLatinConverter """ These tests are for the piglatin converter""" class TestConverter(unittest.TestCase): """This test makes sure that once the first letters are not vowels they are moved to the end""" def test_for_none_vowel(self): self.pig = PigLatinConve...
b4ed1b7eb05ab6da331e525a39a51ddd196cc6b1
aliwo/swblog
/_drafts/number_baseball.py
3,274
3.578125
4
# 가설 1: 0 스트라이크 0 볼이 나오면 제대로 계산하지 못한다. # -> 반론: 모든 질문이 0스트라이크 0볼이 아닌 이상 xxx 는 소거 된다. # 가설 2: 설마 질문에는 0이 들어갈까? # -> 0 없애도록 했는데 역시 오답... # 사실은 111 처럼 중복이 가능하다? -> 문제에 명시되어 있다. 중복은 없어. def strikes(elem): if elem[1] == 0: return ['xxx'] question = str(elem[0]) if elem[1] == 1: return [f'{q...
ee93ccbf1d7a2333fb1d2c1f69c055d0a5d6a2df
aliwo/swblog
/_drafts/kakao_2019_11/crain.py
644
3.71875
4
def pick_doll(board, stk, pick): for layer in board: if layer[pick] != 0: stk.append(layer[pick]) layer[pick] = 0 return def solution(board, moves): answer = 0 stk = [] for pick in moves: pick_doll(board, stk, pick-1) if len(stk) >= 2: ...
90f0633a3a87aa291b56512cd6699dbde07985d9
aliwo/swblog
/_drafts/copy_test.py
593
4
4
from copy import deepcopy class Num: def __init__(self, num): self.num = num def __repr__(self): return str(self.num) a = [1, 2, 3] b = [Num(1), Num(2), Num(3)] # 할당 a1 = a b1 = b print('할당') a1.append(4) print(a) b1.append(Num(4)) print(b) print() # 얕은 복사 print('얕은 복사') a2 = a[:] b2 = b[...
00e5fa463d5a47ac891a6ce478dca0169e1c642c
aliwo/swblog
/_drafts/algo_expert_medium/three_number_sum.py
1,514
3.640625
4
from collections import defaultdict # def threeNumberSum(array, targetSum): # ''' # 정렬하고 탐색을 시작하나 # 아니면 정렬 없이 답을 만들까. # # two number sum 이면 딕셔너리 만들면 된다. # three number sum 이면 이중 루프 돌면서 딕셔너리를 look up 하면 되나? # # ''' # array.sort() # cache = {x: {y: True for y in array[i+1:]} for i, x in e...
4fddb352f78666322a54f60acf257705c02a540b
aliwo/swblog
/_drafts/skt_2022_11_26/the_great_merchant.py
3,918
3.65625
4
from typing import List, Any class Branch: """ 상인이 하루에 선택할 수 있는 경우의 수 입니다. 상인은 매일... - 구매 - 가만히 있거 - 판매 를 할 수 있습니다. """ def __init__(self, money: int, stone: int): self.money = money self.stone = stone def buy(self, price: int) -> "Branch": ...
6772a12b4837a3d7fa63a6eba3764c719d15983a
rzamoramx/data_science_exercises
/statistics/variance.py
604
4
4
""" Base functions for computes variances """ import math from typing import List from linear_algebra.vectors import sum_of_squares from statistics.central_tendencies import de_mean def standard_deviation(xs: List[float]) -> float: """ The standard deviation is the square root of the variance """ return math....
82649213d5ab8211c2da37b4f0db2aaef5f2829c
jaeglee94/allHomework
/03 Python Homework/PyBank/main.py
2,007
3.65625
4
#Import Libraries import os import csv from statistics import mean #Initialize Variables file = os.path.join("budget_data.csv") dataSet=[] PL = [] plChange = [] months = 0 netTotal = 0 average = 0.0 #Read CSV to list variable with open(file,"r",newline = "") as csvfile: csvreader = csv.reader(csvfile,delimiter ="...
e8ee5820f5c7b6e7a83f797c3077fd7015b92671
KoYeJoon/python_basic
/ch4/exercise4/exer2.py
459
3.625
4
""" f=open("sample.txt",'r') sum=0 count=0 while True: line=f.readline() if not line : break count=count+1 result=int(line) sum=sum+result print(sum) average=sum/count f.close() f=open("result.txt",'w') f.write(str(average)) f.close() """ f=open("sample.txt") lines=f.readlines() f.close() total=0 for line in l...
19e270416749b68d0334062ec0051001a30dfe35
ssegota/Complex-System-Engineering-Exercises
/vj5.py
2,370
3.65625
4
import numpy as np from Values import * import math #maximum allowed cost(budget) #used if useCostLimit = True costLimit = 8000 #if set to true it will use the predefined cost limit (which might be higher than first solution cost) #otherwise it will generate solution that has a better cost then the first rand...
1503231991538ae5b8dcda3e9e758a93956d01dd
chloebee102/Dunkin-Dash
/tiles.py
15,554
3.59375
4
# coding: utf-8 # In[56]: #needed to define the plane in which the player moves import items, enemies, actions, world #import pdb class MapTile(): def __init__(self, x, y): self.x = x self.y = y def intro_text(self): #display info when entering the tile raise NotImplementedError() ...
cfed7dd7c7a90f60de005c1f1c02124bfc4f6ef1
srinivasarao2468/Python
/class/class_variables.py
1,031
3.96875
4
class Employee: amount_increment=1.04 def __init__(self, fname, lname, salary): self.fname = fname self.lname = lname self.salary = salary self.email = fname+"."+lname+"@gamil.com" def fullname(self): return "{} {}".format(self.fname, self.lname) def amount_rise(...
96dc9f04059696a4f6b9af6233ee9de2cd73b927
srinivasarao2468/Python
/Excercises/currentdata.py
157
3.703125
4
from datetime import datetime print("current datetime ", datetime.now()) now = datetime.now() print("current datetime\n", now.strftime("%Y-%m-%d %H:%M:%S"))
2a64573bd720f3a1634f1e31855f76116eb72d2d
lancelote/testing_python_book
/test/unit/calculator_app/calculate_test.py
1,586
3.84375
4
import unittest from calculator_app.calculate import Calculate class TestCalculate(unittest.TestCase): def setUp(self): self.calc = Calculate() def test_add_method_returns_correct_result(self): self.assertEqual(4, self.calc.add(2, 2)) def test_add_method_raises_typeerror_if_not_ints(sel...
39d9b6de8c992a3e3e9ce1594b45527b29f62634
kelvinlegolas3/python-practice
/06-ObjectOrientedProgrammingv2.py
1,097
3.9375
4
# Assessment 6 : Object Oriented Programming v2 # Link : https://github.com/Pierian-Data/Complete-Python-3-Bootcamp/blob/master/05-Object%20Oriented%20Programming/04-OOP%20Challenge.ipynb # 1. print("Exercise # 1:") class Account: def __init__(self, owner, balance): self.owner = owner ...
059d0ddd6b41ff375c1296f092ed4a93ce77df7f
ahmad225/LeetCode
/Easy/Python/reverseInteger.py
282
3.75
4
def reverse(x: int) -> int: reversed = 0 while x != 0: temp = reversed * 10 + x % 10 if temp / 10 != reversed: return 0 #overflow of integer reversed = temp x /= 10 return reversed i = 2**40 print(9646324351 > 2 ** 31 - 1)
758a310ed0ad0ba45b24b35b75702f85f1aa61bc
TimIainMarsh/Project-Euler
/Problem1.py
300
3.828125
4
# list1 = [] # for i in range(1000): # # i%3 will produce zero if i is divisable by 3 - zero is seen as false that is why # # it is not(i%3) # if not(i%3) or not(i%5): # list1.append(i) # sum = 0 # for i in list1: # sum += i # print(sum) for i in range(20,0,-1): print(i)
3efa7e30fb15bcf535e23fed76bbc3f2b6071625
Kontetsu/pythonProject
/example6.py
160
3.921875
4
# Comparison operators john_1 = "John" john_2 = "John" print(john_1 == john_2) print(1 != 1) print(99 < 1.1) print(99 > 1.1) print(-32 >= -33) print(123 <= 123)
9a187a02324ff8272baffd64344857c219549ef3
Kontetsu/pythonProject
/example40.py
241
3.703125
4
# Exceptions # Divide smth by zero a = 1 b = [1, 2, 3, 0, 0, "string", "hello"] for element in b: try: print(a / element) except (ZeroDivisionError, TypeError) as error: print("This is an exception {}".format(error))
5b2887021b660dfb5bca37a6b395b121759fed0a
Kontetsu/pythonProject
/example24.py
659
4.375
4
import sys total = len(sys.argv) - 1 # because we put 3 args print("Total number of args {}".format(total)) if total > 2: print("Too many arguments") elif total < 2: print("Too less arguments") elif total == 2: print("It's correct") arg1 = int(sys.argv[1]) arg2 = int(sys.argv[2]) if arg1 ...
e8310a33a0ee94dfa39dc00ff5027d61c74e6d94
Kontetsu/pythonProject
/example27.py
748
4.28125
4
animals = ["Dog", "Cat", "Fish"] lower_animal = [] fruits = ("apple", "pinnaple", "peach") thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } #for anima in animals: # lower_animal.append(anima.lower()) print("List of animals ", animals) for animal in animals: fave_animal = input("Ent...
7b53f5e59aaa660a1e5c8be1541a55f888966e1c
hfw6310/LeetCode-Method
/206. 反转链表.py
1,003
4
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def reverseList(self, head): """ :type head: ListNode :rtype: ListNode """ # 递归 if hea...
2f206911f23fee3c39bdfc19824907c366146a3b
hfw6310/LeetCode-Method
/234. 回文链表.py
1,106
3.859375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def isPalindrome(self, head: ListNode) -> bool: # 堆栈 stack = [] # step1: push curr = head while (curr): ...
9e9bd791108484ce6835338381726b17dbc52d83
littlet1968/div_scripts
/matchDate.py
2,476
3.75
4
from datetime import datetime def match_date(myDate): try: # we only have a date? if len(myDate.split(' ')) == 1: try: myDObj = datetime.strptime(myDate, '%d-%b-%Y') # return date object in form "DD-MM-YYY" return(myDObj) ...
2c7b93cc1861afa5516f966e22e45c0a7e47f701
LauraSiobhan/beginning_python_jan2020
/students/ryan/exercise_14_2.py
209
3.796875
4
card_list = [(3, 'diamonds'), (8, 'clubs')] total = 0 for item in card_list: number = item[0] suit = item[1] print(f'{number} of {suit}') total += number print(f'My total number of points is {total}')
d210715994b35fe9e77948473c5ad580111f1e8a
LauraSiobhan/beginning_python_jan2020
/examples/blackjack.py
3,887
3.96875
4
""" This is a simple implementation of a blackjack game. The basic rules are: the dealer deals you cards, starting with two, then adding one if you "hit". Your goal is to reach, but not exceed, 21 points. If the dealer has more points than you without going over 21, they win. If you have more points than the dealer ...
089268b059eb6f71a886c24ed1e6ed55fa6a58e9
mabauer/aoc2020
/src/day09.py
2,710
4.09375
4
#!/usr/bin/env python3 import re import os import sys from typing import List from utils import read_inputfile # Convert input into list of ints def read_numbers(input: List[str]) -> List[int]: result = [ int(line) for line in input ] return result # Verify if number equals to the sum of some pair in to_co...
309858fc891519e6fd7b4f9913ec9b759215f034
mabauer/aoc2020
/src/day10.py
4,552
3.765625
4
#!/usr/bin/env python3 import re import os import sys from typing import List from typing import Tuple from typing import Dict from utils import read_inputfile # Convert input into list of ints def read_numbers(input: List[str]) -> List[int]: result = [ int(line) for line in input ] return result # Count t...
a2e7daef49e13c888bac2502866972f7d7c8598e
mabauer/aoc2020
/src/utils.py
199
3.5625
4
from typing import List import os def read_inputfile(filename: str) -> List[str]: with open("input" + os.path.sep + filename) as f: input = [line.strip() for line in f] return input
1688c93855bda769c0e21a5cbfb463cfe3cc0299
JimVargas5/LC101-Crypto
/caesar.py
798
4.25
4
#Jim Vargas caesar import string from helpers import rotate_character, alphabet_position from sys import argv, exit def encrypt(text, rot): '''Encrypts a text based on a pseudo ord circle caesar style''' NewString = "" for character in text: NewChar = rotate_character(character, rot) NewStr...
98b83cd4a9300252b7a6f5c9f8ab63aba966c33b
deyoung1028/Python
/classwork7_15.py
1,090
4
4
#json # int, float, bool, dictionary, array #array of int, array of dictionary, array of bool, etc. import json from os import name # write json #with open("car.json", "w") as file #car = {"make":"Honda", "model": "Accord", "noOfCylinders":2} #json.dump(object you want to write, file object) #...
b211b888702bbb1ebed8b6ee2b21fec7329a7b59
deyoung1028/Python
/to_do_list.py
1,738
4.625
5
#In this assignment you are going to create a TODO app. When the app starts it should present user with the following menu: #Press 1 to add task #Press 2 to delete task (HARD MODE) #Press 3 to view all tasks #Press q to quit #The user should only be allowed to quit when they press 'q'. #Add Task: #Ask the user f...
e41796d392658024498869143c8b8879a7916968
deyoung1028/Python
/dictionary.py
487
4.21875
4
#Take inputs for firstname and lastname and then create a dictionary with your first and last name. #Finally, print out the contents of the dictionary on the screen in the following format. users=[] while True: first = input("Enter first name:") last = input("Enter last name:") user = {"first" ...
210c1ad4af6f4f8e6d59be5997cfd4af820a60e1
jhonatacaiob/EXERCICIOS-DE-REPETI-AO-DE-LOGICA
/QUESTÃO 7.py
687
3.78125
4
primeira=[] segundo=[] terceiro=[] quarto=[] quinto=[] def preguiça(x): print("Nessa lista, existem", len(x), "pessoas") for i in range (1,16,1): idades = int(input("QUAL SUA IDADE?: ")) if idades<=0: print("Você não é um recém nascido") elif idades <= 15: primeira += [idades...
b4b7af57d632857f823abddf5385ed1d8f802c6b
hieast/PlayGround
/MOOC/Rice/AIIPP(An Introduction to Interactive Programming in Python)/Stopwatch The Game.py
1,870
3.5625
4
#"Stopwatch: The Game" import simplegui # define global variables width = 300 hight = 200 font_size = 48 seconds = 0 success = 0 stoped = 0 running = False # define helper function format that converts time # in tenths of seconds into formatted string A:BC.D def format(t): if t >= 6000: return "Boommmmmm!...
47a0012507170ee674d6b2096d69059606842e2d
AnanditaGuha/Chapter4Anandita_Hunter
/fiveb.py
273
3.734375
4
import turtle def draw_spiral(t,n,sz,ang): for i in range(n): t.right(ang) t.forward(sz) sz = sz + 5 wn = turtle.Screen() tess = turtle.Turtle() wn.bgcolor("lightgreen") tess.color("blue") tess.pensize(3) draw_spiral(tess,99,5,89) tess.right(90)
63d5e945c98414589b8511ac360b670e836d9eaa
KritikRawal/Lab_Exercise-all
/2.11.py
96
3.921875
4
"""What is the result of 10**3?""" print("The result of 10**3 is: ") print(10 ** 3) print()
74dee8921f4db66c458a0c53cd08cb54a2d1ba63
KritikRawal/Lab_Exercise-all
/4.l.2.py
322
4.21875
4
""" Write a Python program to multiplies all the items in a list""" total=1 list1 = [11, 5, 17, 18, 23] # Iterate each element in list # and add them in variable total for ele in range(0, len(list1)): total = total * list1[ele] # printing total value print("product of all elements in given list: ", tota...
d71d9e8c02f405e55e493d1955451c12d50f7b9b
KritikRawal/Lab_Exercise-all
/3.11.py
220
4.28125
4
""" find the factorial of a number using functions""" def factorial(n): if n == 1: return 1 else: return n * factorial(n - 1) num = int(input('enter the number')) print(factorial)
53b8278af9a4a98b4de820d91054d80e9f1247f4
KritikRawal/Lab_Exercise-all
/3.8.py
393
4.125
4
"""takes a number as a parameter and check the number is prime or not""" def is_prime(num): for i in range(2, num): if num % i == 0: return False return True print('Start') val = int(input('Enter the number to check prime:\n')) ans = is_prime(val) if ans: print(val,...
1f611b99273d9a3b4f8cf798e9c6834868a8dded
KritikRawal/Lab_Exercise-all
/4.8.py
192
3.84375
4
"""display the Fibonacci series between 0 and 50""" disp = 0 a = 1 series = [] while disp <= 50: series.append(disp) temp = disp disp = disp + a a = temp print(series)
9bd2b639bea460194c13fea4a4964f0ee94e1fc8
KritikRawal/Lab_Exercise-all
/4.l.4.py
176
3.984375
4
"""Write a Python program to get the smallest number from a list.""" list1 = [10, 20, 4, 45, 99] # printing the minimum element print("smallest element is:", min(list1))
ae6ae8cfe7e655b1ffc9617eb8d87480a97e8f27
KritikRawal/Lab_Exercise-all
/4.2.py
635
4.4375
4
""". Write a Python program to convert temperatures to and from celsius, fahrenheit. C = (5/9) * (F - 32)""" print("Choose the conversion: ") print(" [c] for celsius to fahrenheit") print(" [f] for fahrenheit to celsius") ans = input() conversion = 0 cs = "" if ans == "c": ans = "Celsius" elif an...
b9e75d0b9d9605330c54818d1dd643cc764032cf
KritikRawal/Lab_Exercise-all
/2.5.py
277
4.21875
4
"""For given integer x, print ‘True’ if it is positive, print ‘False’ if it is negative and print ‘zero’ if it is 0""" x = int(input("Enter a number: ")) if x > 0: print('positive') elif x<0: print('negative') else: print('zero')
e76c314a76e8dfbab059db55880212321501f8e6
dmccuk/the_python_mega_course
/String_Manuipulation/stock_v_writers.py
576
3.5625
4
o = 790 h = 6 names_rating = {"Lucy": 18, "Mary": 12, "Henry": 10, "Stacey": 11, "Loulou": 5} print("") print("Hours to comlete %s orders" % o) for i in names_rating.values(): x = o / i print(round(x,1)) print("") print("Hours taken for everyone working together to complete %s order" % o) print(o / sum(names_...
f7026478851e7f253d9786928bdd2f65d1b7098b
dmccuk/the_python_mega_course
/User_input/string_formatting uppercase.py
153
3.953125
4
def name(value): first = value.capitalize() message = "Hi %s" % (first) return message name1 = input("Enter your name: ") print(name(name1))
815dfb869742fe6053bc5edbca8760044a00cdda
pniedzwiedzinski/cpp-cuda-linear-regression
/scripts/linear_regression.py
1,116
4.03125
4
""" This module contains python implementation of linear regression algorithm, that I will be then implement in CUDA. I will be using data generated from `generate_data.py`, which generates data of function `y = 3x + 2`. The model will is of form `y = X * W` where `X` is a vector of features and `W` is a vector of wei...
0ec3619cec0dc520dabfe5fe4317acc9f95312fb
bugxiaoc/spider-Demo
/spider_Demo/tools/stringu.py
808
3.515625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import re """ String Util """ def checkURI(str): if re.search('',str,re.S): return 1 else: return 0 def delete_space(obj): while '' in obj: obj.remove('') return obj def fromat_list(obj): temp = [] for x in obj: temp....
3de052724e3e39f88b6cdeaf03793aaeab0eafd8
DJMedhaug/mad_libs
/madlib.py
523
4
4
animal = input('Enter an animal ') madlib = animal madlib += ' can be found running wild in ' madlib += input(' Enter a city... ') madlib += ' causing distruction at every turn, when he turned ' madlib += input('Enter a color ') madlib += ' he gained strength and speed, {} tried to run from the people. '.format(animal)...
336721b955f93d2642cb854994909e450d6d15c1
Anas321/single_stone_task
/spark_sql.py
1,505
3.5
4
"""Start a spark session to generate the required document.""" from pyspark.sql import SparkSession import config def generate_json_report(input_files, report_file_name=config.OUTPUT_FILE): """Generate a json report by starting a spark session. Args: - input_files: input files names. ...
d3271b426ac5456f44d241952152409ed5acb612
erick-guerra/python-oop-learning
/Python Beyond the Basics - Object-Oriented Programming - Working Files/Chapter 3/1_classes.py
448
3.9375
4
class MyClass(object): var = 10 # this_obj is a MyClass instance or MyClass Object this_obj = MyClass() # created second instance to show different hex cod (memory address) that_obj = MyClass() print(this_obj) print(that_obj) print(this_obj.var) # Instance access variable from the class; 10 print(that_obj.var) ...
379041e760fc23eadd2de54d6a67c3bcf1cec6df
erick-guerra/python-oop-learning
/Python Beyond the Basics - Object-Oriented Programming - Working Files/Chapter 5/scratch_dir/scratch.py
663
3.53125
4
import os class DictConfig(dict): def __init__(self, filename): self._file_name = filename if os.path.isfile(self._file_name): with open(self._file_name, 'a') as fh: fh.writelines("{key}={value}\n".format(key=key, value=value)) def __setitem__(self, key, value): print("Set Item") dict.__setitem__...