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
a1dc70b63b0442c3793ce5cfbf7f7b0aebd9c2b9
cfkinzer/CS-1110
/roman.py
879
3.6875
4
num_map = [(1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'), (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'), (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I')] # establishes a list of integers and corresponding numerals roman = '' # establishes the string that will be printed as the roman numeral of the...
0db7edba50ace2583727abbd2288a932499b41e8
doubleBemol/python-scripts
/cli_scripts/PriceTaxHelper.py
2,410
4.0625
4
class PriceTaxHelper: """Simple class that can add or substract TAX to prices. How to use: Import it to your script by using: from PriceTaxHelper import * (assuming the file is in the same directory), Then just instantiate an object: tax = PriceTaxHelper() And use tax to performe your calcu...
d1487a4888790ec0cc265e4c536a91077dd642fa
helgemod/StrideDimensions
/StrideDimensions/StrideDimensions.py
13,049
4.4375
4
#!/usr/bin/env python """ # StrideDimension is an implementation of the ideas # StrideDimension is based on the ideas in Computerphile video # "Multi-Dimensional Data (as used in Tensors) # https://www.youtube.com/watch?v=DfK83xEtJ_k # # The main thing is to find data/loop through multidimensional data # that is repre...
6109c625b06f1ecad1b265e673828415d188020b
DroneAutonomy/Miniproject
/helloworld.py
1,337
3.640625
4
import tensorflow as tf import keras as keras import matplotlib.pyplot as plt import numpy as np mnist = tf.keras.datasets.mnist #images of hand-written images 0-9 (x_train, y_train), (x_test, y_test) = mnist.load_data() """Normalize data:""" x_train = tf.keras.utils.normalize(x_train, axis=1) x_test = tf.keras.util...
b2e3732e10bec6816bb6f2447e1f9d2ff11fea9d
Yinghui-HE/Traffic-Flow
/TrafficLight.py
1,664
3.8125
4
# TrafficLight class. class TrafficLight(object): def __init__(self, name, green_light_time_len, start_green_time_in_cycle=0, is_green=False, red_light_time_len=0): self.name = name self.green_light_time_len = green_light_time_len # unit: second self.start_green_time_in_cycle = start_green_t...
9e02101352e4c6fd59bf7063f48d5cd36729176d
jaspajjr/synthetic-ecommerce-dataset
/src/customer.py
1,117
3.90625
4
import random def calculate_customer_column(df, retention_rate): ''' Given a dataframe create a new column of customer ID numbers. ''' customers = set() customer_list = [] for num, visit in enumerate(df.index): if num == 0: new_id = create_new_customer_id() cust...
a7d9f16118477e7ace274d2b0a53bd0f76126afd
JanPschwietzer/adventofcode2020
/day_9.py
1,872
3.734375
4
with open("list", "r") as file: text = file.read().split("\n") global_counter = 0 global_sum = 0 # Star 1: # This function checks if the actual line can be sumed up with 2 numbers in the range of 25 lines before the line # def star1(text): loop = True counter = 25 i = 0 g = 0 while loop: ...
605d74d0ff0c22eeb960d116c3d79dbfd7c02a1f
SpirinEgor/HSE.unix_python
/python/homework_1/nl.py
640
3.71875
4
#!/usr/bin/env python3 import sys from os.path import exists from typing import TextIO def numerate_lines(source: TextIO): for i, line in enumerate(source): print("{:>6} {}".format(i + 1, line[:-1])) def main(): if len(sys.argv) == 1: numerate_lines(sys.stdin) elif len(sys.argv) == 2: ...
75aec96e5a40d714c0b22db7dd2a8790536fea7d
SpirinEgor/HSE.unix_python
/python/homework_1/profiler.py
934
3.5
4
#!/usr/bin/env python3 import time from typing import Callable def profiler(function: Callable) -> Callable: def wrapper(*args, **kwargs): if not hasattr(wrapper, "__calls"): setattr(wrapper, "__calls", 0) start_time = time.time() result = function(*args, **kwargs) ...
2193fdf2696e67560c1db26666798f453125acaf
KiaFathi/algoJS
/euler/problem2.py
624
3.921875
4
''' 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, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. '...
c7bc61a089584773d43f557ff3dc3575e580ba38
TamiTamik/python6
/dasgal9.py
394
3.796875
4
# Тоон дарааллын хамгийн их болон багын байрыг соль. numbers = [int (x) for x in (input().split())] min_element = min(numbers) min_element_index = numbers.index(min_element) max_element = max(numbers) max_element_index = numbers.index(max_element) numbers[max_element_index] = min_element numbers[min_element_inde...
67191405cab18e264b2ac6d085093befe014bb11
TamiTamik/python6
/app.py
102
3.578125
4
nums = [int(x) for x in input().split()] print(nums) txt = "12 23 23 12 1 2 3" print(txt.split())
ee90d861a5b3040bbcf52364b36d26a1fc58e217
deepakprasad119/py_repo
/IntrvPrograms/perfect_team.py
1,081
3.6875
4
#skills = "pcmzpzpmc" # print("Enter the list of students skills ") # skill = input() def perfectTeam(skills): ar = sorted(skills) #ar_set = sorted(list(set(ar))) ar_set = ('b', 'c', 'm', 'p', 'z') # print(ar_set) skill_dict = dict.fromkeys(ar) # print(skill_dict) #b, c, m, p, z = 0, ...
577f232538a46bdd8a22af1a9227d75f1aae0147
hiro-o918/openapi-python-client
/openapi_python_client/utils.py
464
3.65625
4
import re import stringcase def snake_case(value: str) -> str: value = re.sub(r"([A-Z]{2,})([A-Z][a-z]|[ -_]|$)", lambda m: m.group(1).title() + m.group(2), value.strip()) value = re.sub(r"(^|[ _-])([A-Z])", lambda m: m.group(1) + m.group(2).lower(), value) return stringcase.snakecase(value) def pascal...
2b94309c12347153c99577af8f6064046fcc38d8
leikang123/python-code
/day13.py
391
3.671875
4
#练习题 import matplotlib.pyplot as l x_values =list(range(1,10) y_values = [x**3 for x in x_values] l.scatter(x_values,y_values,s=40) squers=[1,8,9,64,125,216] """线条加粗""" l.plot(squers,linewidth=5) """图标显示横坐标和纵坐标""" l.title("my is num",fontsize=13) l.xlabel("time",fontsize=13) l.ylabel("value",fontsize=13) l.plot(squers...
3957b50146e927e27fb014345ebcfcd15972a288
leikang123/python-code
/day9.py
950
4.21875
4
""" #汽车租 car = input("what is it car ?") print("Let mw see if I can find you a Subaru :"+' '+car) print("\n") men = int(input("how much have pople meat,please?")) print(men) if men > 8 : print("Not") else : print("Yes") print("\n") number = int(input("please input number :")) print(number) if number % 10 == 0...
e96deebf5c52ab7eda648a973f5871cc21f50d7d
leikang123/python-code
/Algorithm/Tree.py
1,417
4.21875
4
"""d定义二叉树""" #树的节点 class Node(): #节点的属性,值,左节点,右节点 def __init__(self,value,left=None,right=None): self.value = value self.left= left self.right = right #二叉树 class BTree(): #根节点 _root = None #跟节点属性 def __init__(self,root): self._root = root # 定义添加方法,node...
977c2eb274dabd0045268e2adb67c040810b48f8
leikang123/python-code
/day-11.py
1,688
3.515625
4
def greet_user(): print("leikang") greet_user() print("\n") #定义一个函数带参数行参数 def greet_user2(username): print("hello"+' '+username.title()) # 参数实参数,赋值给username greet_user2('leikang') greet_user2('lk') # print("\n") def display_message(): print("charet learn") display_message() def books(title='ve'): prin...
fbc74817b7ce4c540a0a71b8c88c1130dbbdfccf
anfieldlove/Decision-Tree
/code/decision_tree.py
12,092
4.3125
4
import numpy as np class Tree(): def __init__(self, value=None, attribute_name="root", attribute_index=None, branches=None): """ This class implements a tree structure with multiple branches at each node. If self.branches is an empty list, this is a leaf node and what is contained in ...
1dd61c61efb4f009935dd3eac4941beb97231a08
Adam-Schlichtmann/FlaskRQ
/venv/bin/helpers.py
1,869
3.765625
4
import random import math def cocktailSort(items): comparisons = 0 swaps = 0 top = len(items) bottom = 0 for j in range(0, len(items)): swapped = False for x in range(bottom, top-1): comparisons += 1 if items[x] > items[x+1]: swaps += 1 ...
4fd447a0ed8a9639649c6925abc664f36f97d046
Chenhuaqi6/python_base
/day21/code/with.py
1,004
3.515625
4
# try: # fr = open("myfile.txt","rt") # with open("myfile.txt","rt") as fr: # s = fr.readline() # print("第一行的长度是:",len(s)) # int((input("请输入整数"))) # except OSError: # print("打开文件失败") # except ValueError: # print('输入错误') # with 打开之后不用输入关闭 # 3. 写程序,实现复制文件功能 # 要求: # 1) 要考虑关...
21d3011171e2ed8a63761bfa8fa364c6d454892a
Chenhuaqi6/python_base
/day04/code/if_elif.py
837
4.03125
4
#输入一个数字,用程序来判断这个数是正数 #是负数还是0 # s = float(input("请输入一个数字")) # if s < 0: # print(s, "是负数") # elif s > 0: # print(s,"是正数") # elif s == 0: #也可 else 减少一个判断 # print(s,"是零") # s = int(input("请输入一个季度(1~4): ")) # if s == 1: # print("春季有1,2,3月份") # elif s == 2: # print("夏季有4,5,6月份") # elif s == 3: # ...
2e7a1b3a901e44674f3d721611f4a837f7c8fc58
Chenhuaqi6/python_base
/day08/10.12exercise.py
1,987
4.03125
4
##练习 # 写一个程序,让用户分俩次输入一个人的信息: #   信息包含: 姓名 和电话号码 # 让用户输入多个人的信息,当输入姓名为空时,结束输入 # 把用户输入的数据存于字典中 #  姓名作为键,电话号码作用值 # 最后打印存储数据的字典 # 如: # 请输入姓名:小张 # 请输入电话: # 请输入姓名: # 请输入电话 # 请输入姓名:《回车》 # 打印{“小张”:13855555,”小李“:4564646} # a = {} # while True: # name = input("请输入姓名: ") # if name == "": # break # phone = int(i...
8354919a6664f6e920d679c9dd7506716f37002d
Chenhuaqi6/python_base
/day18/code/init_method.py
2,344
3.875
4
#init_method.py #此示例示意初始化方法的定义方法及用法 # class car: # def __init__(self,n,a,b): # self.name = n #名字 # self.color = a #颜色 # self.brand = b #型号 # def run(self,speed): # print(self.color,"的",self.name,self.brand,"正在以",speed,"速度行驶") # s1 = car("宝马","白色","x5") # s2 = car("雷克萨斯","...
05abdb8ec024837c0a0b11a262ff5078eba8fe12
Chenhuaqi6/python_base
/day07/10.11exercise/for.while.py
8,408
3.640625
4
##for while练习 # n = int(input("请输入一个正整数: ")) # for i in range(1,n+1): # print("*"*i,end=" ") # print() # n = int(input("请输入一个数: ")) # for i in range(1,n+1): # k = n -i # print(" "*(n-i)+"*"*i) # s = input("请输入用户名: ") # m = int(input("请输入密码: ")) # if s == "seven" and m == 123: # print("登录成功") # ...
95464d9aa7dc2c1e0d308f22e973a8b8da885642
Chenhuaqi6/python_base
/day18/code/instance_attribute.py
591
3.96875
4
#此示例示意实例属性的创建及使用 class Dog: def eat(self,food): print(self.color,"的",self.kinds,"正在吃",food) #在吃的过程中添加一个last_food属性用来记录此次吃的是什么 self.last_food = food def show_info(self): print(self.color,"的",self.kinds,"上次吃的是",self.last_food) dog1=Dog() dog1.color = "黄色" dog1.kinds = "京巴"...
1091b2b790a73532c8ad895225e789d61b5588df
Chenhuaqi6/python_base
/day04/code/intput1.py
1,148
3.6875
4
#输入 # s = input("请输入你要去的城市: ") # print("你要去的城市是: ", s) # print(1, 2, 3, 4,sep="") # print(1,2,3,4,end="\n\n\n") # print(1,2,3,4,) # x = int(input("请输入一个整数: ")) # y = int(input("再输入一个整数: ")) # z = x + y # i = x*y # o = x**y # print("和为:%d,乘积:%d,次方:%d" % (z,i,o)) # h = int(input("输入小时: ")) # m = int(input("输入分钟: ")) ...
170c4992e30d3d66ccd1cefbc934b8e1f1674422
Chenhuaqi6/python_base
/day07/10.11exercise/break.py
185
3.640625
4
#break.py i = 1 while i <6: print("开始时i=", i) if i == 3: break print("结束时i=", i) i += 1 else: print("else执行") print("程序结束")
b74bf59523b140433df9a1f2546419921fb147ea
Chenhuaqi6/python_base
/day10/10.16练习老师答案.py
528
3.53125
4
# def get_chinese_char_count(s): # count = 0 # for i in s: # if 0x4E00 < ord(i) < 0x9FA45: # count += 1 # return count # s = input("请输入中文英文混合的字符串: ") # print("您输入的中文个数是: ", get_chinese_char_count(s)) def isprime(x): if x < 2: return False #此处x一定大于等于2 for i in range(...
a3a74b1c07b5d2799728f690675e5c069add601d
Chenhuaqi6/python_base
/day16/code/myzip.py
484
3.8125
4
#此示例示意当zip 有俩个参数时,实现自定义的myzip函数 def myzip(iter1,iter2): #先得到俩个可迭代对象的迭代器 it1 = iter(iter1) it2 = iter(iter2) while 1: try: x = next(it1) y = next(it2) yield (x,y) except StopIteration: return numbers = [10086, 10000, 10010, 95588] names =...
a551a3cec36b47394e2e0e0934f98a2b2694532e
Chenhuaqi6/python_base
/day04/code/if嵌套.py
325
3.625
4
#if _embed.py mouth = int(input("请输入月份(1-12): ")) if 1 <= mouth <= 12: print("输入正确") if mouth <=3: print("春季") elif mouth <= 6: print("夏季") elif mouth <= 9: print("秋季") else: print("冬季") else: print("您的输入有误!!!")
f194802914a355a6ee0e6afa8f1e7d477d2dd00d
Chenhuaqi6/python_base
/day20/homework.py
1,982
3.671875
4
# class myrange: # def __init__(self,start,stop = None,step = 1): # if stop is None: # stop = start # start = 0 # self.start = start # self.stop = stop # self.step = step # def __iter__(self): # return MyrangeIterator(self.start,self.stop,self...
a15a1b378d3a19ff79ccae77302d8748bc66373c
Cardanont/PythonStuff001
/fileoperation.py
280
3.6875
4
def ReadFile(): f = open('../../files/myfile.txt', 'r') for line in f: print(line, end ='') f.close() def WriteFile(): f = open('../../files/myfile.txt', 'a') f.write('\nThis line will be appended.') f.write('\nPython is Fun!') f.close()
a99db93a4699cba8ff4b3621b0e10516188cfa19
mohyour/accion
/regex/regex.py
989
3.765625
4
# In the code cell, assign to the variable regex a regular expression that's four characters long and matches every string in the list strings. strings = ["data science", "big data", "metadata"] regex = "data" # we use the special character "." to indicate that any character can be put in its place. strings = ["bat",...
c6545fd5a1ec44282b5c5880076880446c587c14
Designerspr/NeNe
/NeNe/Loss.py
2,447
3.78125
4
'''providing 2 useful loss function: CEL(cross-entropy error) MSE(mean squared error) for different uses in regression and classification. ''' import numpy as np class CEL(object): '''cross-entropy error should be used only in classification problems. Or it may cause errors when calculating log(). ...
698afb436345c9ceab3bbf62f776de7f12706695
ajila123/security-surveillance
/numpymenu.py
3,962
3.875
4
import numpy as np def admatrix(): n=int(input("enter the no. of rows:")) m=int(input("enter the no. of columns:")) x=[] for i in range(n): y=[] for j in range(m): z=int(input("enter the value of first matrix:")) y.append(z) x.append(y) prin...
2e57d87c04fcdd82734a5a0c4de8bb2f43bdd814
hgy9709/p2_20161118
/w5Main8.py
327
4.15625
4
height=input ("input user height (M): ") weight=input ("input user weight (kg): ") print "%.1f" %height, "%.1f" %weight BMI=weight/(height*height) print "%.1f" %BMI if BMI<=18.5: res= "Low weight" elif 18.5<BMI<23: res= "Nomal weight" elif 23<=BMI<25: res= "Over weight" else: res= "Very Over weight" pri...
c709834bd5102a31e8b472eb857dfbdaa42be985
hgy9709/p2_20161118
/W7Main2.py
920
3.6875
4
import turtle wn=turtle.Screen() t1=turtle.Turtle() mytracks=list() mytracks.append(t1.pos()) t1.speed(1) t1.penup() t1.goto(-400,300) t1.pendown() t1.pencolor("Red") t1.right(90) t1.fd(400) mytracks.append(t1.pos()) t1.backward(150) mytracks.append(t1.pos()) t1.left(90) t1.fd(300) mytracks.append(t1.pos()) ...
0e76403eb77e74078d40d8e56595a6039afffee0
bufferjjh/Line-of-best-fit-calc
/LOBF.py
4,114
3.515625
4
import math i = input("Enter number of data points: ") dataPoints = [] for x in range(int(i)): i = input("enter data point: ") if("," in i): dataPoints.append(i) else: print("Error") break dataPoints = [ j.split(",") for j in dataPoints ] dataPoints = [[float(u) for u in...
cfc1d5d0f291a3f54bca222cc0bfff1aa32ac095
karolciba/playground
/projecteuler/problem_2_fib.py
924
3.625
4
cache = {} def cache_fib(n): if n == 0: return 0 if n == 1: return 1; if n in cache: return cache[n] f = cache_fib(n-1) + cache_fib(n-2) cache[n] = f return f def plain_fib(n): if n == 0: return 0 if n == 1: return 1; f = plain_fib(n-1) + pla...
d15af301a2e1120f31cd25fc850e002c76995603
karolciba/playground
/parsing/regex.py
3,120
3.515625
4
"""Regular expression compilater allowing smallest functional subset of expressions, i.e.: [-]+(0|[1-9][0-9]*) """ import automata from enum import Enum def crange(fro, to): """Character range (in ASCII) starting "fro" ending in "to" """ return [chr(c) for c in xrange(ord(fro),ord(to)+1)] # EXPR ::=...
645a2330360db40d5cd7a001acbd002346b5447f
DavidJaimesDesign/MIT-IntroCS
/1-lecture/ps1c.py
1,175
3.90625
4
annual_salary = input("Your yearly salary: ") total_cost = 1000000.0 portion_down_payment = total_cost/4.0 epsilon = 100 high = 1.0 low = 0 num_steps = 0 guess = (high + low)/2 def amountSaved(guess, salary): annual_salary = salary portion_saved = guess semi_annual_rate = 0.07 months_to_save = 36 ...
31c88bb2ec80a05a2be8f8d3acbc05e3b570b34a
september06/campus-learn-next.py
/unit 1/questions 1.3.3list comprehension.py
169
3.890625
4
import functools def is_funny(string): return (lambda list : not(True in list)) ([ (x!= 'h' and x != 'a') for x in list(string)]) print(is_funny("hahahahahaha"))
e60a6e408ae38400ff9a6a080b12af2adac7f644
ivklisurova/SoftUni_Python_OOP
/testing/groups_2.py
2,422
3.8125
4
class Person: def __init__(self, name: str, surname: str): self.name = name self.surname = surname def __add__(self, other): return Person(self.name, other.surname) def __str__(self): return f'{self.name} {self.surname}' class Group: def __init__(self, name: str, peop...
bd4f4255c2705f5796875094d23f2206725be5a4
CDinuwan/Python-Beginner-to-Advanced
/function.py
252
3.9375
4
def Increment(number, by): result = 3 * 2 return result print(Increment(2, 3)) # keyword argument print(Increment(3, by=3)) # can add default value def fun(number: int, by: int = 1) -> int: return (number, number + by) print(fun(2))
a8711e99bd3d0c202fe5ddf1dbfca77d7d930dbb
rohitkv77-g/Assignments
/IR/assig2.py
1,588
3.546875
4
import math def trans(X, Y): #initial matrix final edit result = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] for i in range(len(X)): for j in range(len(Y[0])): for k in range(len(Y)): result[i][j] += X[i][k] * Y[k][j] return result def new_pointt(X, Y): result = [0, 0, ...
645d7799a10b5442b6fdeb861fce4727e72215d8
rachelkelly/gitx
/whatever.py
152
3.546875
4
for i in range(6): print "Git is fun until things go wrong. Horribly, horribly wrong." if i%2 == 0: print "cool beans" else: print "hot rice"
3745b713df49cc15479c0cc2cef30ea36e5e3c61
Vincent-Weng/ECE656_Project
/pythonAnalysis/starAnalysisPlot.py
4,368
3.921875
4
import project_funclib import os import matplotlib.pyplot as plt from pprint import pprint from collections import Counter def countWords(textFile, numReviews): """Takes in a text file and returns a Counter object which contains each word and the number of times it appears in the reviews""" word_counts =...
24f7d21c0be0c90ac706b58cbbe0f07fcfab71eb
MClaireaux/CrossTheRoad
/main.py
1,295
3.515625
4
from turtle import Screen import time from player import Player from car import CarManager from random import randint from scoreboard import ScoreBoard, GameOver, FinishLine screen = Screen() screen.setup(height=int(600), width=int(600)) screen.title("Cross the Road") screen.tracer(0) screen.colormode(255) ...
317963ac96ac0dfe54d799cdd2a4d79917efbf1d
saudx98/saud
/rock.paper.scissors.py
1,110
3.78125
4
import random def rps(): computer_choice = random.randint["rock, paper, scissors"] if computer_choice == ("rock"): computer_choice_rock() elif computer_choice == ("paper"): computer_choice_paper() else: computer_choice_scissors() def computer_choice_rock(): user_choice = inpu...
22c4dd6626a502735fb2d075db7e762bedb1523d
sherld/LeetCodeForPython
/Solutions/SetMatrixZeroes.py
986
3.609375
4
class Solution: def setZeroes(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ rowLen = len(matrix) columnLen = len(matrix[0]) # 这里可以借用第一行和第一列作为存放标志位,额外只需要两个参数 rowRecord = [0] * ...
6f16901a7d7e0fb56f993ec81a4f2ec9ab3457a7
sherld/LeetCodeForPython
/Solutions/LargestNumber.py
329
3.5
4
class LargerNumKey(str): def __lt__(x, y): return x+y > y+x class Solution: def largestNumber(self, nums): largest_num = ''.join(sorted(map(str, nums), key=LargerNumKey)) return '0' if largest_num[0] == '0' else largest_num if __name__ == "__main__": Solution().largestNumbe...
fdfa32a084d3d6920d5c561ef7b04134b39afd06
sherld/LeetCodeForPython
/Solutions/RemoveDuplicatesfromSortedListII.py
1,026
3.640625
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def deleteDuplicates(self, head): """ :type head: ListNode :rtype: ListNode """ dummyHead = ListNode(0) dummyHead.next = head...
0c19f61501b07077be02928600456137d1253e40
sherld/LeetCodeForPython
/Solutions/WordSearch.py
2,960
3.625
4
class Solution: def exist(self, board, word): """ :type board: List[List[str]] :type word: str :rtype: bool """ flag = [[False for i in range(len(board[0]))] for j in range(len(board))] for i in range(len(board)): for j in range(len(board[0])): ...
54a7c57864f335109d1c86d2825c5b038e31d926
sherld/LeetCodeForPython
/Solutions/Pascal'sTriangle.py
550
3.5
4
class Solution(object): def generate(self, numRows): """ :type numRows: int :rtype: List[List[int]] """ numList = [1] ret = [] for i in range(numRows): ret.append(list(numList)) numList.append(0) numList.insert(0, 0) ...
b771a17603b164c0b3f3c4135ccfc99a3091b4cd
sherld/LeetCodeForPython
/Solutions/CombinationSumII.py
2,217
3.6875
4
class Solution: def combinationSum2Mine(self, candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ ret = set() stack = [] candidates.sort() self.findCombination(ret, candidates, stack, target, 0) ...
40d47cf762708327b527cf1f48187c6f06e66edc
sherld/LeetCodeForPython
/Solutions/ValidSudoku.py
1,421
3.734375
4
class Solution: def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ length = len(board) container = set() # validation check for row for i in range(length): container.clear() for j in range(length)...
5f65249c6d16df488590a13245fe4b9b22839ddd
sherld/LeetCodeForPython
/Solutions/TwoSum.py
472
3.65625
4
class Solution(object): def twoSum(nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ indexMap = {} for index, item in enumerate(nums): if item in indexMap: return [indexMap[item], index] in...
25c6fc85fc1a543935a3e11bfa4073e357701852
FajneFarita/D05
/HW05_ex09_01.py
721
3.96875
4
#!/usr/bin/env python3 # HW05_ex09_01.py # Write a program that reads words.txt and prints only the # words with more than 20 characters (not counting whitespace). ############################################################################## # Imports import os # Body def print_long_words(filename): ...
9684d9c1831d171ee355ef19756ede4b5be139bd
auribe83/curso_python
/operador_IN.py
497
3.84375
4
#Operador IN print("Asignaturas Optativas ano 2019") print() print(" Asignaturas Optativas: Informatica Grafica - Pruebas de Software - Usabilidad y accesibilidad") asignatura=input("Escribe la asignatura escogida: ") #opcion=input("Escribe la asignatura escogida: ") #asignatura=opcion.lower() if asignatura in ("Inf...
e202360fd4d50cc5aacba09ec5ecf0fa085ac10c
auribe83/curso_python
/bucle_for_IV.py
384
3.921875
4
#Ejemplo de for con cadena que comprueba cualquier email que se introduzca por teclado contador=0 miEmail=input("Introduce tu direccion de Email: ") #for i in "argenis429@gmail.com": for i in miEmail: if(i=="@" or i=="."): contador=contador + 1 if contador==2: #if email: # otra forma de evaluar el if, asumiendo q...
beffd1bf31d92894793cec43474a41c662fd1100
auribe83/curso_python
/generadores_II.py
463
3.71875
4
# cuando se coloca una * en los parametros se le indica que recibira un numero #indetermiando de parametros y los recibe en forma de tupla def devuelve_ciudades(*ciudades): for elemento in ciudades: #for subelemento in elemento: yield from elemento #se crea el objeto generador print(next(ciudades_dev...
7b3626b2f56c8ca9fec8b7c058ad175a7f9d0afc
C109156214/pythontest
/11.py
590
3.5625
4
a=input("請輸入月及日為:") b=int(a.split(" ")[0]) c=int(a.split(" ")[1]) list1=[[1,21,"Aquarius","Capricorn"],[2,19,"Pisces","Aquarius"],[3,21,"Aries","Pisces"],[4,21,"Taurus","Aries"],[5,22,"Gemini","Taurus"],[6,22,"Cancer","Gemini"],[7,23,"Leo","Cancer"],[8,24,"Virgo","Leo"],[9,24,"Libra","Virgo"],[10,24,"Scorpio","Libra...
1d3d53629627a9f137ae63793031ab8a1641b49e
chunin1103/nguyentuananh-c4e22
/Fundamentals/session3/homework/turtle_2.py
316
3.96875
4
from turtle import * shape("square") x = ["red", "blue", "brown", "yellow", "grey"] for i in range(5): color(x[0 + i]) begin_fill() forward(100) for i in range(2): # drawing rectangle right(90) forward(180) right(90) forward(100) end_fill() mainloop()
7d16a8117e50750c2c4f9606aba2ab6612cd3b09
chunin1103/nguyentuananh-c4e22
/Fundamentals/session3/homework/crud_1.py
2,589
4.125
4
items = ["T-shirt", "Sweater"] loop_counter = 0 while True: if loop_counter == 0: n = str(input("Welcome to our shop, what do you want? \n Please enter C, R, U, D or exit: ")) loop_counter += 1 else: n = str(input("What else do you want? \n Please enter C, R, U, D or exit: ")) ...
215cb0a3d2ce7e7ad90934b820d6895735b08447
chunin1103/nguyentuananh-c4e22
/Weather Forecast/datew.py
191
3.75
4
import datetime now = datetime.datetime.now() print ("Current year: %d" % now.year) print ("Current month: %d" % now.month) print ("Current day: %d" % now.day) print(now)
c1eee72f9b01bf8e00700e66fb1d2ef43d15e4c0
chunin1103/nguyentuananh-c4e22
/Labs/lab1/homework/timer_test.py
184
4.0625
4
# time = input("what time? ") # pair = time.split(":") # hour, minute = pair time = "7:30" pair = time.split(":") hour, minute = pair print(type(hour)) print(hour == 7) print(minute)
5c041d23e63881180c219651e270f5de661c32ed
chunin1103/nguyentuananh-c4e22
/Labs/lab3/calc.py
225
3.8125
4
def add(x, y): r = x + y print(r) return r a = 5 b = 10 t = add(a , b) print(t) def substract(z, c): l = z - c print(l) z += 1 return z, l + 1 z = 6 c = 5 t = substract(z, c) print(t) print(z)
5a551147e9cd9e917addfe7c7ab3e71ce66b11fe
chunin1103/nguyentuananh-c4e22
/Fundamentals/session2/homework/serious/2_factorial.py
121
3.875
4
n = int(input("Enter a number out of curiousity")) m = 1 for i in range(1, n + 1, 1): m *= i print(i) print(m)
6c2a99b5130a477bc561d318d0752b3317691778
DinoL/TableTennis
/Tennis.py
1,647
3.8125
4
import Queue import random import collections class Player: """A class representing table tennis player""" def __init__(self, name, skill = None): if skill is None: skill = random.random() self.skill = skill self.name = name self.gamesCount = 0 self.streak = ...
118cef461810e410d53e55a86e32c85f8a339a42
JennicaStiehl/db_python_exercises
/strings.py
343
3.875
4
long_string = "Fall is a great time to make pumpkin bread!" print(long_string[0:4]) print(long_string[-5]) print("%c is my %s letter and my number %d number is %.5f" % ('x', 'favorite', 1, .14)) print(long_string.capitalize()) print(long_string.find("bread")) print(long_string.isalnum()) quote_list = long_string.split(...
5186d7ee1bcbe2b7019204a34537a987b640f9e2
AnshumanSinghh/DSA
/data_structure/queue/tcs_02.py
918
3.71875
4
def numOfWays(a, b): n = len(a) m = len(b) if m == 0: return 1 new = [[0] * (n) for _ in range(m)] for i in range(m): for j in range(i, n): if i == 0: if j == 0: if a[j] == b[i]: new[i][j] = 1 ...
d7de4f27b05171c1a29e6fd4f1b0fab5e872dbaf
AnshumanSinghh/DSA
/Sorting/selection_sort.py
864
4.28125
4
def selection_sort(arr, n): for i in range(n): min_id = i for j in range(i + 1, n): if arr[min_id] > arr[j]: min_id = j arr[min_id], arr[i] = arr[i], arr[min_id] return arr # Driver Code Starts if __name__ == "__main__": arr = list(map(int, input...
52327888006bb61760a9b8b0e4f2cdce59d8255f
lran2008/seqscripts
/tophatUtils.py
1,046
3.53125
4
def parseTophatBedLineToDict(line): linedict = {} bl = line.split('\t') blocksizes = bl[10].split(',') blockstarts = bl[11].split(',') linedict['blockstarts'] = [int(x) for x in blockstarts] linedict['blocksizes'] = [int(x) for x in blocksizes] linedict['chromStart'] = int(bl[1]) linedic...
2adcc454bfc2126ef3c0e19349ab19c264314253
NGG-kang/PythonPractice
/String.py
3,557
4.03125
4
# 문자열 자료형 # 문자열에서 유용하게 쓰이는게 많다 a = "Python Practice" #문자열 a = "\"Backslash\"" # 문자열에 (")추가 하려면 백 슬래시 사용 a = "\n" # 줄 바꾸기를 위한 이스케이프 코드 a = "\', \"" # 그외는 \t(탭), \\ (백슬래시) 등이 있다 # 여러 줄 입력시는 (''') or (""") 사용 a = '''Python String Practice ''' ...
8f0a80532c3cd7cd004978563dda65b3138b5906
blewert/intro-multiagent
/multiagent-move.py
2,941
4.0625
4
## Benjamin Williams <eeu222@bangor.ac.uk> ## Horde Labs ## --- ## A simple example which involves drawing multiple agents moving around an environment. ## #Import tkinter module for python 2.7, if you're running 3, use Tkinter as the module name. import tkinter as tk import math import random #The environment width...
dd7db5fab293db002751c61e3af510eed33a7bde
zhr619151879/Job-shop-scheduling
/Test/ttt.py
7,124
3.65625
4
import fileinput import random import time import pandas as pd def readJobs(path=None): """ Returns a problem instance specified in a textfile at path. """ abz5 = './abz5.txt' with fileinput.input(files=abz5) as f: next(f) jobs = [[(int(machine), int(time)) for machine, time in zip...
41b0bfff2c193bd57043e73a6208d22e317c8834
piroor/ShunsukeArai-readable-code
/shiyou1.py
215
3.546875
4
import dictionary_data # print(dictionary_data.language1) # print(dictionary_data.language2) # print(dictionary_data.language3) for i in range(len(dictionary_data.lis)): print(i+1,": ",dictionary_data.lis[i])
539b2280307a72c01443551a197fd4962406efdc
Jyothsna99/Problem-Solving
/listPythonSort.py
276
4.03125
4
l=[int(x) for x in input().split()] if(all(l[i] < l[i+1] for i in range(len(l)-1))): print("List is sorted in ascending order") elif(all(l[i] > l[i+1] for i in range(len(l)-1))): print("List is sorted in descending order") else: print("List is not sorted")
9a0266ced700c9fad5d415f84cd216a9461ba463
Jyothsna99/Problem-Solving
/infytq2.py
224
3.984375
4
a=int(input("Enter 1st number")) b=int(input("enter 2nd number")) c=int(input("enter 3rd number")) if c==7: print("-1") elif b==7: print(c) elif a==7: print(b*c) else: print(a*b*c)
90abab8b72a7120c81d5e9c5bdb4822aaf29da8b
iciarsierra/practical4
/evenodd.py
94
4.0625
4
x = int (input ("Enter one value: ")) if x%2 == 0: print ("Even") else: print ("Odd")
dd725fbb498fa0e06a8920d54d9302a396248c7c
Seppamar/cipher
/cipher.py
508
3.734375
4
##användaren väljer vilket tekst skall cipheras och hur mycket ##ord("A") returnerar ascii 65 ##chr(90) returnerar Z word = "Ree" def cipher(tekst, key): ciphered = "" for letter in tekst: ##Ändrar parametern till ascii To_acii = ord(letter) ##Förflyttar ascii tecknet med key ...
f0db2e8b269eb83e0b66b34ad11efaafb94c95c3
ramyasutraye/Python-Programming-11
/Beginner Level/composite no.py
200
4.21875
4
m=int(input('Enter the number ')) factor=0 for i in range(1,m): if m%i==0: factor=i if factor>1: print ("The number is a composite number!") else: print ("This is not a composite number!")
691f8ce70b61eb374495b4fb0ab06353a66511a6
ramyasutraye/Python-Programming-11
/Beginner Level/swap two nos.py
143
3.875
4
a = 5 b = 10 temp = a a = b b = temp print('The value of x after swapping: {}'.format(a)) print('The value of y after swapping: {}'.format(b))
d124e426fc4a6f6f42c2942a8ce753e31c07ba56
AnniePawl/Tweet-Gen
/class_files/Code/Stretch_Challenges/reverse.py
1,036
4.28125
4
import sys def reverse_sentence(input_sentence): """Returns sentence in reverse order""" reversed_sentence = input_sentence[::-1] return reversed_sentence def reverse_word(input_word): """Returns word in reverse order""" reversed_word = input_word[::-1] return reversed_word def reverse_rev...
5428b2f9dce1f91420c57963dcd1e80275e3c6cb
AnniePawl/Tweet-Gen
/class_files/Code/rearrange.py
864
4.125
4
import sys import random def rearrange_words(input_words): """Randomly rearranges a set of words provided as commandline arguments""" # Initiate new list to hold rearranged words rearranged_words = [] # Randomly place input words in rearranged_words list until all input words are used while len(re...
5ee167c03ccd081d4398f971e8b04b5c2e079aaa
Windspar/Gamelayer
/gamelayer/util/wordwrap.py
391
3.515625
4
def wordwrap(font, text, width): lines = [] x = 0 w = len(text) while x < w: while font.size(text[x:w])[0] > width: w -= 1 if w != len(text): while text[w] != " ": w -= 1 line = text[x:w].strip() if len(line) > 0: lin...
e7de485a21e6e2df73d90546ef10f657390de78b
RonyPatel22/demotool
/rp.py
719
3.828125
4
name = input("Type your name : ") print("Hello " + name ) fathername = input("What is your father name : ") print("Your father name is " + fathername ) age = input("What is your age : ") print("Your age is " + age ) gender = input("What is your gender male/female : ") print("Your gender is " + gender ) graduation =...
be183d4018f826da35d2714e5aba2677fb2d6ebb
MaxBotta/Vertiefung_Programmierung
/Tobi/IS01/Alice in Wonderland.py
674
4
4
def countinglines(): with open(".\Alice.txt", encoding="utf8") as file: print("Zeilen: ") print(sum(1 for _ in file)) def countingcharacters(): with open(".\Alice.txt", encoding="utf8") as file: print("Zeichen: ") zeichen = 0 for line in file: #words ist ein...
d4362b0037e772e94ad84f0c5f3514141bb920a1
MaxBotta/Vertiefung_Programmierung
/Max/Adressbuch/tools.py
483
3.859375
4
def set_spacing(string, x): i = len(string) spacing = "" while i <= x: space = " " spacing = spacing + space i = i + 1 return spacing def is_alphabetic(value): if all(i.isalpha() or i == ' ' for i in value): return True return False def is_number(value): i...
503ad24148f7233e5c12f6e06be7b47b444e93cb
zezei/linearAlgebra-coursera
/assignment 4/geometry_lab/geometry_lab.py
3,978
4.125
4
from mat import Mat import math ## Task 1 def identity(labels = {'x','y','u'}): ''' In case you have never seen this notation for a parameter before, the way it works is that identity() now defaults to having labels equal to {'x','y','u'}. So you should write your procedure as if it were defined...
fe5bea4d582ef4b4bdbee6f387dcf82aa7511913
zezei/linearAlgebra-coursera
/assignment 3/hw3/hw3.py
6,979
3.875
4
# version code 893 # Please fill out this stencil and submit using the provided submission script. from mat import Mat from vec import Vec import matutil ## Problem 1 # Please represent your solutions as lists. vector_matrix_product_1 = [1, 0] vector_matrix_product_2 = [0, 4.44] vector_matrix_product_3 = [14, 20, 2...
60a490e49326cbc6bb2d5a854d1da5b9a7fca179
Jeffro80/Convert_Expenses
/convertExpenses.py
11,146
3.75
4
# Author: Jeff Mitchell # Date: 18 March 2019 # Version: 0.2 # Quick Desc: Program to convert expenses into Annual, Monthly, Fortnightly and # Weekly # To be fixed: # Future capability: # Subtract an expense from total import copy import custtools.admintools as ad import sys def confirm_reset(): """Confirm th...
b757503b78c08eb76ff697ecae37265f19c7285b
JuhiPaliwal/Morse-Code
/GPIO.py
14,800
3.765625
4
""" Author : Juhi Paliwal and Arunima Mookherjee Last Modified : Sat, Apr 16 2016 18:16:46 MORSE CODE GENERATOR BUILT ON RASPBERRY PI """ import time import RPi.GPIO as GPIO GPIO.setsmode(GPIO.BOARD) GPIO.setup(12,GPIO.OUT) GPIO.cleanup() on_time=3 on_short_time=1 off_time=1 word=input("Enter the ...
f76a969859f8cdbfedb6a147d505ae1fc788dc19
Chris-Valenzuela/Notes_IntermediatePyLessons
/4_Filter.py
664
4.28125
4
# Filter Function #4 # Filter and map are usually used together. The filter() function returns an iterator were the items are filtered through a function to test if the item is accepted or not. # filter(function, iterable) - takes in the same arguements as map def add7(x): return x+7 def isOdd(x): return x ...
f11b5ae468153672fbafee116ab432b77cb19c2e
MayuriTambe/Programs
/Programs/DataStructures/List/4.Count.py
173
3.875
4
Data=['abc', 'xyz', 'aba', '1221'] print("The list is:",Data) Result=0 for element in Data: if element[0]==element[-1]: Result=+1 print(list.count(Result))
fcd1c7d44e44b020e6ae0dff3123e9a0e2be8d04
MayuriTambe/Programs
/Programs/BasicPython/SizeOfObject.py
120
3.53125
4
import sys input=input("Enter the data") size=sys.getsizeof(input) print("The size of objects in byte form is:",size)
2c91438cf51545ab88b49b85133471ae3aa7e984
MayuriTambe/Programs
/Programs/DataStructures/sets/Frozenset.py
126
3.5
4
Details={"Name":"mayuri","Age":22,"ID":100} print("The set is:",Details) print(type(Details)) for i in Details: print(i)
14a410230faf3de4c85fbfb15d6d2dc2943677e5
MayuriTambe/Programs
/Programs/SqlConnection/MongoCRUD/Read.py
319
3.53125
4
import pymongo from pymongo import MongoClient myclient= pymongo.MongoClient('mongodb://localhost:27017/') database=myclient["codes"] collection=database["subjects"] data=([{"Maths":77,"English":79,"Computer":65,"Biology":87}]) result=collection.insert(data) findvalue=collection.find() print(result) print(findvalue)
39c7f7ce47b9c32558af8b2e84035cb3b8746cdc
MayuriTambe/Programs
/Programs/DataStructures/Strings/SubString.py
194
4.25
4
Name_of_String=input("Enter the String") print("The String is:",Name_of_String) Substring=input("Enter the substring from the string") Occurence=Name_of_String.count(Substring) print(Occurence)