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
2f6a2d06d0acc256bb05ddf534f612dcbf040fbd
capss22/python
/python_程式碼/ch3/3-3-5-dict5.py
210
3.609375
4
lang={'早安':'Good Morning','你好':'Hello'} for ch, en in lang.items(): print('中文為', ch, '英文為', en) for ch in lang.keys(): print(ch,lang[ch]) for en in lang.values(): print(en)
92ae64d044ef72ba32f756f8a6bb41c604a3f4f3
radimzitka/advent-2020
/10/10.py
1,029
3.625
4
# Advent of code 2020 # # Author: Radim Zitka # # Task: 10 # from os import replace input = open("input", "r") # Read file row by row lines = input.readlines() adapters = [] for line in lines: adapters.append(int(line)) adapters.append(0) adapters.sort() adapters_len = len(ada...
0f79e96638a920b157ee0ceed4bc93ba0bf686b0
xaliap81/US-Bikeshare-Data
/bikeshare.py
6,894
3.890625
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import time import pandas as pd import numpy as np data = {'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv'} cities = ['chicago', 'new york city', 'washington'] months = ['jan...
cec21951ac0bba2466db7fbcfdb87bf89bc8ef6b
Zayne-sprague/Kaggle_VinBigData_Competition
/KaggleCompVinBD1/src/utils/timer.py
485
3.71875
4
import time from typing import Optional class Timer: def __init__(self): self.start_time: Optional[float] = None def start(self) -> None: assert self.start_time is None, "timer is already running" self.start_time = time.perf_counter() def stop(self) -> float: assert self...
fcc99a2234f0ec53bf8c02adad4d79e889ac3edc
DiiiLongas/python_exercises
/ReadExcelPython.py
608
3.625
4
import pandas as pd df = pd.read_excel('C:\\Users\\d.longas\\Documents\\IMPORTANT 2021\\Varios Diana\\DaniHermoso.xlsx') empleados = df["Empleados"].tolist() #print(empleados) newlist = ["Daniel Velásquez", "Diana Longas", "María Zapata", "Julio Domingo"] for hola in range(len(newlist)): empleados.append(newlist...
dfd6eec37a34258a95609a6b976a423d3cbf6fe4
AmiteshMagar/Physics-Dept._PyTut-2
/p10.py
388
3.5625
4
def subRout10(n,Lx,Ly): LyPrime = [] #this for us to compute the last value Lx.append(Lx[0]) Ly.append(Ly[0]) for i in range(n): calc= (Ly[i+1] - Ly[i])/(Lx[i+1] - Lx[i]) LyPrime.append(calc) Ly.pop(len(Ly)-1) return LyPrime #testing subRout10 -- works perfectly! ...
bcfcdb2a40292a27ca91b1ce7f50e41cd70bb974
AmiteshMagar/Physics-Dept._PyTut-2
/p7.py
2,284
3.875
4
#Made by: Amitesh import math '''from p6 import secant''' #apparently import statement doesn't work in this case # because the functoin in p6 take only 1 value for computation, #but our function takes in 3 values #To avoid editig the previous program I will be wirting different ways solve using THIS function ...
b0069a97b817938cad5711112f3f8039a6d973c3
Laxmivadekar/file
/xyz.py
231
3.546875
4
f=open('xyz.txt','w') f.write('\n1.R-opens a file for reading \n2.W-opens a file for waiting \n3.x- creates a file if not exists \n4.a-add more content to file \n5.t-text mode \n6.b=binary mode \n7.+-read and write mode') f.close()
e3ee59510a40d8bf6d1203a3d8dd9df17b864d62
cdufour/tsrs19-scripting
/python/strings3.py
1,787
3.828125
4
# strings3.py phones = [ "+33611 2233 44", "+39611223355", "+3961 1223366", "+33611223377", "+3361122 3388", "+40611223399", "+381 61122 33 22", "+4061122 3333", "+40611223300", ] str = "Je sais programmer en Python" str = "+33-07-88-33-22-50" # x = str.upper() # => JE SAIS PROG...
30adf60cec6adb28424367070012751ef78de6b6
cdufour/tsrs19-scripting
/python/sumInput.py
541
3.703125
4
# sumInput ''' Créer un script demandant à l'utilisateur de saisir un chiffre tant que la somme des chiffres précédemment saisis est inférieur à 100 exemple: 10 60 10 30 => 10 + 60 + 10 + 30 = 110 > 100 => sortie de boucle ''' sum = 0 # variable servant à faire le cumul des valeurs saisies while sum < 100: # on boucl...
976f57ced6c60750c43743c012b410a441ac12f0
KamauLaud/Advanced-Machince-Learning-HW3
/kernelsvm.py
7,663
3.53125
4
"""Functions for training kernel support vector machines.""" import numpy as np from quadprog_wrapper import solve_quadprog def polynomial_kernel(row_data, col_data, order): """ Compute the Gram matrix between row_data and col_data for the polynomial kernel. :param row_data: ndarray of shape (2, m), whe...
6b0d37ace57f0f1a9a865412289c2d203207ad25
ccheung9595/Math_2305_Final_Project
/Functions/graph_operations.py
1,397
3.90625
4
# -*- coding: utf-8 -*- def min_cost_edge(G, T): edges_0 = [] # finds all edges that have a vertex already in the minimum tree spanning graph for e in G[1]: for v in T[0]: if v in e and e not in T[1]: edges_0.append(e) edges = [] # removes...
6bdfdbbf5749d68b7a915d654bcd19b01119a3b9
katherineskc/Coursera_Capstone
/Neighborhoods_in_Toronto.py
4,540
3.65625
4
#!/usr/bin/env python # coding: utf-8 # # Segmenting and Clustering Neighborhoods in Toronto # ## PART 1 scrape data and create dataframe # In[1]: #import libraries import pandas as pd import numpy as np get_ipython().system('pip install lxml') # In[4]: #import BeautifulSoup from urllib.request import urlopen ...
47b069d28a5dc0064c7a0eed239485aedf5087ed
Somacros/inteligencia-artificial-4_2
/Equipo 3 Busqueda en profundidad iterativa limitada.py
3,301
3.59375
4
class Node(object): def __init__(self, label: str=None): self.label = label self.children = [] def __lt__(self,other): return (self.label < other.label) def __gt__(self,other): return (self.label > other.label) def __repr__(self): return '{}'.fo...
71c4d5c56c625a13150a5b1fbc4173f817da7c05
zwqll/entity
/Bi-LSTM-CRF-pos/Server/utils/MySQLUtil.py
2,725
3.875
4
import MySQLdb class MySQLUtil: def __init__(self, **login): ''' The constructor of MysqlOperator class. Creates an instance of MysqlOperator and starts connecting to the MySQL Database. :Args: - **login - Keyword arguments used in pymysql.Connect() ...
6d0b67fc4adc19862870b5e4d1533bc7af262c44
CPTpersonal/IC-POS
/checkout.py
1,907
3.890625
4
import sys def checkout(Products, Cost): """This function answers queries on products and their total cost""" total_cost = 0 # initializing total cost # first do a sanity check on inputs if type(Products) is not list or type(Cost) is not dict: print("Error: The products must be in a list ...
24965a5a115396529f362f8c93fbfde9942b9c0b
andyjung2104/BOJ-source-codes
/2775.py
164
3.6875
4
import math t=int(input()) for _ in range(t): k=int(input()) n=int(input()) print(math.factorial(n+k)//(math.factorial(k+1)*math.factorial(n-1)))
8d374865b226eeffe9b449fdc896b4014979c70f
andyjung2104/BOJ-source-codes
/2839.py
307
3.578125
4
N=int(input()) if N%5==0: print(N//5) elif N%5==1: if N>=6:print((N-6)//5+2) else:print(-1) elif N%5==2: if N>=12:print((N-12)//5+4) else:print(-1) elif N%5==3: if N>=3:print((N-3)//5+1) else:print(-1) elif N%5==4: if N>=9:print((N-9)//5+3) else:print(-1)
a22afaf9ef8748ca6fc54e49db57fc92f9e5bc73
andyjung2104/BOJ-source-codes
/1978.py
345
3.765625
4
N=10**3 isPrime=[True for i in range(N+1)] isPrime[0]=False isPrime[1]=False for i in range(4,N+1,2): isPrime[i]=False for i in range(3,int(N**.5)+1+2,2): j=i while j*i<N+1: isPrime[j*i]=False j+=1 n=int(input()) L=list(map(int,input().split())) cnt=0 for l in L: if isPrim...
986f08d7a5a1aff7e58a28de015ebe8ac69d81dc
andyjung2104/BOJ-source-codes
/4375.py
492
3.765625
4
import math while True: try: n=int(input()) tmp=1 while True: if pow(10,tmp,n)==1: print(tmp) if n%3!=0: print(tmp) elif n%9==0: print(math.lcm(9,tmp)) ...
a157d4775a860a6be525c7308aed0773f5dd926b
eugenialuzzi/UADE
/PROGRA1_TP1_ej6.py
842
4.125
4
#Escribir dos funciones para imprimir por pantalla cada uno de los siguientes patrones #de asteriscos. def ImprimirCuadrado(n): """Imprime un cuadrado de asteriscos. Recibe la cantidad de filas y columnas nxn, e imprime el cuadrado de asteriscos""" for i in range(n): for j in range(n): ...
ab3a2c874319978421cb53769fa233c0d00db571
ReutFarkash/hello-world
/hungry.py
92
3.921875
4
hungry = input("I'm hungry") if hungry=="yes": print("eat") else: print("don't eat")
3757e733e79b329d2ef44a3028bd5c598d7f25d9
Endless5F/PythonModel
/machinelearn/linearregression/lr_house_price.py
1,680
3.6875
4
# 多因子线性回归实战 import pandas as pd import numpy as np from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error, r2_score data = pd.read_csv("./csv/usa_housing_price.csv") # print(data.head()) # 绘制源数据点图 plt.figure(figsize=(8, 8)) # 绘制源数据第一幅点图 p...
7c42c300bc601c5d096aa228aec5ac4ea961b318
Kallaf/UVA
/Data Structures/Linear/1D Array Manipulation/UVa 00230.py
992
3.734375
4
books = [] while True: line = input() if line == "END": break temp = line.split("by") arr = [] arr.append(temp[1][1:]) arr.append(temp[0][:-1]) arr.append(False) arr.append(False) books.append(arr) books.sort() def find(title): global books for i in range (0,len(books)): if title == books[i][1]: r...
b6ab8cc66e3b4b99829ae5379566ec00061660db
ssamea/CosPro_CodingTest
/step1/5차/ex5.py
1,293
3.609375
4
# 다음과 같이 import를 사용할 수 있습니다. # import math # 캐릭터는 자신과 공격력이 같거나 자신보다 공격력이 작은 몬스터에게 이깁니다. 내가 가진 캐릭터가 최대 몬스터 몇 마리를 이길 수 있는지 구하려 합니다. 단, 한 캐릭터는 한 번만 싸울 수 있습니다. def solution(enemies, armies): # 여기에 코드를 작성해주세요. answer = 0 cnt=[0 for i in range(len(armies))] # 이긴 카운팅 횟수를 체크하려는 변수 for i in range(len(armies)...
90a7b9001dcb738a41a3fbb63980ec2af3c51e3d
ssamea/CosPro_CodingTest
/step1/5차/ex6.py
1,389
3.640625
4
# 다음과 같이 import를 사용할 수 있습니다. import math # p 진법으로 표현한 수란, 각 자리를 0부터 p-1의 숫자로만 나타낸 수를 의미합니다. p 진법으로 표현한 자연수 두개를 더한 결과를 q 진법으로 표현하려 합니다. # 접근법: 10진수로 변환 후 더하고 q진법으로 변환 numbers_int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] numbers_char = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] def char_to_int(ch): for i in rang...
546d8ed52ab454e257620bae9050a44188030e6a
majf2015/python_practice
/operation.py
1,781
3.71875
4
# encoding:utf-8 #---用数列表示加运算--- def add(s1, s2): ss = ['0', '0'] if int(float(s1)) == float(s1): if int(float(s2)) == float(s2): ss1 = [str(s1), '0'] ss2 = [str(s2), '0'] else: ss1 = [str(s1), '0'] ss2 = s2.split('.') else: if int(fl...
ead3b82dc0a2abc558fb523ef8fa57b45fcc2b34
majf2015/python_practice
/exercise/slice.py
833
3.78125
4
list1 = range(1,6) list2 = [12,13,14,15] print list1[: 3] + list2[-3: ] for v in list1: print v i = 0 while i < len(list1): print list1[i] i = i + 1 d1 = {1:'a',2:'b', 3:'c'} for key, val in d1.iteritems(): print key print val print [x for x in range(0,11)] print [x for x in list1 if x%3 == 0] import os prin...
6fb8d633ce4fa7132301cdf0684e6347f1a2f7fb
majf2015/python_practice
/persen_system.py
5,493
3.9375
4
# -*- coding: utf-8 -*- class Person: def __init__(self, n, s, h, w): self.name = n self.sex = s self.height = h self.weight = w def set_name(self, n): self.name = n def set_sex(self, s): self.sex = s def set_height(self, h): self.height = h ...
b5fcbf409e26739cd5887c5b6accfb0c95d3e18f
majf2015/python_practice
/exercise/0107iter.py
510
3.578125
4
d = {'name': 'feng', 'age': 27, 'gender': 'male'} for key in d: print key for value in d.itervalues(): print value for v in d.iteritems(): print v for age in 'age': print age from collections import Iterable print isinstance('qwe', Iterable) print isinstance([1, 2, 3], Iterable) print isinstance(123, Iterable) fo...
2f69c84b0517375ad6e4591ca8ad4dab9279d708
AkashKadam75/Kaggle-Python-Course
/Boolean.py
716
4.125
4
val = True; print(type(val)) def can_run_for_president(age): """Can someone of the given age run for president in the US?""" # The US Constitution says you must "have attained to the Age of thirty-five Years" return age >= 35 print("Can a 19-year-old run for president?", can_run_for_president(19)) print("C...
8ed25f22f141f16ac4a1c3c5729bf4da3d78c44b
huboa/xuexi
/python-15/day07-mokuai-面向对象/经典类-新式类.py
292
3.765625
4
## class A(object): def __init__(self): self.n="A" class B(A): def __init__(self): self.n="B" class C(A): def __init__(self): self.n="C" class D(B,C): def __init__(self): self.n="D" d=D() print(d.n) super(Teacher,self).__init__(name,age,sex)
a800f4194fb50c8bd6e9d0ab1ca695e13b77c460
huboa/xuexi
/liaoxuefeng/03-gao-advance/05-high.py
397
3.953125
4
##小九九 n = 9 i = 0 while (i < n): i += 1 j = 0 L = [] while(j < i): j += 1 s = j * i # print(j,"*",i ,"=",s) L.append("%s*%s=%s"%(j,i,s)) print(L) ##汉诺塔 # def move(n,a,b,c): # if n==1: # print(a,'->',c) # else: # move(n-1,a,c,b) # ...
0dc27ea73cc01d635831dbf892f2381c0860fba4
huboa/xuexi
/oldboy-m1/day-01/day01/day01 - 1/day01 - 1/前夕/3.什么后面可以加括号.py
695
3.8125
4
def f1(): print('f1') class F2(object): pass class F3(object): def __init__(self): pass def ff3(self): print('ff3') class F4(object): def __init__(self): pass def __call__(self, *args, **kwargs): print('f4') def func(arg): """ ...
8f4590da596edc00f9cdadd9efe7a758801ea178
huboa/xuexi
/oldboy-python18/day07-模块补充-面向对象/homework/选课系统/core/main.py
2,196
3.578125
4
import auth class school: def __init__(self, name, address,city): self.name = name self.address = address self.city=city class student: def __init__(self, name, age, sex='male'): self.name = name self.age = age self.sex = sex class teacher: def __init__(self,...
f4b8871a85d3db6934353309013264ee2c244ea6
huboa/xuexi
/oldboy-python18/day02-列表-字典/home-work-stu/谢文明/作业二:打印省市/打印省市.py
555
4
4
dic = { "河北": { "石家庄": ["鹿泉", "藁城", "元氏"], "邯郸": ["永年", "涉县", "磁县"], "邢台":["a","b","c"] }, "江苏": { "连云港":["灌南","灌云","新浦"], "南京":["4","5","6"], "无锡":["1","2","3"] } } name=input("请输入中国省名称:") if name in dic: for i in dic[name].keys(): ...
ef8b9904bbaf95f0ee8e7b53ecff67ae4b2593c9
huboa/xuexi
/oldboy-python18/day04-函数嵌套-装饰器-生成器/00-study/00-day4/生成器/生成器.py
1,807
4.28125
4
#生成器:在函数内部包含yield关键,那么该函数执行的结果是生成器 #生成器就是迭代器 #yield的功能: # 1 把函数的结果做生迭代器(以一种优雅的方式封装好__iter__,__next__) # 2 函数暂停与再继续运行的状态是由yield # def func(): # print('first') # yield 11111111 # print('second') # yield 2222222 # print('third') # yield 33333333 # print('fourth') # # # g=func() # print(g) #...
673f64bffaa92c61ca63bcdb0e0c53f3b9fad628
huboa/xuexi
/python-15/day04/匿名函数.py
352
3.84375
4
def calc(n): # if n > 5: # print("hello") n=n*2 return n*n #print(calc(6)) map(calc(),[1,2]) ###匿名函数lambda data = map(lambda n:n*2,[1,2]) print(data) data = map(lambda n:n*2,range(10)) print(data) for n in data: print(n) data = map(lambda n:n*n,range(10)) ###3元运算 a = 4 b = 5 d =a if a >1...
8c4f19f7f6a830f31d76d64251ee6bcc0c46366d
huboa/xuexi
/oldboy-python18/day07-模块补充-面向对象/self/05-继承/组合.py
1,585
4.25
4
class OldboyPeople: school = 'oldboy' def __init__(self,name,age,sex): self.name=name self.age=age self.sex=sex def eat(self): print('is eating') class OldboyStudent(OldboyPeople): def __init__(self,name,age,sex): OldboyPeople.__init__(self,name,ag...
86eb98601768f42b58559422e47e2b3d516d3bdd
huboa/xuexi
/oldboy-python18/day07-模块补充-面向对象/00-tt/day7/继承/继承.py
2,485
4.53125
5
#继承的基本形式 # class ParentClass1(object): #定义父类 # pass # # class ParentClass2: #定义父类 # pass # # class SubClass1(ParentClass1): #单继承,基类是ParentClass1,派生类是SubClass # pass # # class SubClass2(ParentClass1,ParentClass2): #python支持多继承,用逗号分隔开多个继承的类 # pass # # # # # print(SubClass1.__bases__) # print(SubClass2.__b...
ddfcc054d45dfe20bf93034f9c55af42bd8a2e9b
huboa/xuexi
/oldboy-python18/day04-函数嵌套-装饰器-生成器/00-study/00-day4/函数嵌套.py
620
4.03125
4
#函数的嵌套调用:在调用一个函数的过程中,由调用了其他函数 # def bar(): # print('from nbar') # # def foo(): # print('from foo') # bar() # # foo() # def max2(x,y): # if x > y: # return x # else: # return y # # # def max4(a,b,c,d): # res1=max2(a,b) # res2=max2(res1,c) # res3=max2(res2,d) # return...
fe0628d501eaa9391b229991a3dfaf1940ff0751
huboa/xuexi
/oldboy-python18/day03-函数-file/00-day3/函数参数.py
2,026
4.3125
4
#形参:在定义函数时,括号内的参数成为形参 #特点:形参就是变量名 # def foo(x,y): #x=1,y=2 # print(x) # print(y) #实参:在调用函数时,括号内的参数成为实参 #特点:实参就是变量值 # foo(1,2) #在调用阶段实参(变量值)才会绑定形参(变量名) #调用结束后,解除绑定 #参数的分类 #位置参数:按照从左到右的顺序依次定义的参数 #位置形参:必须被传值,并且多一个不行,少一个也不行 #位置实参:与形参按照位置一一对应 # def foo(x,y): # print(x) # p...
2fa86da40002d7a92e3dd06c3643c3cf76d8f91c
huboa/xuexi
/oldboy-python18/day08-接口-网络/00-day8/封装.py
2,931
4.15625
4
#先看如何隐藏 class Foo: __N=111111 #_Foo__N def __init__(self,name): self.__Name=name #self._Foo__Name=name def __f1(self): #_Foo__f1 print('f1') def f2(self): self.__f1() #self._Foo__f1() f=Foo('egon') # print(f.__N) # f.__f1() # f.__Name # f.f2() #这种隐藏需要注意的问题: #1:这种隐藏只是一种语法上变形操作...
052744e05cac11301014d1c33f8bc99e41c023c0
huboa/xuexi
/oldboy-python18/day03-函数-file/00-day3/可变长参数.py
2,575
4.15625
4
#可变长参数指的是实参的个数多了 #实参无非位置实参和关键字实参两种 #形参必须要两种机制来分别处理按照位置定义的实参溢出的情况:* #跟按照关键字定义的实参溢出的情况:** # def foo(x,y,*args): #nums=(3,4,5,6,7) # print(x) # print(y) # print(args) # foo(1,2,3,4,5,6,7) #* # foo(1,2) #* #*args的扩展用法 # def foo(x,y,*args): #*args=*(3,4,5,6,7) # print(x) # print(y) # print(args...
b969c7d2a9ef82a20bdccb4fff835a0b31c1c807
huboa/xuexi
/oldboy-python18/day06-模块/00-day6/内置函数补充.py
1,653
3.96875
4
#与匿名函数结合使用 #max,min,sorted salaries={ 'egon':3000, 'alex':100000000, 'wupeiqi':10000, 'yuanhao':2000 } # print(max(salaries)) # print(max(salaries.values())) # t1=(1,'h',3,4,5,6) # t2=(1,'y',3) # print(t1 > t2) # t1=(10000000,'alex') # t2=(3000,'egon') # print(t1 > t2) # print(max(zip(sa...
85a1c8c00030d2666f636f8519a14b8fc39facf2
GerardoNavaDionicio/Programacion_Orientada_a_Objetos
/Nueva carpeta (2)/excepcion1.py
344
3.8125
4
try: a = int(input('Ingrese un primer numero: ')) b = int(input('Ingrese un segundo numero: ')) c = a*b except ArithmeticError as err: print('Error, no ingresaste un numero ',err) except Exception as err: print('Error, no ingresaste un numero',err) else: print('El Resultado es \t: ',c) finally: ...
113173291a37bf20cf55aee72b375d6837a87172
GerardoNavaDionicio/Programacion_Orientada_a_Objetos
/Nueva carpeta (2)/radio button.py
2,381
3.765625
4
from tkinter import* from tkinter import font from tkinter import messagebox import time class App(): def __init__(self): self.principal = Tk() self.principal.title("estaciones del Year") self.principal.geometry('700x400') fuente = font.Font(size=10,weight='bold') self.opci...
5288b56f04cff33aebc138002858494d8c9988d0
GerardoNavaDionicio/Programacion_Orientada_a_Objetos
/Nueva carpeta/GND29062021_Ejercicio2.py
784
3.96875
4
#Ejercicio_2: Implemente un programa que use hilos independientes. Un hilo imprime deberá imprimir números #pares del 1-30, y otro hilo imprime números impares del 1-30. Cree dos instancias (hilos) de cada uno y muestre la salida. #Gerardo Nava Dionicio 191801029 import threading class NumerosPares(threading.Thread): ...
f8021adde9778049a6fa98320586c936d5cfa999
GerardoNavaDionicio/Programacion_Orientada_a_Objetos
/Nueva carpeta/GND29062021_Ejercicio1.py
776
3.765625
4
# Ejercicio_1: Generados aleatoriamente números en un rango del 0-100, con un retardo de tiempo de 5 segundos, #una vez generados, se deben almacenar en una lista, ordenarlos de menor a mayo y mostrarlos. #Gerardo Nava Dionicio 191801029 import random import time import threading class Numeros_Aleatorios(threading.Thre...
a5d5de138beca92738bb8c73809fb5bfbaf4e5ba
GerardoNavaDionicio/Programacion_Orientada_a_Objetos
/Nueva carpeta (2)/primo erros.py
1,070
3.5
4
class NumPrimoError(Exception): def __init__(self,valor,mensaje = 'No es numero primo'): self.valor= valor self.mensaje=mensaje super().__init__(self.mensaje) def __str__(self): return f'{self.valor} -> {self.mensaje}' def es_primo(num): for i in range(2,num): if nu...
1ff293c7609d332e7aa3c5a9d15ac150a1fca85b
stjordanis/MLBlocks-Demos
/examples/image/simple_cnn_classifier.py
2,007
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Usage example for SimpleCnnClassifier on MNIST Dataset.""" import keras import numpy as np from sklearn.datasets import fetch_mldata from sklearn.metrics import f1_score from sklearn.model_selection import train_test_split from mlpipelines.image.simple_cnn import Simp...
e6587ea0313a775ce4d1264301f7611f013e64dd
ATHARVAMISHRA22092008/atm-simulator
/atm.py
1,349
3.96875
4
import random action=input("What action would you like to perform, w=withdraw, d=deposit, c=check, e=change currency") def withdrawal(): pin=input("What is your pin number") currency=input("Whatt currency would you like to use") amount=input("how much money would you like to withdraw") print(amoun...
5776d5f24753d80fb02ac4253eb17075607aa4db
HwiLu/learn-automate-stuff-with-python
/函数.py
1,391
3.859375
4
import random def getAnswer(answerNumber): if answerNumber == 1: return 'It is certain' elif answerNumber == 2: return 'It is wrong' answer=random.randint(1,9) result=getAnswer(answer) print(result) ''' 上述代码可能会输出None。 表示没有值,None是NoneType数据类型的唯一值 ''' '''关键字参数和print()''' ''' 有些函数有可选的关键字参数,如prin...
2c6c31a9e253db04567128cec4d56823719f6c3d
KavilanNaidoo/Assignment
/Exercise - Fridge and Lift.py
670
4.0625
4
#Kavilan Naidoo #16-09-2014 #Exercise - Fridge and Lift lift_height=float(input(" Please enter the lift height: ")) lift_width=float(input(" Please enter the lift width: ")) lift_length=float(input(" Please enter the lift length: ")) lift_space= lift_height * lift_width * lift_length fridge_height=float(inpu...
6c6312c2ca09290609d3ffab7ba295729f46d488
KavilanNaidoo/Assignment
/fahrenheit to degrees exercise.py
232
4.09375
4
#Kavilan Naidoo #12-09-2014 #Fahrenheit to degerees Exercise fahrenheit= float(input(" Please enter the temperature in fahrenheit: ")) centigrade= (fahrenheit-32)*(5/9) print("The degrees in centigrade is {0}".format(centigrade))
a2ed6ea1ca6675537cb8e82f830ef83c54213964
SteveJ21/design_patterns
/observer/observer_impl.py
1,814
3.984375
4
# Trivial example of the observer design pattern. from abc import ABCMeta, abstractmethod class AbsObserver(object): """Abstract base class for observer.""" __metaclass__ = ABCMeta @abstractmethod def update(self): pass class AbsSubject(object): """Abstract base class for subject.""" ...
de8e68e1b23ff975e8647479d292ed27760ebc2a
dgaeta/feedforward-neural-net-SDG-backprop
/src/Learner.py
2,244
4.0625
4
#### Libraries # Third-party libraries import numpy as np import FeedForward ''' @author Danny Gaeta ''' class Learner(object): @staticmethod def backprop(weights_tensor, bias_matrix, delta, activations, zs): ''' backpropagation algorithm A way to pass the blame backwards through the network to ...
9d0295a026ede3216507c2eaf28d61c974bfb526
AdamsGeeky/basics
/01 - Basics/04-intro-variable-declaration.py
594
3.515625
4
# HEAD # Python Basics - Creating variables # DESCRIPTION # Describes how variables throws error # without any assignation # # RESOURCES # # STRUCTURE # variable_target_name | equal_to_assignment_operator | target_value var = 10 # # COMPULSORY DECLARATION # A variable cannot just be declared and left. It has to ...
3a5ba0d910522c04787252d6a8afc8e8cae27952
AdamsGeeky/basics
/04 - Classes-inheritance-oops/51-classes-descriptor-magic-methods.py
2,230
4.25
4
# HEAD # Classes - Magic Methods - Building Descriptor Objects # DESCRIPTION # Describes the magic methods of classes # __get__, __set__, __delete__ # RESOURCES # # https://rszalski.github.io/magicmethods/ # Building Descriptor Objects # Descriptors are classes which, when accessed through either getting, sett...
2b4ee967304815ea875dfc6e943a298df143ef48
AdamsGeeky/basics
/04 - Classes-inheritance-oops/05-classes-getters-setters.py
784
4.34375
4
# HEAD # Classes - Getters and Setters # DESCRIPTION # Describes how to create getters and setters for attributes # RESOURCES # # Creating a custom class # Class name - GetterSetter class GetterSetter(): # An class attribute with a getter method is a Property attr = "Value" # GETTER - gets values for at...
6f45acaeec134b92f051c4b43d100eeb45533be4
AdamsGeeky/basics
/02 - Operators/10-membership-operators.py
1,363
4.59375
5
# HEAD # Membership Operators # DESCRIPTION # Describe the usage of membership operators # RESOURCES # # 'in' operator checks if an item is a part of # a sequence or iterator # 'not in' operator checks if an item is not # a part of a sequence or iterator lists = [1, 2, 3, 4, 5] dictions = {"key": "valu...
69459e61117378739f424e1e6091108bfa1fe056
AdamsGeeky/basics
/05 - Modules/01 - imports - import key/mainfile.py
899
3.875
4
# HEAD # Modules - Understanding file modules and import key in Python # DESCRIPTION # Describes usage of import statements and # using a file as a import # RESOURCES # # Describes what is a main module # https://stackoverflow.com/questions/419163/what-does-if-name-main-do # Find and load a module given its ...
57e6b0b5cbb90562a02251739653f405b8237114
AdamsGeeky/basics
/03 - Types/3.1 - InbuiltTypes-String-Integer/05-integer-intro.py
952
4.15625
4
# HEAD # DataType - Integer Introduction # DESCRIPTION # Describes what is a integer and it details # RESOURCES # # int() is a function that converts a # integer like characters or float to a integer # float() is a function that converts a # integer or float like characters or integer to a float # Work...
d1a7d8dec707ebeea8cb221b08e05dc9b58008d4
AdamsGeeky/basics
/03 - Types/3.2 - InbuiltTypes-ListsTuples/17-indentation-exceptions.py
520
3.796875
4
# HEAD # DataType - List method - Indentation Usage # Space Lexical Grammer - within list # Breaking into two lines # DESCRIPTION # Describes how indentation applies # on list and allows spaces or breaking of lines # RESOURCES # # list put into multiple lines - using spaces # python checks for bra...
45aa75e842f102cc1a8749383f81bdaf17c26416
AdamsGeeky/basics
/01 - Basics/29-functions-args-keywordargs-argslist-kwargsdict-order.py
3,209
3.984375
4
# HEAD # Python Functions - args, kwargs, *args, **kwargs # DESCRIPTION # Describes # capturing all arguments as *args (tuple), # and **kwargs (dictionary) together # capturing all arguments with default arg # definition, *args (tuple), and **kwargs # (dictionary...
b04ae7f2eea4a5301c9439e4403403599358a05f
AdamsGeeky/basics
/04 - Classes-inheritance-oops/54-classes-overwriting.py
1,525
4.375
4
# Classes # Overriding # Vehicle class Vehicle(): maneuver = "Steering" body = "Open Top" seats = 4 wheels = 4 start = 0 end = 0 def __init__(self, maneuver, body, seats, wheels): self.maneuver = maneuver self.body = body self.seats = seats self.wheels = whe...
a0f7967a83d0876a37cc74dd8c3c3dc8e1f2eaf3
AdamsGeeky/basics
/01 - Basics/33-error-handling-try-except-intro.py
1,137
4.1875
4
# HEAD # Python Error Handling - UnNamed Excepts # DESCRIPTION # Describes using of Error Handling of code in python # try...except is used for error handling # # RESOURCES # # 'try' block will be be executed by default # If an error occurs then the specific or # related 'except' block will be trigered # ...
a30f5ca5fac728d808ef78763f16ca54290765f6
AdamsGeeky/basics
/01 - Basics/11-flowcontrol-for-enumerate-loops.py
1,129
4.78125
5
# HEAD # Python FlowControl - for loop # DESCRIPTION # Describes usage of for loop in different ways # for different usages # # 'for' loop can iterate over iterable (sequence like) or sequence objects # Result provided during every loop is an index and the relative item # # RESOURCES # # # USAGE # 1 # # for i...
651a9072f2fda69580dbcb085b896ff3ac61aa06
AdamsGeeky/basics
/01 - Basics/09-flowcontrol-if-else-singleline-expressions.py
582
3.78125
4
# HEAD # Python FlowControl - Decision flow - single line if block # DESCRIPTION # Describes single line if block with print statement # Describes single line if...else block with print statement # # RESOURCES # name = 'Dracula' # SINGLE LINE FLOWCONTROL IF STATEMENT # if (condition): expression if (name == "Test")...
0640d7d0149ef291a99d472edcaf9e6d6c80ebe4
AdamsGeeky/basics
/01 - Basics/50-datatypes-type-conversion.py
2,961
4.5625
5
# HEAD # Python Basics - Conversion of Data Types # DESCRIPTION # Type Conversion # DESCRIPTION # Describes type conversion methods (inter-conversion) available in python # # RESOURCES # # These function can also be used to declare specific types # When appropriate object is used, these functions can be # use...
ee34a13657d64a8f3300fdf73e34362ad5a49206
AdamsGeeky/basics
/04 - Classes-inheritance-oops/17-classes-inheritance-setters-shallow.py
1,030
4.46875
4
# HEAD # Classes - Setters are shallow # DESCRIPTION # Describes how setting of inherited attributes and values function # RESOURCES # # Creating Parent class class Parent(): par_cent = "parent" # Parent Init method def __init__(self, val): self.par_cent = val print("Parent Instantiated ...
3e975c865b5f4b65df831aa3a6c9fccf8ced403d
AdamsGeeky/basics
/03 - Types/3.4 - OtherTypes-DataStructures/08-stack-queue-difference.py
2,076
3.546875
4
# HEAD # DataType - Other Inbuilt Data Types # from Internal/External Libraries/Modules # DESCRIPTION # Describes difference between STACK and QUEUE # RESOURCES # # Stack and Queue both are the non-primitive abstract data structures # The main differences between stack and queue are that STACK uses LIFO (la...
f5bb5dc4c9e162d036a8b713162d55aac0ffac1f
AdamsGeeky/basics
/04 - Classes-inheritance-oops/02-classes-attributes-creating-objects.py
747
4.03125
4
# HEAD # Classes Introduction - Creating Attributes and objects from classes # DESCRIPTION # Describes how to create attributes # Use classes to create objects with your attributes # RESOURCES # # Creating a custom class # Class name - AttributeDefs class AttributeDefs(): # Simple public class attribute ...
10900bafdcbf739fcc0ddfa2b5fdc75f26660f52
git-gagan/TkinterCalculator
/TkinterCalculator.py
6,313
3.65625
4
#importing required modules from tkinter import * from tkinter import messagebox #GUI interaction window = Tk() window.geometry("570x460") window.title("Calculator") window.config(bg = "black") #Adding widgets and inputs e = Entry(window, borderwidth = 10, font = ("Comic Sans MS", 30), cursor = "dot") #...
fac7b971d39bc7fa1e426c25f55cc0093a20ce1b
bulbazavriq/python-basis
/215/2.py
209
3.859375
4
# Получение названия страны по имени столицы a = input() from data import data for i in data: if i['capital'] == a: print(i['country']) break
d1269a707b91020f29b40ec725453d7143b2933c
coder2000-kmj/python-assignment
/5th(grosspay).py
420
3.953125
4
''' Write a program to prompt the user for hours and rate per hour to compute gross pay. Also to give the employee 1.5 times the hourly rate for hours worked above 40 hours To find the average of best two IA of 3 IA. ''' h=float(input("Enter the number of hours")) rate=150 #hourly rate if h<=40: print("Th...
5815ab67a2662657c9a6f59422f66dbd52977b51
subho781/MCA-python-assignment3
/assignment 3 Q10 p2.py
205
3.828125
4
#WAP to print the following patterns using loop def pypart(n): for i in range(0,n): for j in range(0, i+1): print(j+1,end=" ") print("\r") n = int(input('enter the number : ')) pypart(n)
faec669d1fe1620953f63600c923fc41cf81f2d7
dtran2108/find_dup_files
/waypoint3/size_group.py
1,047
3.875
4
from os.path import getsize from itertools import groupby def remove_empty_files(file_list): """ return a list of files path without empty files""" temp = [file_name for file_name in file_list if getsize(file_name) == 0] for _file in temp: file_list.remove(_file) return file_list ...
dd82a99bcc396b1d8d3294ba1d8ee70edb382fdf
ASHISHMISHRA0011/Astronomy-Project
/cnn_regression_ellipse.py
3,296
3.515625
4
# USAGE # python cnn_regression.py --dataset Houses-dataset/Houses\ Dataset/ # import the necessary packages from tensorflow.keras.optimizers import Adam from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt import datasets_ellipse import models_ellipse import numpy as np import argparse...
0d115bb0f1122777136e4cffa51a1fdbdfe668fd
JeremyAngCH/spyship
/spritesheet.py
947
4.03125
4
import pygame """ SpriteSheet Class ----------------- Spritesheet is an image that consists of several smaller images/sprites placing next to each other. These smaller images/sprites are usually a sequence of animation frames. This simple class creates a new sprite frame out of spritesheet. For example, if a spriteshe...
04648bdf1ff4e581c6185130cc61b970e28cfeb0
jokfletc/Informatics_I210
/Home Work/jokfletc_homework7.py
5,736
4.09375
4
#John Fletcher #Homework 7 #8.20 class BankAccount(object): #constructor set amount to equal None so function can handle if arguement is #not entered def __init__(self,amount=None): #if statement so if arguement isn't entered amount equals zero if amount == None: amount = 0 #self.amount ...
85169a51506725637a2c4381d2207b9ab62af041
ankitshah009/Python_code_writtten_by_me
/huff.py
6,445
3.578125
4
from heapq import heappush, heappop, heapify from collections import defaultdict import math def encode(symb2freq): """Huffman encode the given dict mapping symbols to weights""" heap = [[wt, [sym, ""]] for sym, wt in symb2freq.items()] heapify(heap) while len(heap) > 1: lo = heappop(h...
3f285707303ffc6cfd2c29e71f9c392df6b4fb8d
Hymanfire2018/pythonUnited
/SimpleBase/whilerandom.py
501
3.859375
4
""" 猜数字游戏 计算机出一个1~100之间的随机数由人来猜 计算机根据人猜的数字分别给出提示大一点Larger/小一点Smaller/猜对了 """ import random answer = random.randint(1, 100) counter = 0 while True: counter += 1 number = int(input('Input a guess number: ')) if number < answer: print('Larger') elif number > answer: print('Smaller') el...
1857a3882a5758add70eb8554cc923c4ff490210
sanjaybsm/udemy-webcourse-learning
/udemy-python-basics/function_example.py
237
3.828125
4
def my_func(param1="hello"): print("printing first function") def addNum(num1,num2): if(type(num1)==type(num2)==type(10)): return num1+num2 else: return "I need Integers" result = addNum(1, 2) print(result)
a6eaff50f0572d0a764660930d487a0d3dec2b21
sanjaybsm/udemy-webcourse-learning
/udemy-python-basics/lists.py
196
4.03125
4
mylist = [1, 2, 3] print(mylist) myNewList = ['a', 'b', ['c', 'd', 'e']] print(myNewList[2]) # list comprention list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] col = [row[0] for row in list] print(col)
5318c68f06a8bdbe04df90aa23b2f21e9e30dc28
jaedsonpys/Curso-DIO
/Threads-E-IPs/threads.py
474
3.5
4
from threading import Thread from time import sleep def car(vel, pilot): traject = 0 while traject <= 100: traject += vel sleep(.2) print(f'Piloto: {pilot}') print(f'Km: {traject}\n') # criando as threads: # # target: função a ser executada # args: argumentos que vão na funç...
43e04217d40fc085afd47f31f19a3c9dc5f727d7
jaedsonpys/Curso-DIO
/VerficadorDeTelefone/verficador.py
298
3.6875
4
import phonenumbers from phonenumbers import geocoder number = str(input('Digite um número de telefone (Ex: +558299887766): ')) phone_number = phonenumbers.parse(number) # Obtendo o local do número de telefone geolocation = geocoder.description_for_number(phone_number, 'pt') print(geolocation)
f96d6651e41ca733e06d7b0346137a65688cd20a
RAVURISREESAIHARIKRISHNA/Python-2.7.12-3.5.2-
/Reading_list_INTs_Exception.py
816
4.21875
4
def Assign(n): try: return(int(n)) except ValueError: # Managing Inputs Like 's' print("Illegal Entery\nRetry..") n=input() # Asking User to Re-entry Assign(n) # Calling the Same function,I correct input entered..Integer will be Returned,Else..Calling Recursively return(int(n)) #Ret...
235f34a09178932a48e5f0000b42f203dee00bf8
RAVURISREESAIHARIKRISHNA/Python-2.7.12-3.5.2-
/Resizing_Labels.py
537
3.875
4
from Tkinter import* obj=Tk() Label1 = Label(obj,text="LABEL 1",bg="black",fg="white") Label2 = Label(obj,text="LABEL 2",bg="yellow",fg="blue") Label3 = Label(obj,text="LABEL 3",bg="green",fg="red") Label4 = Label(obj,text="LABEL 4",bg="red",fg="black") BottomFrame = Frame(obj) BottomFrame.pack(side=BOTTOM...
8ce7d73538cb08371608da13c9ce35c92c77889c
RAVURISREESAIHARIKRISHNA/Python-2.7.12-3.5.2-
/BUTTON_MOUSE EVENTS.py
395
3.734375
4
from Tkinter import* def Left(event): print("Left Button") def Right(event): print("Right Button") def Middle(event): print("Middle Button") obj = Tk() Button_1 = Button(obj , text="MOUSE EVENTS" , bg= "red" , fg = "white") Button_1.bind("<Button-1>",Left) Button_1.bind("<Button-2>",Middle...
9416426ede499ee00430261914856bcffe50393b
RAVURISREESAIHARIKRISHNA/Python-2.7.12-3.5.2-
/Temp_1.py
484
3.5
4
#Build for Python 2.7.12 from tkinter import* def Left(event): print("Left Button") def Right(event): print("Right Button") def Middle(event): print("Middle Button") obj = Tk() obj.iconbitmap(r'C:\Users\HARI\AppData\Local\Programs\Python\Python35-32\DLLs\My_Icon.ico') Frame_1 = Frame(obj , w...
c4b1cbc1a24b57bb2f69fb37790c78f9d1487870
RAVURISREESAIHARIKRISHNA/Python-2.7.12-3.5.2-
/Excel to txt.py
5,349
3.578125
4
################## Excel Sheet to TXT Converting ############################## ## NOTE : .txt File Support Only UTF-8 Encoding ## They Do not Support Special Symbols Like Sigma,Pi,THeta and all other like Symblos # @Copyright "Hari Technologies" import openpyxl,sys,os,pyperclip from tkinter import* impo...
ff3c9eb4ccf2453d295b61d02059436312a802c9
RAVURISREESAIHARIKRISHNA/Python-2.7.12-3.5.2-
/MULTIPLE_INHERITANCE.py
1,757
4.0625
4
""" super() will only ever resolve a single class type for a given method, so if you're inheriting from multiple classes and want to call the method in both of them, you'll need to do it explicitly. """ class Test: def __init__(self): self.sub1=0 self.sub2=0 sefl.total=self.sub1+s...
263900d91bd5bcd29fa481b957a60df5ca0a8884
RAVURISREESAIHARIKRISHNA/Python-2.7.12-3.5.2-
/Tamper Clipboard.py
269
3.5625
4
import pyperclip,sys print("The ClipBoard Data is:") Data = pyperclip.paste() print(str(Data)) print("Do you Really Want to Tamper?::Press Enter to Tamper::Press Any Key and Enter to Exit") h = input() if(h==""): pyperclip.copy("Tampered") sys.exit(0)
7c8df801c08e1804b1674c8af110c41259477ae9
raulgiron/TeamTreeHouse-ObjectOrientedPython
/try_it_yourself.py
4,431
3.984375
4
import json import unittest from random import randint from random import sample class Die: """Roll Die class. This is a basic learning project.""" def __init__(self, sides: int = 6): self.sides = sides def roll_die(self): """This method is intended to roll the dice.""" die = rand...
b06ddef2efe873fd5974959fea60af151c733f5a
maahee8855/pythoncode
/addition.py
299
3.953125
4
print("-"*60) print("welcome to addition program".center(60)) x=int(input("enter x:")) y=int(input("enter y:")) print(f"x={x}".center(60)) print(f"y={y}".center(60)) print(f"{x}+{y}={x+y}".center(60)) print("-"*60) print("-"*60) print("-"*60) print("-"*60) print("-"*60) print("-"*60) print("-"*60)
aa4b3828292bd9589e7b924f604511337fba4ab1
srutherford2000/advent-of-code-2020
/dec 10/day10_pt1.py
450
3.8125
4
file_name=input('enter a file name') in_file=open(file_name) lines=[] for line in in_file: lines.append(int(float(line.strip()))) in_file.close() lines.sort() num_of_threes = 1 #accounts for the one at the end num_of_ones = 0 last_num = 0 for num in lines: dif = num - last_num if (dif == 3): ...
1a91c8ad479c912ebdc212e70dda865d25a3bd8c
srutherford2000/advent-of-code-2020
/dec 6/day6_pt2.py
827
3.71875
4
file_name=input('enter a file name') in_file=open(file_name) lines=[] for line in in_file: lines.append(line.strip()) in_file.close() linesTogether = [] #combine multiple lines to one input string" combine = [] for line in lines: if (line == ""): linesTogether.append(combine) combine = [] ...
2c18e3e757e2f6ea934a07bed911173c78f42587
tomaszpasternak94/posts_and_users
/duplicate_titles.py
324
3.53125
4
import titles from titles import titlesAll def duplicatesF(): duplicates=[] counter = 0 for i in titlesAll: if i in titlesAll[counter+1:]: duplicates.append(i) else: pass counter += 1 print('\nlista duplikatów:') return print(list(set(duplicates)),'\n...
64f6a48bb7208bc7004588b02585de4fd3404fd4
minthf/codewars
/sum_of_digits_digital_root.py
130
3.546875
4
def digital_root(n): result = sum(int(x) for x in str(n)) return result if len(str(result)) == 1 else digital_root(result)