blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fdc11ce0d759260621efb625478ffb8ae872396e
josephsmartinez/python
/homework/music.py
1,952
3.5
4
from abc import ABCMeta # Metaclass class Instrument: __metaclass__ = ABCMeta play_behavior = None def display(self): pass def playBehavior(self): print(self.play_behavior) class Violin(Instrument): def __int__(self): self.play_behavior = Bow() de...
d97afd52ce743e383495528a086be451ac71153d
josephsmartinez/python
/Topics/Functions/closures.py
494
3.5
4
# Python Closures. A Closure is a function object that remembers values in enclosing scopes even if they are not present in memory. # https://youtu.be/swU3c34d2NQ def logger(msg): def log_message(): print('Log', msg) return log_message log_hi = logger('Hi') log_hi() # def html_tag(tag): ...
eb14f7bb32f3e35991def7d66a63d864edb5b9af
josephsmartinez/python
/Topics/JSON_XML/example/lambda_function_examples.py
1,045
4.78125
5
#lambda function in python - used to create anonymous function objects #example 1 x = lambda a : a + 10 print(x(5)) ############################################# #example 2 x = lambda a, b : a * b print(x(5, 6)) ############################################# #example 3 x = lambda a, b, c : a + b + c print(x(5, 6, 2)) ...
0f7236c6fcd3063d63a40b5e05240ec6b3f7d56c
Nathanael126/Assignment-Week-6
/Assignment (7)/Assignment 7.py
390
3.796875
4
# Create variables and open files Book = open("Assignment 7 Book (Frankenstein; Or, The Modern Prometheus by Mary Wollstonecraft Shelley).txt","r" ,encoding='utf8') Word_Length = 0 counter = 0 # Calculate average length for a in Book: for b in a.split(): counter += 1 Word_Length += len(b) ...
89660dcc1a2f8b3038ff190bf39ec48e75143334
braeden-smith/Chapter-8-9-10
/Chapter 8 Excercise 6.py
772
4.28125
4
#Braeden Smith - Chapter 8 Excercise 6 #8.6: Rewrite the program that prompts the user for a list of numbers and prints #out the maximum and minimum of the numbers at the end when the user enters “done.” #Write the program to store the numbers the user enters in a list and use the max() #and min() functions to c...
a9d884d274c01dd78cceab6370265d03f5fafe07
kizcko/Number-Theory
/Reed-Solomon/main.py
509
3.75
4
import decoding from encoding import encoding from decoding import * m = 29 p = 11 s = 1 k = 3 def convert_to_ascii(text): return "".join(str(ord(char)) for char in text) if isinstance(m, str): m = int(convert_to_ascii(m)) def main(m,p,s,k): print("\nEncoding\n",20*'=') print(...
abad4069fe6a47e510018da684c81aefb5f9e99e
xiaolongwang2015/Interview
/stock_timing2.py
1,363
3.6875
4
""" 题目:买卖股票的最佳时机2 难度:简单 题目描述: 给定一个数组 prices ,其中prices[i] 是一支给定股票第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。 注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 示例 1: 输入: prices = [7,1,5,3,6,4] 输出: 7 解释: 在第 2 天(股票价格 = 1)的时候买入,在第 3 天(股票价格 = 5)的时候卖出, 这笔交易所能获得利润 = 5-1 = 4 。 随后,在第 4 天(股票价格 = 3)的时候买入,在第 5 天(股票价格 = 6)的时候卖出, 这...
c666563aef5024cd9cda3f64ef116e4fb1acc0c2
xiaolongwang2015/Interview
/dp/domain_model_simplified.py
2,165
3.546875
4
class Wall: """ 墙 """ def __init__(self, wall_coordinates, wall_type): # 设置属性 self.wall_coordinates = wall_coordinates # 墙的坐标点集 self.wall_type = wall_type # 墙的类型 class Window: """ 窗户 """ def __init__(self, window_coordinates, need_to_be_dismantled, window_he...
dd3749681cb56f0a22f138d2373c0f1c140c8a91
xiaolongwang2015/Interview
/54螺旋矩阵.py
2,047
3.828125
4
""" 54 螺旋矩阵 难度:中等 题目描述: 给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。 示例1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例2: 输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7] m == matrix.length n == matrix[i].length 1 <= m, n <= 10...
f49c6fd2cd3baa7c71cd6e86180c6e987cab3a6d
xiaolongwang2015/Interview
/二叉树/102二叉树的层序遍历.py
1,223
3.671875
4
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def levelOrder(self, root: TreeNode): rst = [] stack = [] if root is None: retur...
708169ed99cb4203a49c24fb73a5e9881ca1a2f2
julencosme/python_programs
/admin_privileges.py
616
3.984375
4
# Module for classes: Admin and Privileges. class Privileges(): """Represent admin user's privileges.""" def __init__(self): self.privileges = ["can add a post", "can delete a post", "can ban a user", "can add admin user"] def describe_admin_privileges(self): p...
6f2b755900e20445827577bfa312749df9964739
julencosme/python_programs
/cubic_numbers.py
385
3.640625
4
# Plotting first five cubic numbers. import matplotlib.pyplot as plt input_values = [1, 2, 3, 4, 5] cubes = [1, 8, 27, 64, 125] plt.plot(input_values, cubes, linewidth=3) plt.title("Cubic Numbers", fontsize=21) plt.xlabel("Value", fontsize=13) plt.ylabel("Cube of Value", fontsize=13) plt.tick_params(axis='both', l...
02c219f4f9864058401ba815d0eda9679f2c60fa
julencosme/python_programs
/functions_arbitrary_keywords_cars.py
395
3.890625
4
def make_car(manufacturer, model_name, **car_info): """Build a dictionary containing everything we know about a car.""" car = {} car['manufacturer'] = manufacturer car['model'] = model_name for key, value in car_info.items(): car[key] = value return car car_profile = make_car( 'mer...
1fe0141bace6717a4f841c44f48283eb03db2a5a
julencosme/python_programs
/dictionaries_for_loops_people_favorite_numbers.py
366
3.546875
4
favorite_numbers = { 'Abe': ['6', '66', '6666'], 'Boswell': ['4', '44', '4444'], 'Francisco': ['7', '77', '7777'], 'Jane': ['3', '33', '3333'], 'Cecelia': ['0', '00', '0000'], } for person, numbers in favorite_numbers.items(): print("\n" + person.title() + "'s favorite numbers are:") for nu...
9516d4ce4b81be9539581d514fad3634af3e4537
julencosme/python_programs
/for_loops_if_message_hello_admin.py
282
3.875
4
user_names = ['Admin', 'Adam', 'Bob', 'Christina', 'Diane', 'Evan'] for user_name in user_names: if user_name == 'Admin': print("Greetings Admin, would you like to see a status report?") else: print("Greetings " + user_name + ", thank you for logging in.")
5d0095a29aa307336a84ec2176d0fc5760cdda89
julencosme/python_programs
/users.py
1,329
4.28125
4
# Module for classes: 'User', 'Privileges', 'Admin'. class User(object): """A model for a user.""" def __init__(self, first_name, last_name, age, country): """Intialize user info attributes.""" self.first_name = first_name self.last_name = last_name self.age = age self...
de5ae86a428978a141a632417ef4c05e942e23c8
julencosme/python_programs
/prompt_if_elif_else_movie_tickets.py
509
4.0625
4
# Movie ticket information: # If a person is under the age of 3, the ticket is free. # If they are between 3 and 12, the ticket is $10. # If they are over age 12, the ticket is $15. prompt = "What is your age?\n" prompt += "Once you have entered your age, we will state your admission fee: " while True: age = in...
4fd8645e4b15532b49e7ac101000c61c28eaf106
julencosme/python_programs
/classes_child_parent_ice_cream_shoppes.py
1,260
4.4375
4
class Restaurant(): """A model of a restaurant.""" def __init__(self, name, cuisine): """Initialize name and age attributes.""" self.name = name self.cuisine = cuisine def describe_restaurant(self): """Simulate a description of restaurant.""" print(self.name.title()...
832a63ccbe255281418f4a4977a97b0fe9d17821
julencosme/python_programs
/molecules_loopRandomMotion.py
565
3.875
4
# Generating random motion of molecules; wrapping 'molecules_randomMotion.py' # in a while loop to make sure the program continues to run. import matplotlib.pyplot as plt from motion_molecules import RandomMotion # Keeping the motion going, as long as the program is active. while True: # Making random motion, an...
28d84755da4a4d487f54b08d4d1233b8ee381b75
vishwanath79/PythonMisc
/Python3StandardLib/Concurrency/asyncio_queue.py
1,734
3.875
4
import asyncio # firstin first out structure for coroutines like a queue.queue async def consumer(n,q): print('Consumer {}: starting'.format(n)) while True: print('consumer {}: waiting for item'.format(n)) item = await q.get() print('consumer {}: has item {}'.format(n,item)) if i...
9a1243f92735a437a32575d5a55283fa682cdf18
vishwanath79/PythonMisc
/FunctionalProgramming/self_init.py
702
3.65625
4
class Car(object): def __init__(self, model,color,company,speed_limit): self.color = color self.company = company self.model = model self.speed_limit = speed_limit def start(self): print("started") def stop(self): print("stopped " + self.model) def ...
6b3678e4a4dd264263853b22c9d8384285e5c492
vishwanath79/PythonMisc
/Python3StandardLib/1text/textwrapper.py
751
3.90625
4
import textwrap sample_text = ''' The textwrap module can be used to format text for output in situations where pretty-printing is desired. It offers programmatic functionality similar to the paragraph wrapping or filling features found in many text editors. ''' print(textwrap.fill(sample_text, width=50))...
a2b6dda8e754d28c870b6c078acb4120a16e10a7
vishwanath79/PythonMisc
/Pythonic/6_1definingfieldsonclasses.py
493
3.625
4
class NotSoPythonicPet: #def __init__(self): def __init__(self, name,age): self.age = age self.name = name def __str__(self): return "A pet whose name is {} and age is {} ".format(self.name,self.age) #dont do below # def set_name(self,name): # self.name = name # ...
f9ce45d7b24ea47a82015aefcd348a08d8fd2156
vishwanath79/PythonMisc
/IntermediatePy/3_2jeopardy.py
701
3.84375
4
import sqlite3 connection = sqlite3.connect("jeopardy.db") # print(help(connection)) # get cursor cursor = connection.cursor() # print(dir(cursor)) cursor.execute("Select game from Category order by random() limit 1") results = cursor.fetchall() # print(results) # print(results[0]) game_id = results[0][0] print("Categ...
fe956bf6ba8ab7b0a69f464099cc8f966912226a
vishwanath79/PythonMisc
/Python3StandardLib/Algorithms/itertoolsisslice.py
546
3.75
4
from itertools import * print('Stop at 5:') for i in islice(range(100),5): print(i, end='') print('\n') print('Start at 5, Stop at 10:') for i in islice(range(100), 5,10): print(i,end=' ') print('\n') print('By tens to 100:') for i in islice(range(100),0, 100, 10): print(i, end=' ') print('\n') #tee fun...
aeef2a36b42fdcb1a82fe9561d85658b0bf45be3
vishwanath79/PythonMisc
/Python3StandardLib/Algorithms/caching.py
1,000
3.8125
4
import functools @functools.lru_cache() # decorator wraps a function in a least-recently used cache.Arguments ot the function are used to build a hash key, whihc is then mapped to a result def expensive(a,b): # subsequent calls with the same arguments will fetch value from the cache instead of calling the function ...
e649d7164a88afe12a6bf403ad4df54150db56c2
vishwanath79/PythonMisc
/MiscScripts/a8_2inheritance.py
1,373
3.609375
4
import sys from abc import ABC, abstractmethod def print_table(objects, colnames,formatter): '''make a formatted table showing attributes from a list of objects''' formatter.headings(colnames) for obj in objects: rowdata = [str(getattr(obj, colname)) for colname in colnames] formatter.row(...
10dce8d7a4453a90fd907ea80b8686a604a43e14
vishwanath79/PythonMisc
/Cookbook/71ANynumofarguments.py
492
3.5625
4
import html def avg(first, *rest): print((first + sum(rest)) / (1 + len(rest))) # to accept any number of arguments, use an argument that starts with ** def make_element(name,value,**attrs): keyvals = [' %s="%s"' % item for item in attrs.items()] attr_str = ''.join(keyvals) element = '<{name}{attrs}...
b3babce45810fcedccbfe62fd27d75e2905bc64f
vishwanath79/PythonMisc
/DQ/titanic.py
3,844
3.71875
4
import pandas as pd import matplotlib.pyplot as plt # Read the dataset test = pd.read_csv("test.csv") test_shape = test.shape train = pd.read_csv("train.csv") train_shape = train.shape print(test_shape) # Learn the dataset sex_pivot = train.pivot_table(index="Sex",values="Survived") #sex_pivot.plot.bar() #plt.sho...
46faace8c3dec66b8c817dfa9315bf8d99ab1a05
vishwanath79/PythonMisc
/PythonScrape/2BeautifulSoup.py
809
3.625
4
import requests from bs4 import BeautifulSoup response = requests.get("http://dataquestio.github.io/web-scraping-pages/simple.html") content = response.content print(content) # Initialize the parser parser = BeautifulSoup(content, 'html.parser') # BS allows accessing branches by using tag types as attributes body ...
5e7e96e4aaa1cc421b6c526e73ddd43a760a3d89
vishwanath79/PythonMisc
/Pythonic/7_1Numericalloop.py
264
3.921875
4
data = [1,7,11] for item in data: print("the value is {}".format(item)) for i in range(1,10): print(i, end=', ') # combination of tuple and unpacking # enumerate gives tuple for idx,value in enumerate(data): print(" {} --> {}".format(idx+1,value))
bfc4a4f24f19d7fe308723384f9516752c6fbf02
vishwanath79/PythonMisc
/Pythonic/8_3ReturnMultipleValuefromFunction.py
649
3.71875
4
import math def main(): args = list() out_params_bad(7,args) print("Return values (bad) : {} & {:.2f}".format(args[0], args[1])) v1,v2 = out_param(7) print("Return values (bad) : {} & {:.2f}".format(v1,v2)) #non pythonic def out_params_bad(base:float, args:list): if len(args) == 0 : a...
534ea09bbfa8983e826a73a4c3d2948bd4892ad3
Hitendraverma/Python-Codes
/pydatetime.py
674
4.125
4
#!/usr/bin/python import time import calendar #calender in python print(calendar.month(2015,12)) #print calender of full year ... calender.calender( year , day width ,each week occupy no. line , width btwn months ) print(calendar.calendar(2016 , 2 , 1 , 10)) time.sleep(3) #leap year print"Check leap 2008 : " , c...
1ee40459fcefd1a7c0ebe8e41abafd0e2fa32033
Hitendraverma/Python-Codes
/scissors.py
757
3.90625
4
#!/usr/bin/python import sys #Its a simple two player game. '''Remember the rules: Rock beats scissors Scissors beats paper Paper beats rock ''' p1 = input("Enter first player name : ") p2 = input("Enter 2nd player name : ") p1a = input(" Enter your option : ") p21= input(" Enter your option : ") def compare(u1,u2...
a82b57606b78a60f7baeae2a62c328ead316ec5c
kgoyal98/AI-ML-Lab
/Assignment 7/la7-160050026/search.py
4,484
4.0625
4
import util from sudoku import SudokuSearchProblem from maps import MapSearchProblem ################ Node structure to use for the search algorithm ################ class Node: def __init__(self, state, action, path_cost, parent_node, depth): self.state = state self.action = action self.pa...
04f0f4c29b520511cb66e41fadaa3e7e8c8a4fed
Mateusz-Godlewski/beautiful_soup
/challenge.py
220
3.921875
4
list1 = [14, 21, 12] list2 = ["14", "21", "12"] list3 = ["1414", "2121", "1212"] index_of_winner = list1.index(max(list1)) print(list1[index_of_winner]) print(list2[index_of_winner]) print(list3[index_of_winner])
a658729ca6008118512b4e5a0d3094a96ac155a5
GianRathgeb/CodingChallanges
/hard/Flip_the_Array/main.py
273
3.65625
4
# Challange: https://edabit.com/challenge/QoavwQhmrDpXJhBW9 # Input: flip_list([1, 2, 3, 4]) ➞ [[1], [2], [3], [4]] def flip_list(lst): output = [] for i in lst: if type(i) is list: output.append(i[0]) elif type(i) is int: output.append([i]) return output
3713841a4d69f2fab214a567a5180840262d57b7
GianRathgeb/CodingChallanges
/hard/The Karaca's_Encryption_Algorithm/main.py
372
3.953125
4
# Challange: https://edabit.com/challenge/JzBLDzrcGCzDjkk5n # Input: encrypt("banana") ➞ "0n0n0baca" def encrypt(word): word = word[::-1] output = "" for l in word: if l == "a": output += "0" elif l == "e": output += "1" elif l == "i": output += "2" elif l == "o": output += "2" elif l == "u": output += "...
d8852a16b468cff6cb5be782e4bc4144ca7d29ee
JanVin/Algorithms
/QuickSort.py
604
3.734375
4
import random def Partition(A, p, r): x = A[r] i = p - 1 for j in range(p, r): if A[j] <= x: i += 1 A[i], A[j] = A[j], A[i] A[i+1], A[r] = A[r], A[i+1] return i + 1 def randomized_partition(A, p, r): i = random.randint(p, r) A[r], A[i] = A[i], A[r] ret...
d055a30a5a3cd715ff433037612359d686a84cbe
tamilselvysm23/pythonBasics
/temperature/test.py
321
3.6875
4
temperature=[10, 20, 50, 46, -35, -56, 232, 100, -45, 187] def celsius_to_fahrenheit(temp): with open("temp.txt", "w") as myfile: for c in temperature: if c > 40: f = c*9/5+32 myfile.write(str(f)+"\n") celsius_to_fahrenheit(temperature) ...
bd36ba64e7fb2c300671e0b437adb282c01570d8
raymondsjkim/python-basics
/assignmentOne.py
356
4.28125
4
''' Raymond Kim 01/11/2018 Python Assignment 1 ''' #Get user input number = input("Enter an integer between 6 and 24: ") #Convert str to int number = int(number) if number < 6 or number > 24: print("This is the case"); elif 6 < number <= 12: print("Congratulations") else: number = number - 6 print("Yo...
d67506ce13ccd20cdb15af6c8bff1a7cfe865408
jmav94/topicos-con-python-2021
/fundamentos-de-python/tiposdedatos.py
1,291
4.25
4
""" NoneType - None - Nada str - String - Cadena de texto int - Integer - Entero float - flotante - Decimal bool - Boolean - True/False list - Lista - Coleccion de datos tuple - Tuplas - Coleccion de datos estatica dict - Diccionario - Clave y su valor range - Rango byte - set - Similar a los diccionarios pero puede f...
0c7e991489f42ad9202319cca269346c8dcf951d
jmav94/topicos-con-python-2021
/ciclos/for.py
662
4.15625
4
# for variable in iterable (lista, rango, array) # Instrucciones contador = 0 restultado = 0 for contador in range(0,6): print("Esto es un ejmplo del ciclo for y esta la vuelta " + str(contador)) contador +=1 print("Aqui termina el ciclo") print("######### Ejemplo tablas de multiplicar ##############") numer...
65e9bf05a716aec9e27298cfd0a2c62473a301f3
jmav94/topicos-con-python-2021
/manejo_errores/main.py
1,236
4.53125
5
# Captura de excepciones y manejo de errores en codigo. """ try: nombre = input("Cual es tu nombre? ") if len(nombre) > 1: nombre_usuario = f"El nombre es: {nombre}" print(nombre_usuario) except: print("Ha ocurriedo un error, introduce bien el nombre") else: print("El programa funciona correctamente") fi...
2e3962c5d4625a69b34dea04d1314d1925038f49
AdrianVillamor/hello-python
/for.py
85
3.796875
4
for c in "Hello!": print(c) for x in range(100): print(x, end = " ") print()
908c956d92611a1c849a84976e36dfdd7cc2d7e9
klatimer/py_test
/blink_threading.py
1,501
3.5625
4
# Kenneth Latimer # 1/16/17 # Description: # Using two threads to flash an LED and stop once button is pressed import RPi.GPIO as GPIO import time import threading global exitFlag exitFlag = False class blinkThread (threading.Thread): def __init__(self, name): threading.Thread.__init__(self) self._running = Tr...
c5c61ff3ff85e909400b40fa387cfcce5a294860
yeruijin/ww.xo
/lx/lx3.py
821
3.6875
4
if __name__=='__main__': klist = [ "good ", "good ", "study", " good ", "good", "study ", "good ", " good", " study", " good ", "good", " study ", "good ", "good ", "study", " day ", "day", " up", " day ", "day", " up", " day ", "day", " up", ...
b77de278ed98b56542b9c358041575c2aeee4fe6
yeruijin/ww.xo
/dayfour/__init__.py
314
3.859375
4
if __name__=='__main__': age1=int(input("请输入你的年龄:")) age2=int(input("请输入他/她的年龄:")) if age1 > age2: print("{0}>{1}".format(age1,age2)) elif age1<age2: print("{0}<{1}".format(age1, age2)) elif age1==age2: print("{0}={1}".format(age1, age2))
f8aeb68357ff6ad0167f92d9481885df2b3fca24
rotsix/algo
/ProjectEuler/Problem007.py
394
4.0625
4
#!/usr/bin/env python # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. # What is the 10 001st prime number? primes = [] i = 2 while len(primes) < 10001: prime = True for elt in primes: if i%elt == 0: prime = False break ...
565fef7978851b5588fd926ad56188200882df6c
rotsix/algo
/conway'sGameOfLife.py
3,189
3.875
4
#!/usr/bin/env python # Simple implementation of the Conway's Game of Life # https://en.wikipedia.org/wiki/Conway's_Game_of_Life from time import sleep def ask_cells(grid): nbCells = int(input("Nb cells ? ")) for i in range(nbCells): print(f"Cell nb {i}") x = int(input("X pos ? ")) y = int(input("Y pos ? ")...
f3f8e0829cd892d83fce80fbc738e4bea2e9e2af
rotsix/algo
/ProjectEuler/Problem033.py
1,540
3.703125
4
#!/usr/bin/env python # The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s. # We shall consider fractions like, 30/50 = 3/5, to be trivial examples. # There are exactly fou...
a156c5726eef78953cead6e1db8c859751ce9108
HYUNMIN-HWANG/Algorithm_practice
/python_study/02-7.bool.py
707
4.15625
4
#### bool 자료형 # True, False a = True b = False print(type(a)) # <class 'bool'> print(type(b)) # <class 'bool'> print(1==1 ) # True print(3>1) # True print(1>10) # False #### 자료형의 참, 거짓 # 비어있으면 거짓, 요소가 있으면 참 if []: # 비어있기 때문에 >> 거짓 print("참") else : print("거짓") if [1,2...
6b2c62f9a79bf7cc6681f493b97619766fe33232
SviatoslavChuiko/Python
/task3.py
251
4.03125
4
NUM = int(input("Enter NUM: ")) n = int(input("Enter number: ")) if NUM >= -3 and NUM <= 20: if n == NUM: print("Success!") if n > NUM: print("More than") if n < NUM: print("Less than") else: print("Try again")
d33f8ae2f930afd41e35b0792e6708e47dd8b3d9
kalinni/JSSP-Tabu
/jssp_parser.py
2,070
3.953125
4
from operation import Operation def separate_instances(file,directory): ''' This function simply separates the instances found in jobshop1.txt into extra files on which the parse_instance function can then be called. ''' with open(file,encoding="utf8") as file: first_instance_found = False file_created = Fa...
0bc8d3572754e0d683b0ff56a2314978d402bf54
Uzaircodin/Hangman
/Hangman.py
1,110
4.09375
4
_input = True playername1 = input("What's your name?...You will give the word:") playername2 = input("What's your name?...You will be guessing:") space = " " greetings = input("Hi" + space+ playername1 +space+ "are you ready to play?...Yes or No:") wordsentence = "Enter a word:" word = "" if greetings == "Yes": w...
4c6ce5dea961a0ea1063806eb15917aa44354086
natalia-cortese/Codewars
/Product of consecutive Fib numbers.py
1,063
4.125
4
""" Challenge: The Fibonacci numbers are the numbers in the following integer sequence (Fn): 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ... such as F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1. Given a number, say prod (for product), we search two Fibonacci numbers F(n) and F(n+1) verifying F(n) * F(n+...
f3a96a15dc14c4b215dc85982083806bc2f856f8
natalia-cortese/Codewars
/Prefill an Array.py
1,393
4.28125
4
""" Instructions: Create the function prefill that returns an array of n elements that all have the same value v. See if you can do this without using a loop. You have to validate input: -v can be anything (primitive or otherwise) -if v is ommited, fill the array with undefined -if n is 0, return an empty array -if n...
395e329f129d15cdd9a11b1c104ac63024675329
lyoness1/hb-code-challenges
/medium/takeaway/takeaway-solution.py
2,140
4.0625
4
"""Takeaway game. >>> takeaway(1) 2 >>> takeaway(2) 1 >>> takeaway(3) 1 >>> takeaway(4) 1 >>> takeaway(5) 1 >>> takeaway(6) 1 >>> takeaway(7) 2 >>> takeaway(8) 2 >>> takeaway(9) 1 >>> takeaway(10) 1 >>> takeaway(20) 1 """...
645f069c6a39f7a9f67d50ddd8e3a969a8b2065f
lyoness1/hb-code-challenges
/medium/largest-sum/largestsum.py
1,902
4.21875
4
"""Find the subsequence with the largest sum. Given a list of integers, like: [1, 0, 3, -8, 4, -2, 3] Return the contiguous subsequence with the largest sum. For that example, the answer would be [4, -2, 3], which sums to 5. >>> largest_sum([1, 0, 3, -8, 4, -2, 3]) [4, -2, 3] >>> largest_sum([1, 0, ...
786de0f9f9d56fb49e2806d5009268ebd7c1be48
laithadi/School-Work---Python
/adix5190_l7 /src/t13.py
495
3.640625
4
""" ------------------------------------------------------------------------ Total digits ------------------------------------------------------------------------ Author: Jayvinder Singh, Laith Adi ID: 181000220, 170265190 Email: rsha0220@mylaurier.ca, adix5190@mylaurier.ca __updated__ = "2018-11-08" -----...
355405235f2ea4c3bd5c94ff02ea3d8e0c1a4363
laithadi/School-Work---Python
/Adix5190_a7/t03.py
283
3.65625
4
''' [program description] Author: Laith Adi ID: 170265190 Email: Adix5190@mylaurier.ca __updated__ = "2018-11-16" ''' from functions import my_find s = input('String to search:') r = input('String to search for:') i = my_find(s, r) print("'{}' is found at location {} in '{}'".format(r, i, s))
7da5e9744b4b7da32c7623b0fcb052ee027373fa
laithadi/School-Work---Python
/Adix5190_l4/t05.py
637
3.9375
4
''' Lab 4, Task 5 Author: Laith Adi & Ashwin Balaje ID: 170265190 & 180790110 Email: Adix5190@mylaurier.ca & bala0110@mylaurier.ca __updated__ = "2018-10-04" ''' budget = int(input('Enter budget: $')) day = 1 expense = 0 total_expense = 0 while day < 8: expense = int(input('Expenses for day {}: $'.format(day...
fe851a02c15aad72263c2c9ff277348e4f4413e5
laithadi/School-Work---Python
/Adix5190_l8/src/t02.py
446
3.71875
4
""" ------------------------------------------------------------------------ Lab 8 ------------------------------------------------------------------------ Author: Laith Adi ID: 170265190 Email: Adix5190@mylaurier.ca __updated__ = "2018-11-15" ----------------------------------------------------------------------...
d8e6faf8ab70527eee21c3b6b9455b71f135d204
laithadi/School-Work---Python
/Adix5190_a4/t04.py
1,608
3.9375
4
''' [program description] Author: Laith Adi ID: 170265190 Email: Adix5190@mylaurier.ca __updated__ = "2018-10-16" ''' # minimum percent SPEND_ATLEAST = 90 / 100 # get budget and set minimum amount party_budget = float(input('Party budget: $')) min_amount = party_budget * SPEND_ATLEAST # setting initial money le...
2796c2901aa28a8353c1cfad59d5a396251f767d
laithadi/School-Work---Python
/Adix5190_l8/src/t05.py
538
3.6875
4
""" ------------------------------------------------------------------------ Lab 8 ------------------------------------------------------------------------ Author: Laith Adi ID: 170265190 Email: Adix5190@mylaurier.ca __updated__ = "2018-11-15" ----------------------------------------------------------------------...
36924d7f48d89f41f784c4348620182e36c9ad02
laithadi/School-Work---Python
/Adix5190_a5/t03.py
263
3.921875
4
''' [program description] Author: Laith Adi ID: 170265190 Email: Adix5190@mylaurier.ca __updated__ = "2018-11-02" ''' n = int(input("Number (>=1): ")) sum_a = 0 for i in range(1, n + 1): sum_a += 1 / (i**2) print("Sum of inverse squares for {} = {}".format(n, sum_a))
651ad964fa7058be3f66466ff60dcd570b8dfb88
arfeen21/Crypto-Big-Data
/src/stocks/tsla/tsla_wrapper.py
1,154
3.65625
4
import yfinance from datetime import datetime def get(): ''' Returns a cleaned dataframe of hourly $TSLA data starting from November 1st 2020 until today. Column names of the dataframe: - Date - HourlyPrice ''' #we start our analysis on data published after the 1st of November 202...
ede041204e4e1046a0b2b0f6a77ff02c96e51874
andreroche/Test-Scripts
/format3.py
587
4
4
age = 37 name = 'Bob' gender = 'male' hobby = 'cycling' timeofday = 'at night' typeofbike = 'giant' country = 'ireland' sizeofwheels = '700' print('{} {} {} was {} when he was {}'.format(timeofday,gender,name,hobby,age)) print('the sun is shining in the sky during the day') print('{} flew to {} then bough...
4ff81820913408335fb5681bcc313eda883fd219
andreroche/Test-Scripts
/csvimport.py
395
3.59375
4
from csv import reader, writer infile = open("data/iris.csv") csvReader = reader(infile) outfile = open("data/nicelyformatted.csv", "w") csvWriter = writer(outfile) headers = (["Petal Length", "Petal Width", "Sepal Length", "Sepal Width", "Flower Type"]) csvWriter.writerow(headers) next(csvReader) fo...
17bb8c6f815c16ffa21072f0913cdd58e9abd05c
andreroche/Test-Scripts
/collatz6.py
199
3.984375
4
# André Roche - Collatz Conjecture in Python. Wiki it on the Net n = int(input("Please enter an interger: ")) if n%2 == 0: n = n/2 print (n) else: n = 3*n+1 print (n) i+=1
67cf0db72ec29511ad896e3158031f69f3d7df59
charlieporth1/ubuntu-scripts
/alphabat.py
2,204
3.640625
4
import sys import pickle import operator import itertools alphabet = 'abcdefghijklmnopqrstuvwxyz' #test if a word uses letters at most once def monoglyphic(word): word = sorted(word) for i in range(1,len(word)): if word[i]==word[i-1]: return False return True #make forwards and backwards trees of words #forw...
39c7c9843a3fa6f4a63b793774eeae42b0e229ce
IlyaSavich/recognizer
/index.py
641
3.5
4
import numpy from Network.Layer import Layer from Network.Network import Network # a = numpy.array([1]) # b = numpy.array([[1, 2], [3, 4], [5, 6]]) # print(b) layer1 = Layer(2, 2) layer2 = Layer(1, 2) network = Network([layer1, layer2]) training_set = numpy.array([ [0, 0, numpy.array([0])], [1, 0, numpy.array...
d15c83371b4dd349ad6a8bfe8c96dec286e263be
ben-paulson/data-structures
/stack/stack_linked.py
1,857
3.734375
4
"""Stack implementation with a singly linked list. Author: Ben Paulson """ from node import Node class StackLinked: """An implementation of the stack data structure using a singly linked list """ def __init__(self): self.top = None self.num_items = 0 def __eq__(self, other): ...
2b2103cc21e7ea4fed5650c32f43180552216255
ben-paulson/data-structures
/expression_evaluation/stack_array.py
2,990
3.9375
4
"""Stack implementation with an array. Author: Ben Paulson """ class StackArray: """An implementation of the stack data structure using an array of elements """ def __init__(self): self.arr = [None] * 2 self.capacity = 2 self.num_items = 0 def __eq__(self, other): ...
dea592532f302acad930ffea572f27fda6b80b2e
ben-paulson/data-structures
/stack/node.py
530
3.671875
4
"""Node definition. Author: Ben Paulson """ class Node: """A node of a list Attributes: val (int): the payload nxt (Node): the next item in the list prev (Node): the previous item in the list """ def __init__(self, val, nxt=None): self.val = val self.next = nxt ...
8688a4e2f18118b9371bfa2ee8ce21dadddb975f
FilipeAPrado/Python
/Paradigmas de linguagem em python/AulaDeClasses/account.py
637
3.5625
4
class Account: def __init__(self, num): self.num = num self.balance = 0.0 def checkBalance(self): return self.balance def credit(self, value): self.balance += value def debit(self, value): self.balance -= value def transfer(self, account, value): s...
b4ccea7c474481adb75d4f5dde8fd84cae01994e
FilipeAPrado/Python
/Paradigmas de linguagem em python/tabuada.py
496
4.03125
4
def multiplicantionTable2(number): multi = 0 while multi < 11: result = number * multi print(f'{number} * {multi} = {result}') multi = multi +1 multiplicantionTable2(int(input('enter a number:'))) def multiplicantionTable(number): multiplers = [0,1,2,3,4,5,6,7,8,9,10] for ind...
d4cc1eed840a997463929fe96567e3cb9cf9c736
FilipeAPrado/Python
/Paradigmas de linguagem em python/ClasseCarro/carro.py
2,214
3.984375
4
# Classe CarroCorrida # *Atributos: # - numeroCarro : int # - piloto : String # - equipe : String # - velocidadeMaxima : float # - velocidadeAtual : float # - ligado : boolean class Carro: def __init__(self, numeroCarro, piloto, equipe, velocidadeMax, VelociadeMin): self.numeroCarro = int(numeroCarro...
0290d406ccf4de31f1ebb05da45b19ecf11e1208
tszgg/python_exercise
/exercise1_done.py
835
3.953125
4
""" Give the data, construct a dictionary in this format: output = { 'Biology': ['Alice', 'David'], 'Chemistry': ['Alice'], ... } """ data = { 'Alice': 'Biology, Maths, Chemistry', 'Bob': 'Maths, English,Physics', 'Charlie': 'Maths', 'David': 'Biology,Chinese' } trim_data={} for k, v in d...
ada93d2cb8c5c0680dd69bc2ef663c312696405e
Lleafll/alternativeclocks
/decimalclock.py
557
3.515625
4
from clock import Clock DH_IN_D = 10 # DH = decmial hour MS_IN_D = 24 * 60 * 60 * 1000 MS_IN_DH = MS_IN_D // DH_IN_D MS_IN_DM = MS_IN_DH // 100 # DM = decimal minute MS_IN_DS = MS_IN_DM // 100 # DS = decimal second class DecimalClock(Clock): def name(self) -> str: return "Decimal Clock" def forma...
6ca7da5ad65dd8a9f4456ff0f51c3df0db4cb1a8
hemant110800/Algorithms-Implementation
/dynamicprg_diffbw_files.py
3,318
4.375
4
''' Consider two files having the following data: File1: "ACA" File2: "ADCE" To find the difference between these two files: Find the longest sequence of characters present in both the files. This is a classic problem which can be solved using dynamic programming technique. Longest common subsequence (LCS)...
33bc0eae3c2a89d7e8aaac6bedf3dd8250c5ce6a
kimberlymartin/Lab-7
/Python Lab 7 While Loops.py
655
3.765625
4
#25pt number = 1 while number < 300: print number number = number + 2 #50pt theList = ['hey',2,3,67,'python',5,100,'october',434,'tuesday',5,2,4] index = 0 while index < len(theList): print theList[index] index = index + 1 #100pt import random rand = random.randint(0,50) guess = False while gu...
9b16a7bb9c72a895731bdc0cde7d0a66731fd2f4
younkyounghwan/python
/baekjoon_1978.py
329
3.703125
4
x = int(input()) l = input().split() sum = 0 def is_prime(x): p=1 count = 0 if (x == 1): return count while(1): p += 1 if (x==p): count+=1 break if (x%p==0): break return count for i in range(0,x): sum += is_prime(int(l[i])) p...
eb5af17fd6f6a7f37cebe81de5fd987a08d4eaea
younkyounghwan/python
/baekjoon_2902.py
57
3.546875
4
x = input().split("-") for i in x: print(i[0],end="")
1bb78cd6e95b9c461add6d542edadadd17b8bd84
younkyounghwan/python
/baekjoon_2083.py
245
3.734375
4
l = [] while(1): x = input().split() if x[0] == "#": break l.append(x) for i in range(0,len(l)): if int(l[i][1]) > 17 or int(l[i][2]) >= 80: print(l[i][0] + " Senior") else: print(l[i][0] + " Junior")
12b236e9c1329a722fd28ba303f4b8f642e6c506
younkyounghwan/python
/baekjoon_2741.py
88
3.53125
4
x = input() x= int(x) i=1 while(1): print(i) if (i==x): break i+=1
4151314d0cf75cf918ae42716f9d548d272e070b
younkyounghwan/python
/baekjoon_2742.py
82
3.5
4
x = input() x= int(x) while(1): print(x) if (x==1): break x-=1
c9d73c5ddd503a6bad64d5523348640a704dbd2e
younkyounghwan/python
/baekjoon_10822.py
88
3.59375
4
x = input().split(",") sum = 0 for i in range(0,len(x)): sum += int(x[i]) print(sum)
9405440205b847480e175664c20f15eb98ba2b43
younkyounghwan/python
/baekjoon_practice.py
119
3.6875
4
x,y=input().split() x = x[::-1] y = y[::-1] x = int(x) y = int(y) if (x>=y): s=str(x) else: s=str(y) print(s)
50ef24354b6c30ccfa33a3449bb35c1baa08e2f3
zhou-yi-git/PAT
/BasicLevel/1021 个位数统计.py
299
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019-03-13 10:36 # @Author : zhou # @File : 1021 个位数统计 # @Software: PyCharm # @Description: a = input() dic = {} for i in a: dic[i] = str(a.count(i)) result = sorted(dic.items()) for i in result: print(':'.join(i))
c5aaaeb83efc32af8ca3ea5863422324b425056d
zhou-yi-git/PAT
/实验4/1856学生信息排序.py
1,597
3.625
4
#!/anaconda3/bin/python # @Time : 2019-04-04 12:48 # @Author : zhou # @File : 1856学生信息排序 # @Software: PyCharm # @Description: class Student: """学生类""" def __init__(self, id, name, sex, chinese, math, english): self.__id = id self.__name = name self.__sex = sex self.__c...
9afc9bb6e072c408030a53e0aa71c5c6cb7da568
zhou-yi-git/PAT
/实验4/2001学生信息输入.py
3,030
3.71875
4
#!/anaconda3/bin/python # @Time : 2019-04-04 00:19 # @Author : zhou # @File : 2001学生信息输入 # @Software: PyCharm # @Description: class Student: """学生类""" def __init__(self, id, name, sex, year, month, day, x, y, z): self.__id = id self.__name = name self.__sex = sex self....
5b2f412b73d3f3bbec8a56dc6bcf3c06dcff9224
aaabhilash97/Problem-Solving-with-Algorithms-and-Data-Structures
/recursion/fibonacci.py
188
3.53125
4
def fib(n,res=[0,1]): if n==0: return [0] if n==1: return [0,1] if len(res)-1==n: return res else: res.append(res[len(res)-1]+res[len(res)-2]) return fib(n,res) print fib(6)
2c52ad531a2ef3b7334ffc8c0e1882e6468f1b60
ValeriaLco/Python-Class
/Tareas/idk.py
169
3.859375
4
a = int(input("give me a number: ")) b = int(input("give me a number: ")) i = a while i <= b: if i % 2 == 0: print(i) i += 2 continue i += 1
1b89dfdd7995bc8fb0e0af59d704123fcfeedee7
ValeriaLco/Python-Class
/Tareas/type_triangle.py
1,143
4.375
4
# type_triangle.py # This programs tells you the type of triangle you have based on given lenghts. It validates the lenghts and if they # are not, the program tells the user so. # Written by Valeria Lucio # a01411381@itesm.mx # Date: August 23th 2019 # Last revision: August 23th 2019 # I first ask the user for side...
7395d77164d973744c9db286c6d68906a111388e
ValeriaLco/Python-Class
/Ejercicios/Divisions.py
1,927
3.953125
4
def Division(): points = 0 questions = 0 print('KANJAY MATH: Well a brief explanation, you will be given 5 problems, at the end, you will be told your score.') print('') print('¿Qué fracción del total es la mitad de una tercera cuarta parte?') questions += 1 print('') print('1. (1/2) 2...
4727d2360a5204923cfaf123dcbafcdad14a2869
ValeriaLco/Python-Class
/Tareas/diagonal.py
615
4.21875
4
# diagonal.py # This programs calculates the value of the diagonal of any rectangle. # Written by Valeria Lucio # a01411381@itesm.mx # Date: August 21th 2019 # Last revision: August 21th 2019 import math # First I ask the user for the lenght and the width of the rectangle. l = float(input()) w = float(input()) # ...
96e7424de515fdb1c687f2ab9d7ff2b383034e7d
ValeriaLco/Python-Class
/Ejercicios/Strings/string_fragments.py
353
4.15625
4
#string_fragments.py # This is a program that reads a string and shows fragments of such string. def string_fragments(string): print(len(string)) print(string[0]) print(string[-1]) for index in range(len(string)): if index % 2 != 0: print(string[index], end='') string =...
0b3d5e670cc7193de73913cf8356d055388946cb
msr-fiddle/pipedream
/profiler/image_classification/utils/all_reduce/extract_reduce_times.py
1,816
3.5
4
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import argparse def process_file(filename): with open(filename, 'r') as f: lines = [] earliest_start_time = {} latest_end_time = {} for line in f: lines.append(line) line = line.strip(...
0a35936af0108dd4bafb1af734c57f04a17e8c49
horeaNicolae/python_training
/ica/exercitii.py
1,750
4.25
4
#!/usr/bin/env python def printNumarInvers(): numar = int(input("Introduceti numarul:")) listaCifre = [] #ultima cifra dintr-un numar e restul impartirii numarului la 10 #ex. 951 / 10 = 95 rest 1 => 1 ii ultima cifra #aflam ultima cifra, o punem intr-o lista, si o taiem din numarul initial ...