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
8a4892bb57e06dc99f908e82e6ea9adc470c0bb8
Sudani-Coder/python
/Removing Vowels/index.py
279
4.375
4
## Project: 2 # Removing Vowels vowels = ("a", "e", "i", "o", "u") message = input("Enter the message: ").lower() new_message = "" for letters in message: if letters not in vowels: new_message += letters print("Message without vowels is : {} ".format(new_message))
ddac792e5b529356d19620b943ed445bd35bf271
jeancarlos96/CalculadoraBasica
/calculadoraBasica.py
1,393
3.59375
4
# -*- coding: utf-8 -*- from tkinter import * import TkMessageBox def sumar(): n1=float(txtn1.get()) en2=float(txtn2.get()) suma=n1+n2 lblresp=Label(text=suma).place(x=180, y=45) def restar(): n1=float(txtn1.get()) n2=float(txtn2.get()) rest=n1-n2 lblresp=Label(text=resta).place(x=180, y=45) def multi(): ...
5b0970960673d4204f344755bd3d1e35c708ffd3
MatheusSaS/PyCourse
/jogos/adivinhacao.py
1,616
3.921875
4
import random def jogar(): print("(*******************************") print("Bem vindo ao jogo de adiviação!!") print("(*******************************") num_secreto = random.randrange(1,101) tentativas = 0 pontos = 1000 print("Qual o gral de dificuldade?") print("(1) Facil (2) Medio (...
a8e950144ee0e073aa490325e13d899c81ddb3db
lmoshood/python201bookcode
/chapter10_re/finding_multiple_instances.py
251
3.6875
4
import re silly_string = "the cat in the hat" pattern = "the" for match in re.finditer(pattern, silly_string): s = "Found '{group}' at {begin}:{end}".format( group=match.group(), begin=match.start(), end=match.end()) print(s)
77089197928b24182560f982d74cf2b2262987a9
natp75/homework_4
/homework_4/homework_4_3.py
360
4.125
4
#Для чисел в пределах от 20 до 240 найти числа, кратные 20 или 21. # Необходимо решить задание в одну строку. #Подсказка: использовать функцию range() и генератор. result = [x for x in range(20,240) if ((x % 20==0) or (x % 21==0))] print(result)
89673a69717709bcf179066418f8957af22f091a
akjayant/Data-Structures-Algorithms
/ds_algo_practice/graph/isbipartite.py
947
3.671875
4
#https://leetcode.com/problems/is-graph-bipartite/ class Solution(object): def dfs(self,v,color,graph,visited): for i in graph[v]: if visited[i]==False: if color[v]=='red': color[i] ='black' else: color...
777be3bac5c3e2d6860c9537cb1d116d41bdf00f
akjayant/Data-Structures-Algorithms
/ds_algo_practice/trees/day 13/day13_5.py
775
4
4
#two binary trees same or not # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def inorder(self,node1,node2): if node1 is None and no...
57cc6a58b94a269a9e8565d9943cfb6c4cd3c520
nadhiyap/pro1
/sstr.py
135
4.1875
4
string=input("enter the str") substr=input("enter the sub string") if substr in string: print(substr) else: print(substr[1::])
47209bb85044ec045c011ef26c8314c3ab0e1538
kojo120/lastguru
/tt.py
2,833
3.6875
4
import csv from csv import DictReader with open('input.csv', 'r') as csv_file: csv_reader = DictReader(csv_file, delimiter=',') line_count = 0 for row in csv_reader: #print(row [line_count]) print(row) for row in csv_reader: #print(row [line_count]) print(row) ...
a1bae54c092b13fad72bfe6313e094e793b6a2fa
BenYuan1998/Do-Crises-Divide-or-Unite-COVID-19-Pandemic-and-Partisan-Polarization-in-the-US-Congress
/code/user_ids_lookup.py
1,332
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri May 28 17:15:32 2021 @author: nuoyuan """ import requests import json def get_params(usernames): # usernames is a comma-separated string of Twitter usernames. For example, usernames="Twitter,TwitterDev". return {"usernames":usernames} def create_h...
ef699a7a572cd3e6b469a20bedc40e6ce31d8963
MaximVazyulya/Lesson3
/task3_func.py
332
3.84375
4
def my_func(a,b,c): c = (a + b + c) - min(a,b,c) return c a = float((input("Введите значение a = "))) b = float((input("Введите значение b = "))) c = float((input("Введите значение c = "))) print("Сумма наибольших двух аргументов = ", my_func(a,b,c))
02459e413eb379f32c89c0b7a856cbe6159982e9
LakunleD/PythonProjects
/graphs.py
2,424
3.515625
4
verticles = [] con = [] edges = [] weights = [] myGraph = {'a': {'b': 4, 'c': 10}, 'b': {'c': 5, 'e': 12}, 'c': {'e': 6, 'd': 14}, 'd': {'e': 13}, 'e': {'f':3}, 'f': {'a': 2} } for start,d in myGraph.items(): for end, weight in d.items(): ## print ('{} -...
c0327f753e1cbd8d3bba93aa38b75a1d976e9056
jcrock7723/Most-Common-Character---Python
/Pg368_#10_mod.py
1,216
4.40625
4
# Unit 8, pg368, #10 # This function displays the character that appears the most # frequently in the sring. If several characters have the same # highest frequency, it displays the first character with that frequency def main(): count=[0]*26 letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' index = 0 fr...
cd0e62a2c747ace7fb6cd6767c483c7764a5ec32
Livane9/Uniguajira-BD
/ejercicios/ejercicioretorno3.py
487
3.6875
4
def numeroPerfectonoPerfecto(numero): numeroPerfecto="es perfecto" numeroNo="no es perfecto" suma=0 for i in range(1,numero): if numero%i==0: suma=suma+i if numero==suma: return numeroPerfecto else: return numeroNo def leerNumero(): numero=int(input("In...
34ed72c6902bd461f26f20ea10aac276bec3a750
fsym-fs/Python_AID
/month01/simple_mall/my_shopping.py
5,237
3.734375
4
# 简单商城 class Merchants_Views: pass class Merchants_Controllers: pass class Shopping_Models: def __init__(self, name, price, number, id): self.name = name self.price = price self.number = number self.id = id class Shopping_cart_Models: def __init__(...
bbbe105f5324d40b530acbc2e6de2d00c0836bc4
fsym-fs/Python_AID
/month05/day02/code/test.py
774
3.921875
4
""" 李白好饮酒, 无事街上走; 提壶去打酒, 原有酒两斗; 遇店加一倍, 遇花喝一斗。 1、酒壶刚开始酒为2斗; 2、遇到店酒的量会翻倍(*2),遇到话会喝一斗(-1); 3、总共遇到店5次,花10次。最后一次肯定是遇花; """ n = 2 # a = '花' # b = '酒' # c = '店' i = 0 lis = [] def func(a, b, c, lis): print(a, b, c) if a == 1 and b == 1 and c == 0: # b -= 1 global i i += 1 ...
e40f31d8a28ac7a3c3a90f07915363433e426304
fsym-fs/Python_AID
/month01/day05/test04.py
238
3.828125
4
""" Test04 list01 = [4,5,65,76,7,8] 输入最大值(自己写算法) """ list01 = [4,5,65,76,7,8] max_number=list01[0] for i in range(1,len(list01),1): if list01[i] >max_number: max_number = list01[i] print(max_number)
aaea8ccf6b8968ce2ff3932b1b11f8c8bde121f7
fsym-fs/Python_AID
/month01/day06_tuple_dict_set/test02_dict.py
579
3.78125
4
""" Test02_dict 1.在终端中循环录入商品的信息(名称,单价) 如果名称为空,停止录入 打印所有商品信息(一行一个) 格式为:...的价格是... 如果录入的是游戏机,则打印其价格 """ print("录入商品的名称和价格") goods = {} while True: name = input("名称:") if name == "": break else: pice = input("价格:") goods[name] = pice for key, value in goods....
dfe55e7be6b5c8f30c0bb409c1d104e519ac7947
fsym-fs/Python_AID
/common_model/iterable_tools.py
3,099
3.828125
4
""" 可迭代对象的工具 linq 微软集成查询框架 """ # 集成操作框架 class IterableHepler: """ 可迭代对象助手类 """ # 万能按条件升序排序>>>>>sorted() @staticmethod def sort_up(iterable, func): """ 按条件(func)将可迭代对象(iterable)进行升序排序 :param iterable: 需要搜索的可迭代对象 :param func:函数类型--->排序条件 "...
a67878d91a6c029118781cba16269fe45cfd9acb
fsym-fs/Python_AID
/month01/day02/demo/demo.py
981
3.703125
4
# name = input("Input Name\n") # score = [95,96] # score = {"score1":95,"score2":96} # data01 = "123" # data02 = data01 # data01 = "ddd" # print (data01) # print(data02) # ''' # varliable01 = "八戒" # varliable02 = "沙僧" # print("varliable01="+str(varliable01)+",varliable02="+str(varliable02)) # temp = varliable01 # # de...
4e6a86265569db4bfb2bc3be92db4f53679e28f3
fsym-fs/Python_AID
/剑指office/other/T1.py
1,228
3.84375
4
''' 题目描述 有 n 个学生站成一排,每个学生有一个能力值, 牛牛想从这 n 个学生中按照顺序选取 k 名学生,要求相邻两个学生的位置编号的差不超过 d, 使得这 k 个学生的能力值的乘积最大,你能返回最大的乘积吗? 输入描述: 每个输入包含 1 个测试用例。每个测试数据的第一行包含一个整数 n (1 <= n <= 50), 表示学生的个数,接下来的一行,包含 n 个整数,按顺序表示每个学生的能力值 ai(-50 <= ai <= 50)。 接下来的一行包含两个整数,k 和 d (1 <= k <= 10, 1 <= d <= 50)。 输出描述: 输出一行表示最大的乘积。 示例1 输入 3 7 4 7 2 50 输出 49 ...
8bd10c03a9d6d8ee195414b836a82c458181c546
fsym-fs/Python_AID
/month01/day15_adv/test/test04_iterator.py
812
3.640625
4
""" iterator 创建图形管理器, 记录多个图形, 迭代图形管理器,打印多个图形 """ class graphicsiterator: def __init__(self, list01): self.list01 = list01 self.index = -1 def __next__(self): self.index += 1 if self.index > len(self.list01) - 1: raise StopIteration return se...
78ed63468ebe0aa5aea8be76b0f018e07b8b0c76
fsym-fs/Python_AID
/month01/day07_function+for_for/test/test01.py
868
3.53125
4
""" test01 1.["齐天大圣","猪八戒","唐三藏"]--->key:字符,value:字符长度 2.["张无忌","赵敏","周芷若"] [101,102,103]-->{"张无忌":101..} 3.将练习二的字典的键与值颠倒 4. 骰子 1--6 骰子 1--6 骰子 1--6 将三个骰子的组合数存入列表 """ a = {'cid': 101, 'count': 1} print(a['cid']) # if 101 in a['cid'] : # print("44") # print(a[1]) try: xy...
27810d0acd68e4a3462e339567678c1ba5781078
fsym-fs/Python_AID
/month02/day08_process_multi+thread/test/test01.py
1,022
3.546875
4
""" 在不改变函数的定义与调用基础上,为其增加新功能(执行时间) """ import time from multiprocessing import Process def account_time(func): def wapper(*args, **kwargs): time01 = time.time() result = func(*args, **kwargs) time02 = time.time() - time01 print(time02) return result return wapper ...
36791b54f878fd9521ef4443871ef004d34dc29f
fsym-fs/Python_AID
/month01/day12_oop/test/test03_extend.py
1,176
3.59375
4
""" 手雷爆炸,可能伤害玩家,敌人生命,还可能伤害房子,鸭子..... 要求,增加新事物,不影响手雷类 """ class Hand_grenades: def explosion(self, thing): print("手雷爆炸啦!!!!!!!!") thing.injured() class Things: def injured(self): pass # -----------------------------------------------------------------------------------------...
a0fd1c85130ad0be293386a56c9d70bf555d5f10
fsym-fs/Python_AID
/month03/mall_project/code/test/test.py
702
3.765625
4
import time def Fibonacci(n): # write code here lis = [0, 1] if n == 0: return 0 elif n == 1: return 1 else: for i in range(2, n + 1): lis.append(lis[i - 2] + lis[i - 1]) return lis[-1] def Fibonacci2(n): # write code here lis = [0, 1] if n...
c6b177dfa29d86d77b0a981fec7cff1da6220461
fsym-fs/Python_AID
/month02/day07_process/homework/other/h4_client.py
718
3.5625
4
""" 客户端发送一个图片及图片的类别信息给服务端 """ from socket import * socket_client = socket(AF_INET, SOCK_STREAM) server_addr = ("192.168.1.6", 8444) socket_client.connect(server_addr) def send_pic(pic_kind, pic_path): socket_client.send(pic_kind.encode()) data = socket_client.recv(1024) if data.decode() == "OK": ...
d1c329671c3ec1bbe940e90b94d481f40bb4c10e
fsym-fs/Python_AID
/month01/day16_adv/test/test06_lambda.py
2,079
3.515625
4
""" 函数式编程: 封装:分 继承:隔 多态:做 """ """ 定义函数,在老婆列表中,查找颜值大于90的所有老婆 定义函数,在老婆列表中,查找存款小于10万的所有老婆 步骤: 根据需求创建函数 运用函数思想:分,隔,做 """ from common_model.iterable_tools import IterableHepler class Wife: def __init__(self, name, face_score, money, age): self.name = n...
333d78ff5e891f55a8bba9a9cdf9d343f2f44d31
fsym-fs/Python_AID
/month01/day03/test/test06.py
643
3.875
4
""" Test06 1.获取一个整数,如果是奇数则state="奇数",否则state="偶数" 2.获取一个年份,如果是闰年,day=29,否则day=28 """ # 1 number = "偶数" if int(input("输入一个整数:")) % 2 == 0 else "奇数" print(str(number)) year = int(input("输入一个年份:")) day = 29 if year % 400 == 0 or \ year % 4 == 0 and \ year % 100 != 0 else 28 print(str(day)) # 2 num...
147cdeeb5490dd61e71a43d6c04313541ee067d0
fsym-fs/Python_AID
/month02/day12_正则表达式/demo/demo01.py
3,531
3.65625
4
import re # 匹配所有数字 from typing import List, Any r = re.findall("\d+", "今天是2020年2月19日") print(r) # ['2020', '2', '19'] # 普通字符,匹配字符串中对应字符 r = re.findall("a", "abcderad") print(r) # ['a', 'a'] """ 或关系: 元字符:| 匹配 | 两侧任意的正则表达式,不能重叠 """ r = re.findall("ab|ef", "abcdefabcd") print(r) # ['ab'...
972fffde01faf002a850c057417ab1798d1731b4
fsym-fs/Python_AID
/month01/day06_tuple_dict_set/test03_dict+list.py
720
3.890625
4
""" Test03_list+dict 循环录入学生的姓名,年龄,性别,成绩 如果名称为空,停止录入 打印所有学生信息(一行一个) 格式为:...的年龄是...,性别是...,成绩是... 如果录入的是唐僧,则打印年龄 """ print("录入学生的姓名,年龄,性别,成绩") students = {} while True: name = input("姓名:") if name == "": break else: age = input("年龄:") sex = input("性别:") grad...
a25a2ac5c36d2e77acb04e23a86f80e9090d77c1
fsym-fs/Python_AID
/month02/day08_process_multi+thread/homework/cp_1/demo06.py
690
3.625
4
""" 进程池 ** 父进程结束,进程池自然销毁 执行的事件函数必须在进程池创建之前声明 如果用Windows或macos则创建进程必须在main函数中 """ from multiprocessing import Pool from time import sleep, ctime # 进程池事件 def wroker(msg): sleep(2) print(ctime(), "---", msg) def f(): print("hhhhh") # 创建进程池 pool = Pool() # 向进程池放事件 for i in...
9a401b22e56c45f738d883731dabad1b1525adb2
ceadoor/HacktoberFest-2020
/Python/tints-ColorGuess.py
322
3.96875
4
# PROGRAM-NAME : Color Guess # By Tintu # PROGRAM-CODE : import random words = ['grey','black','red','pink','blue','peach','green','white'] val=random.choice(words) x=int(len(val)) print(x) for i in range (1,6): for j in range (1,x+1): print ('_',end="") word=input("Enter a character") if(word==val): print...
7d19936ea344f55344b7e4a8e18e4efbf5e84938
ceadoor/HacktoberFest-2020
/Python/tints-GuessGame.py
447
4.28125
4
# PROGRAM-NAME : Guess Game # By Tintu # PROGRAM-CODE : import random def guess(val,x): while ((val-x)!=0): dif=val-x if(dif>0): print("Number is greater than guessed") else: print("Number is less than guessed") x=int(input("Gues another number: ")) print("You guessed right!!!") val=int(random.randra...
b3ee4e4b97ca8d31b9ca2a0a18609d41a06d7e95
ryo-s2000/practice-machine-learning
/k-regression.py
1,421
3.515625
4
from main import mglearn, np, plt, train_test_split # モデル読み込み from sklearn.neighbors import KNeighborsClassifier from sklearn.neighbors import KNeighborsRegressor # mglearn.plots.plot_knn_regression(n_neighbors=3) # plt.show() X, y = mglearn.datasets.make_wave(n_samples=40) # waveデータセットを訓練セットとテストセットに分ける X_train, X_...
ae5d2dd513db892db98123afa06f7c3fdbda462d
OverHold66/hello-world
/DataFrame11.py
232
3.65625
4
import numpy as np import pandas as pd df=pd.DataFrame(np.random.randn(10,4),columns=list('ABCD')) print(df) df1=pd.concat([df.iloc[:3],df.iloc[3:7],df.iloc[7:]]) #判断两个DataFrame中的元素是否相等 print(df==df1)
db0d2005ba798cfdcc93d17a789be124f78514ad
OverHold66/hello-world
/height.py
368
3.5
4
hat_hight_cm=25 my_height_cm=190 total_height_meters=hat_hight_cm+my_height_cm/100 print("Height in meters =",total_height_meters,"?") total_height_meters=(hat_hight_cm+my_height_cm)/100 print("Height in meters =", total_height_meters) print(min(1,2,3)) print(max(1,2,3)) print(abs(32)) print(abs(-32)) print(f...
b7338f6d85328db6119a9d54b06d624ef76ff0a1
nathruby/adventofcode_2019
/Day_2/part1.py
1,037
3.53125
4
INPUT = [1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,13,1,19,1,5,19,23,2,10,23,27,1,27,5,31,2,9,31,35,1,35,5,39,2,6,39,43,1,43,5,47,2,47,10,51,2,51,6,55,1,5,55,59,2,10,59,63,1,63,6,67,2,67,6,71,1,71,5,75,1,13,75,79,1,6,79,83,2,83,13,87,1,87,6,91,1,10,91,95,1,95,9,99,2,99,13,103,1,103,6,107,2,107,6,111,1,111,2,115,1,115,13,0,99,2...
b8b22765c3572d1c775f6d423807ff8060cf6815
AkiOhtani/ALGO
/maximum_level_of_sum_of_a_binary_tree.py
792
3.5625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import Counter from queue import deque class Solution: def maxLevelSum(self, root: TreeNode) -> int: depth = 0 max_sum ...
a56a73e128608144d5c8d74cbdc14589516eb4a9
AkiOhtani/ALGO
/cup.py
1,051
3.578125
4
from queue import deque from copy import deepcopy def copyAndAlter(origin, p, a): matrix_ = deepcopy(origin) buf = matrix_[p].pop() matrix_[a].append(buf) return matrix_ while 1: N, M = map(int, input().split()) if N == M == 0: break matrix = [] for i in range(3): ...
64b7feefea06bb59afba2ebdb4598276479eb0cc
saravananprakash1997/Ranking-and-Rewarding-Project-using-Python-intermediate-
/Intermediate_Project.py
1,878
4.21875
4
#intermediate Python Project #get the total marks of the students #Rank them and highlight the top three #Reward the top three with 1000$, 500$ and 250$ respectively import operator def student_details(): print() number_of_students=int(input("Enter the number of students :")) students_records={} for x i...
90b5fc7bfd46d784ec783b920aedad40202cc854
sroshan106/stack
/stack.py
605
4
4
class Stack: def __init__(self): self.items = [] def push(self,item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): if not self.isempty(): return self.items[-1] def isempty(self): return self.items==[] ...
57cef0c2e509e55fc9640ed2fb3de8271b6deec0
wernerweinhartner/aulas_python
/exercício_média.py
304
3.828125
4
a = float(input('Digite a nota da primeira prova: ')) b = float(input('Digite a nota da segunda prova: ')) c = float(input('Digite o peso da primeira prova: ')) d = float(input('Digite o peso da segunda prova: ')) media_ponderada_das_notas = float(((a*c) + (b*d))/(c+d)) print(media_ponderada_das_notas)
1a24c391858f50598bd83b2610aef8086cb5688b
wernerweinhartner/aulas_python
/02_nota_média.py
362
3.84375
4
#Faça um Programa que peça as 4 notas bimestrais e mostre a média. a = input('A primeira nota bimestral é: ') b = input('A segunda nota bimestral é: ') c = input('A terceira nota bimestral é:') d = input('A quarta nota bimestral é: ') media = (float(a) + float(b) + float(c) + float(d)) / 4.0 print('A media das nota...
e60166ac004c3fd2a4aa605f8bfd17356b63acdd
wernerweinhartner/aulas_python
/Dados_números_parte_2.py
872
3.96875
4
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import math >>> math.sqrt (16) 4.0 >>> math.factorial (5) 120 >>> num5 = 20 >>> mathh.factorial (num5) Traceback (most recent call last): File "<pyshell#4...
f9b926fb2066be3b0059dae5f295105b4879e241
wernerweinhartner/aulas_python
/04_L3.py
189
4.09375
4
# Faça um programa que leia 5 números e informe o maior número lista = [] for i in range(0,6): lista.append(int(input('Informe um valor: '))) #Comentário teste print(max(lista))
c4f1f9468abc1e6c761afa36d9699441858cddaf
wernerweinhartner/aulas_python
/05_peso.py
777
3.828125
4
#primeiro capturar os dados necessários. #depois fazer os devidos testes. #se colocar dois if, duas situações serao consideradas #if(começa ciclos) + elif(quantos quiser) + else # Para homens: (72.7*h) - 58 # Para mulheres: (62.1*h) - 44.7 sexo = input('Digite m para mulher ou h para homem: ') altura = float(input('Di...
6a169c8c988922a92dbca969d89f05abc7dbbe47
wernerweinhartner/aulas_python
/cores_curso.py
327
3.515625
4
#cores cores = {'red': 'vermelho', 'blue': 'azul', 'green': 'verde', 'purple': 'roxo', 'yellow': 'amarelo', 'black':'preto', 'white':'branco'} cor_ing = input('Digite uma cor em inglês: ').lower() print('A tradução dessa cor em português é:') print(cores.get(cor_ing, 'Esta cor não consta no meu dicionário'))
b214d764922658cf482f30f0f6f3593e6561f711
wernerweinhartner/aulas_python
/funções_04.1_L02.py
1,300
3.796875
4
#Repita o exercício fazendo a função retornar, além do novo valor do produto # (somando o percentual do imposto), também o valor somente do imposto custo = False while custo == False: custo = input('Insira o custo do produto: ') try: custo = float(custo) if custo > 0: custo == True...
9023b4a3a37df6b5f55699a612c4afa9d9aba806
wernerweinhartner/aulas_python
/03_L3.py
3,003
4.21875
4
#Faça um programa que leia e valide as seguintes informações: #Nome: maior que 3 caracteres; #Idade: entre 0 e 150; #Salário: maior que zero; #Sexo: 'f' ou 'm' (M=masculino, F=feminino); #Estado Civil: 's', 'c', 'v', 'd' (S=solteiro, C=casado, V=viúvo, D=divorciado). #Ao final, exiba todas as informaçẽos do usuário, d...
43778a0590473b9062b245e359ff78155fb6919f
6288128/-python-
/equation_func.py
4,776
3.75
4
class LinearTerm(): def __init__(self, term): self.term = term.strip() if self.term[:-1] == '+' or self.term[:-1] == '': self.coefficient = 1.0 elif self.term[:-1] == '-': self.coefficient = -1.0 else: self.coefficient = float(self.term[:-1]) ...
820621fd61547622d1e3208d595eeae3b2edd989
eugurlubaylar/Python_Kod_Ornekleri
/Noktalama İşaretlerini kaldırma.py
392
4.40625
4
# Program to all punctuation from the string provided by the user # define punctuation punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' # take input from the user my_str = input("Enter a string: ") # remove punctuation from the string no_punct = "" for char in my_str: if char not in punctuations: no_pun...
88171db3c76961e42eddf14a6a56abd6f753b3d4
NakonechnyiMykhail/cs50
/2_cs50_groups/cs1/lesson24/intro.py
186
3.84375
4
name = str(input('Enter your name: ')) print('Hello,', name) print("Hello,", name) print('Hello, ' + name) s = """ asdasf 23423 3333333 """ print(s) print() s2 = "sas \ www" print(s2)
5a1d4c98b51457eec249f2a229e004116291b93e
Professor83/vitaliy-exampleB101
/hw02.py
2,514
3.8125
4
__author__ = 'Ваши Николаев Виталий Григорьевич' # Задача-1: Запросите у пользователя его возраст. # Если ему есть 18 лет, выведите: "Доступ разрешен", # иначе "Извините, пользоваться данным ресурсом можно только с 18 лет" a = int(input("Введите Ваш возраст ")) if a > 18: print("Вход разрешен") elif a < 18: p...
dc02ec2600792e819448c5aa3e0947e4a1f94488
chirateep/algorithm-coursera-course1
/week3_greedy_algorithms/1_money_change/change.py
545
3.8125
4
# Uses python3 import sys def get_change(m): total_coin = 0 coin_list = [10, 5, 1] coin_index = 0 while (m > 0): value_size = coin_list[coin_index] # print(m, value_size) if (m - value_size) >= 0: m -= value_size total_coin += 1 else: ...
b9d6b6c2663867a56647bfd155014a51011dac0a
chirateep/algorithm-coursera-course1
/week2_algorithmic_warmup/1_fibonacci_number/fibonacci.py
319
3.6875
4
# Uses python3 def calc_fib(n): fib = [0 for i in range(n+1)] if (n >= 0): fib[0] = 0 if (n >= 1): fib[1] = 1 if (n <= 1): return fib[n] else: for i in range(2, n+1): fib[i] = fib[i-1] + fib[i-2] return fib[n] n = int(input()) print(calc_fib(n))
3874b5d85030d2b80f89852790ed17bd98de77b6
chirateep/algorithm-coursera-course1
/week2_algorithmic_warmup/7_last_digit_of_the_sum_of_fibonacci_numbers_again/fibonacci_partial_sum.py
1,629
3.625
4
# Uses python3 import sys def fibonacci_partial_sum_naive(from_, to): sum = 0 current = 0 next = 1 for i in range(to + 1): if i >= from_: sum += current current, next = next, current + next return sum % 10 def fibonacci_partial_sum_fast(from_, to): if to <= 1:...
c1a54c8c84db855cc1e1d2b0870de54a17b0c168
armornik/deep_learning_grock
/gradient_descent(1)/2_gradient_descent.py
5,302
3.515625
4
weight = 0.5 goal_pred = 0.8 input = 0.5 for iteration in range(20): pred = input * weight clear_error = (pred - goal_pred) # Чистая ошибка error = clear_error ** 2 direction_and_amount = clear_error * input # Масштабирование, обращение знака и остановка weight = weight - direction_and_amount ...
376fc53fe42d60685a1707ae8f875c2d92bf113c
SuperVang/example
/python/src/example/test_iteration.py
667
3.703125
4
#!/usr/bin/python3 import sys lst=[1,2,3,4] itr=iter(lst) print(itr) print(next(itr)) itr=iter(lst) for x in itr: print(x,end=' ') else: print() itr=iter(lst) while True: try: print(next(itr),end=' ') except StopIteration: print() break class MyNum: def __iter__(self)...
e6c18c91e4c445e434914e5b6abd564b0b85ac94
prithajnath/kalamari
/kalamari/tree.py
5,783
3.6875
4
from .exceptions import OverrideRootError, TreeHeightError from typing import List class Node: def __init__(self, data: str, parent: None or 'Node'=None) -> None: self.data = data # name of Node self.parent = parent # reference to parent Node object self.children = [] # list of children No...
c29641ff18518c827fe034937f746f24e5db43f1
jaimeliew1/hawcast
/hawcast/myDataFrame.py
1,046
3.546875
4
import pandas as pd import numpy as np class myDataFrame(pd.DataFrame): ''' A modified pandas dataframe that can be called. The call function filters and returns the rows which meet the conditions set by the keyword arguments in the call.''' @property def _constructor(self): return myDataF...
1faaa9939a70a2c663cb276c1d86096152571d88
dwiberg4/num_meth
/mullers.py
1,962
3.90625
4
# Root Finding Method # Open Method # Muller's Method import numpy as np # Define the main Muller's Method Function def mullers(x0,x1,x2,es,imax): itera = 0 ea = es while (ea >= es) and (itera < imax): itera += 1 # Muller's Method h0 = x1-x0 h1 = x2-x1 d0 = (f(x1)...
d70107970f6ca77f746ce051acb0473ee34d4751
inwk6312winter2019/openbookfinal-deepakkumarseku
/task1A.py
1,911
3.671875
4
import string file=open("Book1.txt") hist = dict() for line in file: line = line.split() for word in line: word = word.strip(string.punctuation+string.whitespace).lower() hist[word] = hist.get(word,0)+1 def unique_words(): print("Total number of words are %d" % sum(hist.val...
2845f42dd2a9cea4cb140a50b3d9c0627d702061
vidhur2k/MA351-Report
/perceptron.py
7,131
3.828125
4
""" This is an implementation of a simple perceptron algorithm to classify linearly seperable data. Authors: Harjas Monga and Vidhur Kumar """ # Imports from __future__ import print_function import sys from matplotlib import pyplot as plt import numpy as np import random # Returns 1 if the weighted input sum is gr...
eebe313455c96f1aec240aa0389dff5fd2db447a
red-frog/Algorithm
/sort/insert_sort.py
642
3.953125
4
# -*- coding:utf-8 -*- # 定义方法 def insert_sort(alist): # 核心部分:把整个序列看成两部分 # for j in range(): # 计算序列长度 length = len(alist) # 从无序序列中取数据 for i in range(1, length): # 把取出数据插入 for x in range(i-1, -1, -1): if alist[i] < alist[x]: # 交换数据 ...
65161b034f0738a7ecb1b15354604a5f5c66ee76
Johnelvis/ECG-NN-Classifier
/ecg-nn-classifier/preprocessing/filters.py
1,788
3.5
4
from scipy.signal import medfilt, butter, lfilter """ Low pass filters the ecg signal to remove high frequency noise like electromagnetic interference. """ def low_pass_filter(data, cutoff, order, sample_rate=360): # Nyquist frequency ny = sample_rate >> 1 cut = cutoff / ny # Calculate filter coeffici...
c2ebca5ddbeef276d793c42d9cfc8d69892734d9
coproc/PolyPieces
/src/PolyPieces.py
19,977
3.5625
4
'''piecewise polynomial functions ''' import numbers from fractions import Fraction from Polynomial import Polynomial import sys def _newVarName(usedVarNames, baseName='t'): if not baseName in usedVarNames: return baseName idx = 0 varName = '%s%d' % (baseName, idx) while varName in usedVarNames: id...
78ac7f08733f7501d3f4bdf3dfbe98c732cc25db
PatrickArthur/Python_Calculator
/python_calc.py
954
4.125
4
#Calculator in Python# import math print(" Weclome to Patrick Arthur's Calculator: V1") print(" A) Add") print(" B) Sub") print(" C) Mul") print(" D) Div") choice = raw_input("Pick your choice: ") if choice == "A": print("add numbers!") x= input("First Number: ") y= input("Second Number: ") ...
232381969063033a74cd65f4fe99b109fbcba00d
BenjaminStienlet/CompetitiveProgramming
/tweakers_devv_contest/problem2.py
305
3.8125
4
import math count = 6 fib_n1 = 0 fib_n = 1 while fib_n < 10**18: fib = fib_n + fib_n1 fib_n1 = fib_n fib_n = fib sum_fib = 0 for i in str(fib): sum_fib += int(i) if math.floor(math.sqrt(sum_fib)) ** 2 == sum_fib: print(sum_fib) count += 1 print(count)
ee93edb02aee447d6e10f7b07e5a9d95ef3f585a
BenjaminStienlet/CompetitiveProgramming
/google_code_jam/PythonGCJ2014/Round 1B/C_The_Bored_Traveling_Salesman.py
1,143
3.5
4
__author__ = 'Benjamin S.' fi = open('input.txt', 'r') fo = open('output.txt', 'w') def read_line(): return fi.readline() def write_line(line): print line fo.write(line + "\n") def add(flights, a, b): if not a in flights: flights[a] = [b] else: f = flights[a] f.append...
f0f4fc73f9879189b971a49ff68f1a5d9cbd0496
BenjaminStienlet/CompetitiveProgramming
/project_euler/Problem000-025/problem_002.py
795
4.09375
4
""" Even Fibonacci numbers ======================================================================================================================== Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, ...
f908e557d0686bafb9fa9e4783a3713fbdfb6d6e
BenjaminStienlet/CompetitiveProgramming
/project_euler/helper_functions.py
6,226
3.953125
4
import math import itertools class HelperFunctions(): def __init__(self): pass #=================================================================================================================== # BASIC CALCULATIONS #==========================================================================...
a37f0a683e4d00d12ac836fda1210cf1bf313e13
roytu/awfuljokesbot
/awfuljokes.py
4,391
3.671875
4
import string import wikipedia import re from math import floor from random import random VOWELS = "AEIOUYaeiouy" CONSONANTS = "BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz" MIN_PHENOMES_SHARED = 2 class Words(object): """ A class for retrieving nouns and the like """ def __init__(self): self.__nouns ...
0b8435823bd40e6a835799529bc9a664afd7bcff
Baussiut/Python
/Projet_Python/Projet/app.py
2,223
3.609375
4
import tkinter as tk from tkinter import filedialog root = tk.Tk() root.title("Rechercher un mot dans n'importe quel fichier") WORD = None RESULT = "Résultat trouvé à la ligne: " def upload_file(): global WORD try: myfile = filedialog.askopenfilename( title = "Chercheur de mot", ...
3b778966b64e1d828759e256848b2bb6106c83f7
freeglader/python_repo
/automate_the_boring_stuff/ch2_flow_control/yourName.py
598
3.828125
4
name = '' count = 0 while name != 'your name': print('Please type your name:\n') name = input() count += 1 if count >= 10: print('Holy frick, how are humans this stupid? It took you a whopping ' + str(count) + ' tries. I literally told you exactly what to type! You don\'t see me making mistakes like th...
9a173033eab1402ceb4ee544aa9d5b55f683d3f6
freeglader/python_repo
/automate_the_boring_stuff/ch3_functions/ch3_number_guessing_game.py
2,274
4.3125
4
#TODO: The number guessing game will look something like the following: #TODO: I am thinking of a number between 1 and 20. Take a guess. (Guess is too low, guess is too high) #? My implementation, done before checking solution in the book: import random print('Let\'s play a game. I will pick a number between 1 and ...
37e7c301f87cddf2389d7d334cff0b3fc6a83eda
freeglader/python_repo
/python_crash_course/ch3/ch3_exercises.py
970
4.0625
4
# Chapter 3 "Try it yourself" questions #*: 3-4: Guest List #TODO: Make a list of 3 people you want to invite to dinner & send them a message invitees = ['bob','tom','joe'] message = 'Hi ' + invitees[0].title() + ', wanna go get dinner?' print(message) uninvited = invitees.pop() uninvited_message = '\nUnfortunatel...
e67e71a165eb3e3898b8d039527263b7d2c98cce
MingzheHu-Duke/TrialRepo2
/tachycardia.py
1,265
3.96875
4
def data_input(): """ Get the input which simulate the OCR String Parameters: None Outputs: The ocr_string """ choice = "No" # Make sure the input is what you mean while choice == "No": print("Please input the string obtained from OCR:") ocr_string = input() print("T...
7d215d4ebde45fd672ee4c55e86a6e8f6fba0648
Vivek-Muruganantham/Project-Euler
/Python Project Euler/Python Project Euler/Functions/PrimeNumber.py
697
4.3125
4
#Returns true if the number is prime else false import math def IsPrime(number): # If number is 2, 3, 5 or 7, return IsPrime as true if(number == 2 or number == 3 or number == 5 or number == 7): return True # If number is divisible by 2,3,5 or 7, return IsPrime as False elif(number % 2 == 0 or n...
1fd3dcbd9616387b7286b378b02386ef56ea8a2d
pipo411/AT06_API_Testing
/ArielGonzales/python/session4/Practice4.py
906
4
4
import re #Verify The format of the username def usernameRegex(): username = input("Insert the Username: ") regex_username = re.compile("^[a-z0-9]+") if regex_username.fullmatch(username): return "Valid Username" else: return "Invalid Username" #Verify The format of the password def pa...
f244a0ab93a6ec7dd04f9047841f3ba0bbcd5be1
pipo411/AT06_API_Testing
/ArielGonzales/python/session2/PrimeNumer.py
281
3.828125
4
numbers = [4, 1, 4, 16, 7, 11, 12, 4, 15] for n in numbers: aux = 0 i = 1 while i <= len(numbers): if (n % i == 0): aux += 1 i += 1 if (aux > 2): print(n, "Is not a prime number") else: print(n, "Is a prime number")
0d31376a8bd4c7fbec9c225637fdfaded0f0f490
pipo411/AT06_API_Testing
/ArielGonzales/python/session2/DaysInMonth.py
699
4.15625
4
def days_in_month(month): months = { "January": 31, "February": 28, "March": 31, "April": 30, "May": 31, "June": 30, "July": 31, "August": 30, "September": 31, "October": 30, "November": 31, "December": 30 } if (...
c70951c28b32964823c3f95b6936ebd5009f76ac
pipo411/AT06_API_Testing
/ArielGonzales/python/session4/modulos/WhatAreYou.py
234
3.8125
4
def whatAreYou(age): if age < 13: return "You are a child" if 12 < age < 18: return "You are a teenager" if 17 < age < 30: return "You are a young" if age > 29: return "You are a adult"
c86e88ee54016d83cd5b25a0f1a58758d6c5e2ab
ezmiller/algorithms
/mergesort/python/mergesort.py
988
4.21875
4
# Merge sort # # How it works: # 1. Divide the unsorted list into n sublists, each containing 1 element # 2. Repeatedly merge sublists to produce new sorted sublists until there # is only 1 sublist remaining. This will be the sorted list. def merge(l, r): # print('merge():: l => {} r => {}'.format(l,r)) ...
092bf21a3a4ccb698ba3cd0af855e1be02310e61
trivial-search/Python_the_hard_way
/sunjeet_self_learning/Reading_and_copying_across_files.py
610
3.640625
4
# read contents from one file and copy to other . Files must exist in the local folder for this to work ! Make this solution better by not having that constraint ;) from sys import argv script,source_file,destination_file = argv print(f"The source file entered is {source_file}") open_file_1 = open(source_file) fi...
17035821c1600ab9bfbcea13572ab6059da6eec6
trivial-search/Python_the_hard_way
/sunjeet_self_learning/printing_list_elements_new_line.py
162
3.90625
4
#print each word of this list in a new line list_of_words = ['Black', 'holes', 'are', 'where', 'God', 'divided', 'by', 'zero'] print('\n'.join(list_of_words))
fea00303c0e6a0ac99c1612c802e81419f376d45
trivial-search/Python_the_hard_way
/Modules_code/Module 3/count_words_in_a_string.py
674
4.09375
4
#count the number of times a word appears in a string name = '''Peter Piper picked a peck of pickled peppers. A peck of pickled peppers Peter Piper picked. If Peter Piper picked a peck of pickled peppers, Where's the peck of pickled peppers Peter Piper picked? ''' #this will split the sentence based on whatever is p...
8e016dc1c5677d4d1eb43a6f86c8deef88d19a74
trivial-search/Python_the_hard_way
/sunjeet_self_learning/JSON_parsing.py
593
3.53125
4
# parse the JSON dict below and print the value of the key 'id1' # source --> https://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file #output should be -> 'blabla1' import json #import pprint json_dict = { "maps": [ { "id1": "blabla1", "iscategorical": "0" ...
e6cb91e4d00e36cad041b141b636ac1220ed4508
Randikaviraj/Knapsack-Greedy-Algo
/KnapsackGreedy.py
2,170
3.640625
4
import sys import time def shortKey(ele): return ele[1] def GreedyKnapsack(value: list,cost: list,amountOfMoneyWeHave: int): initialMoney=amountOfMoneyWeHave g=[] a=[] for i in range(len(value)): a.append((i,(value[i]/cost[i]))) a.sort(key=shortKey,reverse=True) for item in a...
643b308106a5ba265d39d65d99d619b68c0513e5
jh5537/TIL
/1_pythonStudy/04_if/day2_if_Ex2.py
445
3.984375
4
# 입력한 정수가 양수, 음수, 0인 판별하여 출력 number = int(input('정수입력 : ')) if number>0: print('양수') else: if number<0 : print('음수') else: print('0') if number>=0: if(number==0): print('0') else: print('양수') else: print('음수') if(number>0): print('양수...
b5d5196fe95c56742c82347ee6ee5d2ea41da683
jh5537/TIL
/1_pythonStudy/16_fileIO/09_file_append.py
371
3.71875
4
# append mode를 사용하여 파일 끝에 내용을 추가. f = open('test2.txt', 'a', encoding='utf-8') data = '\n\nPython Programming' f.write(data) # 변수 data에 해당하는 값을 해당 파일에 추가. - 실행할 때마다 추가됨. f.close() print("------파일 전체 읽기------") f = open('test2.txt','r', encoding='utf-8') print(f.read()) f.close()
040755041f8ef8ac2adf660fc7413d2f94e87317
jh5537/TIL
/1_pythonStudy/10_dictionary/1_김지훈_0524_dictionary.py
1,650
3.9375
4
students = [ {"name" : "홍길동", "korean" : 87, "math" : 98, "english" : 88, "science" : 95}, {"name" : "이몽룡", "korean" : 92, "math" : 98, "english" : 96, "science" : 98}, {"name" : "성춘향", "korean" : 76, "math" : 96, "english" : 94, "science" : 90}, {"name" : "변학도", "korean" : 98, "math" : 92, "english" : 96, ...
6fedcf853d3b390574e4570ef4500d2c13e15c38
jh5537/TIL
/1_pythonStudy/02_dataType/day2_data2.py
453
4.03125
4
# eval() : 입력된 문자열에 해당하는 숫자형으로 변환 ''' num1 = eval(input('number1 :')) num2 = eval(input('number2 :')) print(type(num1)) print(type(num2)) total = num1 + num2 print('합은 {}'.format(total)) ''' print(eval(input())) # = : assign # print(), format(), input(), type(), id() del # escape \n \t \\ \" \' # ...
8ac5a8a0cda70aeca988d113a369341d827189dd
jh5537/TIL
/1_pythonStudy/06_while/1_김지훈_0520.py
1,127
3.59375
4
# 실습 문제 1번 # 1) for a in range (5): print("*"*(5-a)) """모범답안 for i in range(5,0,-1) for j in range(i) print('*', end='') print() """ print("--------------------------------") # 2) for b in range (5): print(" "*(4-b),"*"*(2*b+1)," "*(4-b)) """모범답안 for i in range(5, 0, -1): for j in range(...
7c88bd99898b2da549675e0a142de1e8aac8a159
jh5537/TIL
/1_pythonStudy/14_module/1_김지훈_0526_자료구조와내장함수.py
5,016
3.765625
4
# 1번 print("---------- 1번 --------------------") # 예측 print("==예측") print("[(0, 'apple'), (1, 'banana'), (2, 'grape')]") print("정답 3번") # 결과 print("==결과") mylist = ['apple' ,'banana', 'grape'] result = list(enumerate(mylist)) print(result) # 2번 print("---------- 2번 --------------------") # 예측 print("==예측") print("{'my...
dae5076448b317c439ad0fee06416435761f1bbf
jh5537/TIL
/1_pythonStudy/08_list/day4_list4_extend.py
159
3.921875
4
# extend() : append() insert() a = [3, 6, 0, -4, 1] b = [40, 30, 20, 50] # a.append(b) # print(a) # a.insert(2, b) # print(a) a.extend(b) print(a)
e6fb49134ff864293720d5d60cb3c87c53ffecd4
AbhiAgarwal/python
/data structures/graph/graph_path.py
2,392
3.65625
4
# Personal re-write of a combination of code from the following: # http://www.python.org/doc/essays/graphs/ # https://github.com/faif/python-patterns/blob/master/graph_search.py class Graph: def __init__(self, graph): self.graph = graph def findSinglePath(self, start, end, path = []): self.sta...
a433f93e2f9c88eaaeeba2be3bbd93d540bb97e6
AbhiAgarwal/python
/sorting/quicksort.py
517
3.71875
4
array_x = [88, 12, 78, 87, 89, 95, 16, 82] def QuickSort(L, U, A): if L >= U: return if A[L] < A[U]: swap(L, U, A) P = A[U] B = L T = U print 'P =', P, 'B =', B, 'T =', T while True: swap(B, T, A) while True: B += 1 if (A[B] >= P): break while True: T -= 1 if (A[T] <= P): break if B >= T: ...
a2f6154d2fbd89e94347a4a693e9f4624c43e1e0
AbhiAgarwal/python
/voice/say.py
2,336
3.921875
4
import sys, os # gets all the voices possible for the current user def getVoices(printOrNot): # get the output from the command a = os.popen("say -v ?").read() voices = a.split('\n') voices = filter(None, voices) returnVoices = [] # go through each voice for s in voices: # get det...
1661fbbe92d8ce3ef87070abdee3005f852081ed
adeelnasimsyed/Interview-Prep
/longestPalindrome.py
733
3.84375
4
def longestPalindrome(word): length = len(word) max_length = 1 start = 0 for i in range(1, length): left = i - 1 right = i # even length words while(left >= 0 and right < length and word[left] == word[right]): if(right - left + 1 > max_length): start = left max_len...