blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
3966c5e5e1951e694ab0c4655ffce657ea471055
ignacioParraCajal/probandoGit
/main.py
578
3.75
4
#calcular el porcentaje de tiempo que lleva viva una persona segun su edad def calculadorEdadPorcentual(): edad = int(input("ingrese edad: ")) promedioDeVida = int(input("Promedio de años de vida: ")) calculo = (edad/promedioDeVida) * 100 redondeo = round(calculo) print(f"{redondeo}% de tiempo viv...
1565c2219a95ec932063124361af62c0c4bf2a70
arun-bhadouriya/100daysOfPython
/Day02/tipCalculator.py
605
4.21875
4
print("Welcome to Tip Calculator") total_bill = float(input("What is the Total Bill? $")) total_person = float(input("Ho many people to split the bill? ")) percent = float(input("What Percentage tip you would like to give? 10,12, or 15? ")) # Calculation for the tip and the share each person will pay each_person_pay ...
1eac0aa88454812ee24184c9e133f90afd8f5437
Mazev/Python-Advance
/06.Exercise Tuples and Sets/01. Unique Usernames.py
214
3.5625
4
def input_to_list(count): lines = [] for _ in range(count): lines.append(input()) return lines num = int(input()) result = input_to_list(num) result = set(result) for i in result: print(i)
df4508f24f81c9c15bede056dc6a87d1d3b19b86
Bongkot-Kladklaen/Programming_tutorial_code
/Python/Matplotlib/ep6_bars.py
342
3.515625
4
import matplotlib.pyplot as plt import numpy as np ''' #? การพล็อตกราฟแท่ง #? แสดงกราฟแนวนอนด้วย plt.bart() #? ปรับขนาดด้วย parameter width=0.1 ''' x = np.array(["A", "B", "C", "D"]) y = np.array([3, 8, 1, 10]) plt.bar(x,y) plt.show()
cd6747c2cbd96116fff75d0306d719dbfc4c386d
wuchaowei2012/movie-recommend
/extract.py
1,950
3.5625
4
""" The data, in form of 100k records has to be extracted and formed into a user vs movie rating matrix and user vs watched movie list The initial record user id, movie id, rating, timestamp are read and stored in a list of lists - records 943 users and 1682 movies The first one is a matrix so its a list of lists use...
0ba3f94a356af564b05a3acff24e46f6353446f8
vini52/Exercicios_PI_Python
/ece/lista1/lista1_4.py
265
3.65625
4
frase = input() alfabeto = 'abcdefghijklmnopqrstuvwxyz' cont = 0 frase = frase.lower() for letra in alfabeto: for caracter in frase: if letra == caracter: cont += 1 break if cont == 26: print('SIM') else: print('NAO')
0069c4decce40af702b3549106a63c49a65f9233
ReedJessen/CodeEval
/PrimePalindrome.py
251
3.828125
4
def is_palindrome(x): y = int(str(x)[::-1]) return x == y def is_prime(x): return x > 1 and all(x % i for i in xrange(2, x)) for i in range(1000,-1,-1): if is_palindrome(i) and is_prime(i): print i break
9abf9284c1a81293271c9c06c3dbfc3738b29144
YaroslavBkh/python_stuff
/pig_latin, any().py
397
3.9375
4
def has_numbers(word): return any(char.isdigit() for char in word) def pig_latin(word): """Returns a simplified Pig Latin version of received word""" if has_numbers(word): print("Pig Latin doesn't work numbers, sorry") elif word[0] in ('e','a','i','o','u'): print("{}way".format(word)) ...
07a3c4110629c6467e953005d92a4e0bddb64542
keyu-lai/cs61a
/lab/lab04_extra.py
1,544
4.1875
4
from lab04 import * # Q5 def reverse_iter(lst): """Returns the reverse of the given list. >>> reverse_iter([1, 2, 3, 4]) [4, 3, 2, 1] """ "*** YOUR CODE HERE ***" assert type(lst) == list, "lst must be a list" re = [] for item in lst: re = [item] + re return re def reverse...
cb81bdd06689007dd321e8e8d463381ed1685d82
tartakynov/sandbox
/basic-algorithms/dijkstra.py
1,143
3.796875
4
#!/usr/bin/env python def shortest_path(adjacency, vertices, a, b): n = len(adjacency) start, finish = vertices.index(a), vertices.index(b) unvisited = range(n) parents = [0] * n distances = [1000000] * n distances[start] = 0 u_prev = -1 while unvisited: u = unvisited[0] ...
003e5826f3928d22d73160bc247526fd09f1efb1
zhukaijun0629/Coursera_Algorithms
/Course #3/PA #3-4/knapsack1.py
821
3.65625
4
def knapsack(items,num,size): cache = [[],[]] for k in range(0,size+1): cache[0].append(0) cache[1].append(0) for i in range(1,num+1): for k in range(1,size+1): if k < items[i][1]: cache[1][k] = cache[0][k] else: cache[1][k] = m...
98136947ef4a2861256d9a1e56a8c86695edaf77
frankylamps/python-project-lvl1
/brain_games/games/calc.py
408
3.734375
4
import random from operator import add, mul, sub RULES = 'What is the result of the expression?' def start_round(): num1 = random.randint(10, 15) num2 = random.randint(1, 5) function, symbol = random.choice([ (add, '+'), (mul, '*'), (sub, '-'), ]) question = ('{} {} {}'.fo...
fef0fc9c25492938e16183c6f6ee61463e766d01
bhirbec/interview-preparation
/CTCI/8.5.py
276
3.84375
4
# Note: I used the first two hints to solve this problem def multiply(a, b): if b == 1: return a s = multiply(a, b >> 1) << 1 if b & 1: s += a return s def main(): a = 123 b = 123312 print multiply(a, b) print a * b main()
fa8dc3f159af7c617e96f7d8e97711e79c240a45
Yucheng7713/CodingPracticeByYuch
/Practice/stringPermutation.py
292
3.890625
4
def stringPermutation(p_str): def permutation(prefix, remain): if not remain: print(prefix) for i in range(len(remain)): permutation(prefix + remain[i], remain[:i] + remain[i+1:]) permutation("", p_str) p_str = "abc" stringPermutation(p_str)
560a8ee167acb875f0c6754dd082b46faf383b48
NikoleiAdvani/breakout
/ball.py
1,368
4
4
# Nikolei Advani, 12/16/2016 # This class creates the ball import pygame import random class Ball(pygame.sprite.Sprite): def __init__(self, color, windowWidth, windowHeight): super().__init__() self.RADIUS = 10 self.color = color self.windowWidth = windowWidth self.windowHe...
bc8cee3f1a680e1580dc7bbf8c2e93509f77e3bb
EmineKala/Python-101
/Python/Hafta4/alistirma6.py
619
3.90625
4
#Tüm kullanıcı adlarını ve şifreleri takip eden users adında sözlüğe dayanarak bir kullanıcı adı ve şifrenin doğru olup olmadığını kontrol eden bir fonksiyon yazın. #Fonksiyonunuz, verilen kullanıcı adı ve şifrenin doğru olup olmadığına bağlı olarak True veya False dönmelidir. users = dict() users["eminekala"] = "123...
aadb11ead55cca52257df4dadd6c6d2ae9fcb859
RonakAthos/Python-WorkSapce
/helloworld.py
444
4.0625
4
string1 = "hello" string2 = "king" #list example my_list = ["world", "war", "writen"] my_list.append("working") print(my_list) print(len(my_list)) #Dictionaries example my_dict = {'key1': 100, 'key2':200} print(my_dict) my_dict.items() my_dict['key3'] = {'k1':1, 'k2' : 2, 'k3': 3} print(my_dict['key...
cd39672b84f454cf65774ea4f5b9f4d99ef8a959
mylgcs/python
/训练营day01/05_for.py
271
3.984375
4
# 打印5个"我也很帅" for i in range(5): print("我也很帅") # 从1 打印到 20 for i in range(1, 21): print(i) # 从20打到1 for i in range(20, 0, -1): print(i) # break和continue for i in range(1, 21): if i == 15: break print(i)
7defed8f5c16c0656b1f764aac655220ec57b3f0
Nain08/Python-Codes
/palindrome.py
221
4.125
4
#palindrome sum=0 num=int(input("Enter a number")) numcopy=num while numcopy>0: sum=sum*10 sum=sum+(numcopy%10) numcopy=numcopy//10 if num==sum: print("Palindrome") else: print("Not Palindrome")
23a5ed49ae7de044c3dc105dc1b5474c56d61e82
jolovillanueva47/coding-problems
/binarygap.py
659
3.59375
4
#About def binarygap(num): binaryForm="{0:b}".format(num) indices = [i for i, x in enumerate(binaryForm) if x == "1"] if(len(indices)<=1): return 0 else: currentLargestGap=0 largestGap=0 for index, obj in enumerate(indices): try: largestGap=ind...
23b915c36e24e404de63cd1ff223dd4adf9a97e8
xytracy/python
/ex4.py
585
3.828125
4
cars=100 space_in_a_car=4.0 drivers=30 passengers=90 cars_not_driven=cars-drivers cars_driven=drivers carpool_capacity=cars_driven*space_in_a_car average_passengers_per_car=passengers/cars_driven #give values to the variables print"there are",cars,"cars available." print"there are only",drivers,"drivers ava...
622cf66419efa55057b1d9d6e64834698a9be7d6
chijuzipi/Interview-Prep
/amazon/spiral.py
1,716
3.59375
4
''' spiral order visit of a matrix -->two method --> corner case: 1) nums 2) only one element? ''' def spiral(nums): if not nums or len(nums) == 0 or len(nums[0]) == 0: return [] h = len(nums) w = len(nums[0]) total = h * w res = [] res.append(nums[0][0]) i = 0 j = 0 layer...
b6d76d17dd13eeaf274ae0589ad98253e96f8cb1
Aadhya-Solution/PythonExample
/for_examples/for_prime_n_m.py
167
3.734375
4
n,m=input("Enter N,M:") for i in range(n,m+1): flag=True for j in range(2,i): if i%j==0: flag=False if flag: print("Prime:",i)
8842421c3a352fc3d5ccfd0212c14cff6904777b
ByronHsu/leetcode
/python/543-diameter-of-binary-tree.py
595
3.765625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def dfs(self, root): if root == None: return 0 L, R = self.dfs(root.left) + 1, self.dfs(root.right) + 1 self.ans ...
39f98276f730686b245937b04ace0377ed831df7
Nishadguru/python-sample1
/6th.py
65
3.9375
4
num = int(input("enter the number")) sum = 0 sum+=num print(num)
a60d492766c1462c3e445e577a9a724073d50fdf
flaviasilvaa/ProgramPython
/22.AnalysingText.py
739
4.34375
4
#this program is going to ask a user to type their full name and the program is going to show the name in upper case and lower case #how many letters in their name and how many letters the user have in their first name name = str(input("Type insert your name?\n")).strip() print('-=-'*30,'Analysing your name') print(f'Y...
babe30d24fb47737744647e904725a5ca4c5433d
yestemir/web
/week8/codingbat/string2.py
800
3.8125
4
# 1 def double_char(str): ans = "" for char in str: ans += 2 * char return ans # 2 def count_hi(str): return str.count('hi') # 3 def cat_dog(str): cat = str.count('cat') dog = str.count('dog') if cat == dog: return True else: return False # 4 def count_code(str): result = 0 for i in range(len(str...
004f62538e027529268b88a947153281bcfb21d9
venkii83/DE-Python
/Master_Bank.py
3,688
4.375
4
class Customers: def __init__(self, firstname, lastname, age, gender): """Create __init__() method with name, age & gender of the customer""" self.name = name = "" self.age = age self.gender = gender def show_details(self): print("Customer details") print("") ...
96a7a25e2e724f70ae9d30b78bb216a867f9e44f
Harsh-Agarwals/python-turtle-module-projects
/Colored Hexagon/coloredHexagon.py
251
3.671875
4
import turtle color = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo'] turtle.bgcolor('black') for x in range(360): turtle.pencolor(color[x % 6]) turtle.width(x/100 + 1) turtle.forward(x) turtle.left(59) turtle.done()
ccd411dfb8db1bcca4fbcde4b5309e255051dd14
supria68/ProjectEuler
/python/prime_permutations.py
1,256
3.546875
4
""" EP - 49 The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are permutations of one another. There are no arithmetic sequences made up of three 1-, 2-, or 3-digit primes, exhib...
190304092bb20976662120844ccbbf6e694fa1fb
Balde641/TkInter
/Osat0--11/OSA PROJEKTI2.py
273
4.15625
4
from tkinter import * root = Tk() # We are creating label widget myLabel1 = Label(root, text="Hello World") myLabel2 = Label(root, text="My name is Balde") # We are showing it onto the screen myLabel1.grid(row=0, column=0) myLabel2.grid(row=1, column=1) root.mainloop()
032af1c8a7fa60272a8487c560973642283eef2e
kryskaliska/KurcheuskayaLiza
/Homework/MultiplayerBMI.py
30,538
4.0625
4
d = dict() z = 0 while z <= 10: print('Введите Ваше имя: ') name = input() if name == 'end': break elif name in d: print('Ваши данные', d[name]) else: pol = input('Введите Ваш пол (муж или жен) ') vozr = int(input('Введите Ваш возраст (полных лет) ')) ves = in...
53db0dce8f7a24c3d490db5e66d590168b7ea01d
parxhall/com404
/1-basics/3-decision/11-review/bot.py
1,028
4.3125
4
#ask for input direction = input("Which way should we run?\n") #if statement if direction == "left": #input action = input("There is a branch in the way what should we do?\n") #nested if statement if action == "jump": print("Yes we made it over!") elif action =="go round": print("We ...
9293dec395810d8c32305b9ca862f09a045d6616
Naveenkota55/maze_test
/test_2.py
2,966
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Apr 28 00:10:55 2020 @author: naveenkota """ import turtle wn=turtle.Screen(); wn.bgcolor("white"); wn.setup(700,700); wn.title("Maze 2"); class Marker(turtle.Turtle): def __init__(self): turtle.Turtle.__init__(self) self.color("b...
3b0b8161abc02dcd9a68dcafbe0405fc3e364ddc
SanGlebovskii/lesson_5
/homework_5_4.py
164
3.8125
4
n = int(input()) def sum_of_n(number) -> int: summary = 0 for i in range(1, number + 1): summary += 1 / i return summary print(sum_of_n(n))
1d546ea8d170fc0c62002293aa16e216708943ef
IceAge0/hello-world
/GUI_for_py/TryMainWindow.py
737
3.578125
4
from tkinter import * class MainWindow: def __init__(self): self.frame=Tk() self.label_name = Label(self.frame,text='name:') self.label_age = Label(self.frame,text='age:') self.label_sex = Label(self.frame,text='sex:') self.text_name = Text(self.frame,height='1',width=30) self.text_age = Text...
4b47cd1d45c5a4a1a5587b8f14d48b896eab145b
vc2309/interview_prep
/dp/knapsack.py
515
3.796875
4
def knapsack(W, weights, values): K={w:v for w,v in zip(weights,values)} for i in range(W+1): max_weight=0 for j,wi in enumerate(weights): if wi <=i: rem_val=K.get(i-wi) if K.get(i-wi) else 0 max_weight=max(rem_val+wi,rem_val) K[i]=max_weight return K[W] def main(): weights=[2,2,3,4] values=[10,4...
f122116a725b6cd0776182155202b4b64c4edd4d
rperezl-dev/S1-TAREA1-POO
/Ejemplo 4.py
649
4
4
#Ejemplo 4 #Construir un algoritmo tal, que dado como dato la calificación de un alumno en un examen, presente un alumno aprueba # si la calificación es mayor o igual que 7 class Examen(): def __init__(self): self.calificacion=float def calificacion_exam(self): try: calificacion = ...
9a4882b0f8d534283008bee7da063a8f791a7d6d
MadisMaisalu/prog_alused_vs20
/otsast peale/yl2/yl3.py
2,077
3.71875
4
vanus = int(input("Sisestage enda vanus: ")) while vanus >= 150: # vanuse limiidiks on 150 vanus = int(input("Viga! Proovige uuesti: ")) # veateade kui on üle 150 sugu = input("Sisestage enda sugu (Mees/Naine): ") while (sugu !="Mees") or (sugu !="Naine"): # veateade kui pole Mees või Naine !!!!SIIN ON MINGI ...
28e0f23c9eecd1302ca6ffd7d7161b66a0e893c2
tapanprakasht/Simple-Python-Programs
/str1.py
243
3.734375
4
#!/usr/bin/python3 class Palindrome: def __init__(self): self.string="" self.length def getString(self): self.string=input("Enter the string:")) self.length=len(self.string) def findPalindrome(self): temp=self.length
a2f729047406e1550433844dcb8834da77eb3a5c
mukishrita/-rita-final-week-BC-UG
/test_cases/dojo_test.py
1,489
3.609375
4
import unittest from class_models.the_dojo import Dojo class TestCreateRoom(unittest.TestCase): """Dojo allocates rooms to staff and fellow""" def test_create_room_successfully(self): dojo_instance = Dojo() initial_room_count = len(dojo_instance.list_rooms) blue_office = doj...
db401e9f7d3daf566325c896d749779f63d4047c
aadarshraj4321/Python-Small-Programs-And-Algorithms
/Data Structure Problems/dictionary/search_element_dict.py
256
4.09375
4
myDict = {"name": "Elon Musk", "age": 45, "year": 2021} def searchDict(dictionary, value): for key in dictionary: if(dictionary[key] == value): return [key, value] return [] print(searchDict(myDict, 2021))
1beb2568dea5f30e8ee3ca31c2c4d08d9c3a038b
Ahmad-Omar-Ahsan/Python_tutorials
/Exercise/polygon.py
1,734
4.25
4
import TurtleWorld import math as m world = TurtleWorld.TurtleWorld() bob = TurtleWorld.Turtle() print(bob) """ for i in range(4): print ('Hello!') for num in range(4): fd(bob, 100) rt(bob) """ def square(t, length): """ Draw a square with sides of given length :param t: :param length: :ret...
420e99b8201ca9461cfcea344d0adf0f430096b0
Orusake/Guess_a_number
/GameEngine.py
1,736
4.4375
4
# Drawing Functions # the Drawing Functions are only used to draw function, not used to change values! They only display them. # Add colors # https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-python class bcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARN...
5b8166afdd457a1d27a3f48f05b788667cec22aa
hung1451020115/1451020115
/songuyento.py
312
3.734375
4
print("nhap vao 1 so") a = int(input()) if a < 2: print("a không là số nguyên tố") if (a == 2): print(a,"là số nguyên tố") else: for i in range(3,n,1): if (n % i ==0):2 print("a không là số nguyên tố") else: print("a là số nguyên tố")
5df7f91c9b8426ef1fc05777c2353afaad99fdc3
varshavasthavi/SummerProjects18
/RE-Cryptography/Sessions-5-&-6/VarunKM/VarunKM-caesar_encryption.py
876
3.609375
4
f1 = open("VarunKM-message-caesar.txt","r") # open file1 f2 = open("VarunKM-caesar_ciphertext.txt","w+") while True: char = f1.read(1) # read char by char from file1 if not char: # break when endoffile is reached break else: ...
2448a0727775c5e99f195aeb5c592277b50446c7
crazyguy106/cfclinux
/steven/python/personal_workshop/loops/loop_dictionary.py
242
4.1875
4
#!/usr/bin/python3 dictionary = {'first': 1, 'second': 2, 'third': 3} print('keys', dictionary.keys()) print('values', dictionary.values()) print('items', dictionary.items()) for key, value in dictionary.items(): print(key) print(value)
99caa3c41e5c422ecd0296c09ea9b06960a7a07b
dyeap-zz/CS_Practice
/Facebook/Sliding Window/LongestSubstringKChar.py
1,107
3.6875
4
''' detect unique characters start L/R beginning move R pointer up until k+1 unique char. longest = l+R-1 move L pointer until k unique char var- num_unique_char dictionary to keep track of num off occ 0 to 1 num_unique_char + 1 1 to 0 num_unique_char - 1 while r<len update r if num_uni == k: ...
c04b11fab70c49aae7815dd1ac2fa27a75eee8e6
ajaymore/python-lang
/F03_data_structures.py
2,581
3.671875
4
__author__ = 'Mystique' # Queue from collections import deque queue = deque(['Eric', 'john', 'Michael']) queue.append('Terry') queue.append('Graham') queue.popleft() queue.popleft() print(queue) # List Comprehensions squares = list(map(lambda x: x ** 2, range(10))) squares1 = [x ** 2 for x in range(10)] pairs = [(x,...
2cbd81c64e374d23c08a4f2e4d036570a3a9410a
unsortedtosorted/FastePrep
/Trees/delete_zero_sum_subtree.py
941
3.8125
4
""" Delete Zero Sum Sub-Trees Given the root of a binary tree, delete any subtrees whose nodes sum up to zero. 1. delete_zero_sum_subtree left sub tree 2. delete_zero_sum_subtree right sub tree 3. return root.val + left subtree sum +right subtree sum Runtime : O(N) Memory : O(h) Recursive solution has O(h) memory ...
8b0f0aa35bcdc645924dcc76ae43dbd7fc5d2ef9
ivklisurova/SoftUni_Fundamentals_module
/Basic_Syntax_Conditional_Statements_Loops/Double_Char.py
104
4
4
word = input() double_word = '' for letter in word: double_word += letter * 2 print(double_word)
6ce2e284d8e874017b13957f0cd86a044f8d1788
linhye04/python_calc
/My Calculator.py
786
3.609375
4
from tkinter import* window=Tk() window.title("My Calculator") display=Entry(window, width=33, bg="pink") display.grid(row=0, column=0, columnspan=5) button_list=[ '7', '8', '9', '/', 'C', '4', '5', '6', '*', '%', '1', '2', '3', '-', '//', '0', '.', "=", '+', ''] def click(key): if key=="=": ...
0990e4bf6104e5578129c70402f784e58ace9503
chimble/what-to-watch
/movie_lib3.py
1,075
3.75
4
import csv class Movie(): def __init__(self, movie_id, movie_name): self.movie_id = movie_id self.movie_name = movie_name def get_name(self, movie_id): #return movie name given ID return self.movie_name #print(movie.get_name('1')) def movie_data(): with open('u.item....
51e27f6b75e1b05d8b3e104c5461091904689a0c
BlairWu/python_pycharm
/structure.py
9,377
4.15625
4
#!/usr/bin/python3 print("=============== 列表 ================") """ Python中列表是可变的,这是它区别于字符串和元组的最重要的特点, 一句话概括即:列表可以修改,而字符串和元组不能。 方法 描述 list.append(x) 把一个元素添加到列表的结尾,相当于 a[len(a):] = [x]。 list.extend(L) 通过添加指定列表的所有元素来扩充列表,相当于 a[len(a):] = L。 list.insert(i, x) 在指定位置插入一个元素。第一个参数是准备插入到其前面的那个元素的索...
496c14038cf08bdb986940afa273993e4d50f497
chinweeee/Data-science-SCA-path-projects
/week3.py
1,891
4.375
4
# SCA PROJECT # 3RD WEEK PROJECT #Exercise 1: Write a Python program to get the largest and lowest numbers from a list list1 = [21,43,24,555,12,859] print(max(list1)) print(min(list1)) #Exercise 2: Create a dictionary with the names and birthdays of at least five people. write a program that displays a person's bir...
8ce1a63b196ccc14cf47b6e1c9b1ce62cf754a63
jinnovation/JJinProjectEuler
/pe52.py
375
3.59375
4
def digits(n): return sorted(set(map(int,str(n)))) def same_digits(n1,n2): if digits(n1)==digits(n2): return True else: return False def trial(n): # problem-specific test case return same_digits(n,2*n) and same_digits(n,3*n) and same_digits(n,4*n) and same_digits(n,5*n) and same_digits...
27a1dfdda26c1d861aecb51339b54b33819caba7
adx505602196/store
/day03/输入54321求执行结果.py
117
3.84375
4
num=int(input("请输入一个数:")) while num != 0: print(num % 10) num=num//10 #''' #1 #2 #3 #4 #5 #'''
ba646f2068832e185fa87939106c5bd988016a1a
trashcluster/LeBezvoet
/TD20181012_STECIUK-Axel.py
858
3.75
4
#TD6 #Somme de 2 dés à n faces from random import * from math import * def nfaces(n) : return(int(n*random()+1)) nbfaces=int(input("Entrez le nombre de faces : ")) print(nfaces(nbfaces)) print(nfaces(nbfaces)) #Distances #Demandes les coordonnés de 3 points à l'utilisateur et affiche la distance entre ces point...
d29bde11eed907bb1990091c83215b5fda82063c
a13835614623/myPythonLearning
/01_python_basic/06_循环.py
342
3.796875
4
''' Created on 2018年11月2日 循环 @author: zzk ''' names = ['Michael', 'Bob', 'Tracy'] for name in names: print(name) # 计算1-100 # range()函数,生成一个整数序列 # range(5),生成的是[0,1,2,3,4] sum=0 for x in range(101): sum+=x print(sum) ''' while循环 ''' n=0 sum=0 while n<=100: sum+=n n+=1 print(sum)
2a6fe015fdf99ddcdbc4841072fb564d91de5a12
ArdaCet/Codewars-Repo
/Python_solutions/Replace With Alphabet Position.py
591
3.859375
4
def alphabet_position(text): #alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] alphabet_string = string.ascii_lowercase alphabet = list(alphabet_string) alph_dict = {} output = [] for values, keys in enumerate(alphabet...
a49f52df00e0745de6de8a8e4134b75f41596a1c
giovannyCaluna/Amortizacion-Francesa
/calculator.py
808
3.515625
4
class Bank: def __init__ (self, name, anualRate,comision): self.name = name self.anualRate = anualRate self.monthlyRate = (anualRate/100)/12 self.comision = comision def feeCalculator (self, capital,n): return round(capital*((self.monthlyRate*(1+self.monthlyRate)**n)/((...
4afacfce8380392bb51f2aef067d53fd52e607e6
Akashdeepsingh1/project
/LeetcodeRandom/3sum.py
3,100
3.625
4
def sum3(nums): l = len(nums) s= [] if l>2: for i in range(l): for j in range(i+1,l): for k in range(j+1,l): if nums[i]+nums[j]+nums[k] == 0: temp = [nums[i],nums[j],nums[k]] temp.sort() ...
7735a1f53fe4cbe68a6a5608247d2762f9151e06
likhi-23/DSA-Algorithms
/Searching/linear_search.py
208
3.796875
4
#Linear Search a = list(map(int,input().split())) val = int(input("Enter the search value:")) i = 0 while(i<len(a)): if a[i] == val: print(i) break i+=1 if i >= len(a): print("Value not found")
98712f1cf0721d179462b3b3713d223e72ade214
tkp75/studyNotes
/learn-python-from-scratch/function8.py
223
4.28125
4
#!/usr/bin/env python3 num = 20 def multiply_by_10(n): n *= 10 num = n # Changing the value inside the function print (num) return n multiply_by_10(num) print (num) # The original value remains unchanged
f7978623646fc96d7620b3b598a94c60d6dc54ee
LennonHG/ATMClicks.py
/source_code.py
705
3.5
4
# ATM by Lennon class ATM: def __init__(self, name, password, saveword): self.name = name self.password = password self.saveword = saveword def get_password(self): return self.password def get_saveword(self): return self.saveword print("Welco...
3a54f5a884746c02b28fc6128898966077f5f4e3
VAR-solutions/Algorithms
/Sorting/Insertion Sort/Python/insertion_sort_recursively.py
525
3.96875
4
# Author Shubham Bindal def insertion_sort(array,n): # base case if n<=1: return insertion_sort(array,n-1) last = array[n-1] j = n-2 while (j>=0 and array[j]>last): array[j+1] = array[j] j = j-1 array[j+1]=last def print_arrayay(ar...
90e08ac5bbe1a160c09497abfb2b67231dc50c68
priyankaparikh/recursion-dynamicprogramming
/add_two_numbers.py
1,376
3.953125
4
# You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. # # You may assume the two numbers do not contain any leading zero, except the number 0 itself. # ...
ac8abb168d5e4cda5ac7678ac50f602fd2c4f8c9
Kane4299/PIR
/justeprix.py
2,408
3.8125
4
import random import time import tkinter as tk def countdown(t): while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\n") time.sleep(1) t = t - 1 return t #Set the game's rule def game(event=None):...
d7d462ff5de9012c32f0612107ede4047eea3c2c
yuju13488/pyworkspace
/m5_str/method_is.py
890
3.796875
4
s1='yoyo' s2='0413' s3='yoyo0413' print(s1.isalnum()) #判斷是否由字串或數字組成 print(s2.isalnum()) print(s3.isalnum()) print(s1.isalpha()) #判斷是否由純字串組成 print(s2.isalpha()) print(s3.isalpha()) print(s1.isdigit()) #判斷是否由純數字組成 print(s2.isdigit()) print(s3.isdigit()) print("--------------------") #判斷識別字(須為字母、數字、底線,不可數字開頭,需區分大小寫,不限長度)...
f86996d1e48f47fcf65695bf912c560e51ee4350
zietzm/xswap
/xswap/network_formats.py
2,883
3.765625
4
from typing import List, Tuple, TypeVar import numpy import scipy.sparse def matrix_to_edges(matrix: numpy.ndarray, include_reverse_edges: bool=True): """ Convert (bi)adjacency matrix to an edge list. Inverse of `edges_to_matrix`. Parameters ---------- matrix : numpy.ndarray Adjacency ma...
efafb58f3554342658e325eb46c6dd27203acf46
hansleo/TopicModel_test
/doc_similarity/fileio.py
352
3.640625
4
def read_file(path): file = open(path, 'r', encoding = 'utf-8') contents = '' while True: line = file.readline() if (not line): break contents += line return contents def write_file(path, dict): file = open(path, 'w', encoding = 'utf-8') for k, v in dict.items(): text = str(k) + ',' + str(v) + '\n' ...
3db8b4c7b8b29af6ef71bbd537b8dc9fb80bb07a
yecong14/shiyan
/matrix.py
629
3.65625
4
#!/usr/bin/env python3 import numpy as np def file2matrix(filename): fr = open(filename) array = fr.readlines() numberoflines = len(array) matrix = np.zeros((numberoflines,3)) label = [] index = 0 for i in array: line = i.strip() list = line.split() matrix[index,:] = list[0:3] label.append(i...
ce4b05993f30b73700d090ad7aec97410d158d6f
khollbach/euler
/1_50/24/euler.py
740
3.734375
4
#!/usr/bin/python3 from utils import * import math def main(): print(nth_perm(999999, list(range(10)))) def nth_perm(n, l): ''' n starts from 0. ''' print(n, l) if n < 0: print('n < 0') return None if n >= math.factorial(len(l)): print('n too large') retu...
0e6259fbc955f7a27bd10bd7fe492efc6e22450a
ChangedNameTo/AdventOfCode2019
/2/opcode.py
2,749
3.671875
4
from tests import test_cases def read_frame(index, program): opcode = program[index] # Halt if opcode == 99: return False position_1 = program[index + 1] position_2 = program[index + 2] position_3 = program[index + 3] # Add if opcode == 1: program[position_3] = progra...
c0cdbc44d6c51d7e4d4c22e4fd95bbc0123e1bb1
jabbalaci/Bash-Utils
/here.py
633
3.75
4
#!/usr/bin/env python3 """ Laszlo Szathmary, 2014 (jabba.laci@gmail.com) Print just the name of the current directory. For instance, if you are in "/home/students/solo", then this script will print just "solo". The output is also copied to the clipboard. Usage: here Last update: 2017-01-08 (yyyy-mm-dd) """ import...
13bc50aad56a3fee8fcf72b72a7f06b4fed0ef12
RyanKHawkins/Account_Manager
/main.py
4,694
4.28125
4
""" Create a login program that I can use to add and verify usernames and passwords. A dictionary seems like the appropriate item to store this information. """ accounts = {"ryanhawkins": "beastmode", "testname": "testpass"} class Account: def __init__(self, username, password): self.usern...
23fec4266c6a158041989472eb7cbe11c704fb6a
Justas327/Skaitiniai-Algoritmai
/LD-3/task3.py
722
3.546875
4
import matplotlib.pyplot as plt from ast import literal_eval import numpy as np from interpolation import parametric_interpolation, hermite_interpolation_spline from task3_data import x_range, y_range n = 305 # Number of interpolation points step = 0.1 # Graph's precision # Reducing interpolation points to selected...
cdd06c5d4ae2e8c0c72942bd343c889491f0073b
hnguyen0907008/Nguyen_H_InClass_Python
/RPSGame.py
2,062
4.0625
4
from random import randint choices=['Rock','Paper','Scissor'] player = False player_lives = 5 computer_lives = 5 computer = choices[randint(0,2)] #define win or lose function def winorlose(status): print("Called win or lose function") print("**************************************") print("You", status,"! Would you...
f40e150a33aff6a25dc3716ac6ef00d99dc61567
sayyedsy/sayyed-saber
/while.loop.multi.py
118
3.625
4
table=2 while table<=20: mul=1 while mul<=10: print(table,"×",mul,table*mul) mul=mul+1 print() table=table+1
f3373dc49d85cebfb79fba6154bac766c7673bfa
sugataach/al-gore-rhythms
/arden/test_q5.py
2,543
3.734375
4
''' Given a linkedlist of integers and an integer value, delete every node of the linkedlist containing that value. Approach A: iterate through linkedlist, keeping a pointer to the current and prev nodes when curr.val == integer, prev.next = curr.next, curr = prev.next ''' import pytest class Node: def __init__(...
499742df4c23381236545ba1ef3677a89b2b6cfe
Keshav1506/competitive_programming
/Linked_List/012_leetcode_P_021_MergeTwoSortedLists/Solution.py
8,761
3.546875
4
# # Time : O(N+M) ; Only one traversal of the loop is needed. # Space: O(1) ; There is no additional space required. # @tag : Linked List # @by : Shaikat Majumdar # @date: Aug 27, 2020 # ************************************************************************** # LeetCode - Problem 20: Merge Two Sorted Lists # # Mer...
e0cd03c32ea1ed15704192bb2e6f9cb9aa0d6b0b
francisco-igor/ifpi-ads-algoritmos2020
/Fabio01_Parte02/f1_p2_q2_m_para_km.py
289
3.875
4
# Leia um número inteiro de metros, calcule e escreva quantos Km e quantos metros ele corresponde. # ENTRADA metros = int(input('Leia um valor em m: ')) # PROCESSAMENTO km = metros // 1000 m = metros % 1000 # SAÍDA print(f'O valor {metros}m corresponde a {km}km e {m}m.')
a13928ae5356e79f0b108011bd0c1f7c354e19e1
gastonciara86/PYTHON_2.7-GUIA_2
/EJE4G2.py
114
3.59375
4
c=0 for n in range (10) : nro=int (raw_input ("Ingrese Nro:")) if nro>23: c=c+1 print "Nros>23:",c
fc894120e935b388886a6be1fcc78f1ce0e14084
ayingxp/PythonDataStructure
/datastructure/ch03_sort/bubbleSort.py
619
3.84375
4
""" 所有的排序算法 """ import random # 冒泡排序 def bubbleSort(lyst): """ 每次迭代时都会产生一个最大的值 :param lyst: :return: """ for i in range(len(lyst)): # 控制迭代的轮次 for j in range(1, len(lyst) - i): # 进行一次具体的排序, 每次排序完成之后会产生一个(最大值)的固定位置 if lyst[j] < lyst[j-1]: lyst[j-1], lyst[j] ...
ec1721d3164a0f9f267211468f1372cf497bfeee
tormobr/Project-euler
/038/p38.py
369
3.515625
4
def solve(): res = 0 for i in range(1,10000): pan = "" j = 1 print(i) while len(pan) < 9: pan += str(i * j) j += 1 if is_pandigital(pan) and int(pan) > res: res = int(pan) return res def is_pandigital(n): return sorted(str(n)) ...
f8360a1278f2426fa0acc71926f7ad281b199791
harababurel/homework
/sem1/fop/lab7/models/Faculty.py
2,563
3.9375
4
""" Module implements the Faculty class. """ from models.Student import * from models.Assignment import * class Faculty: """ Class that models a generation of students (faculty) as an object. Each faculty is described by: - students - <list of Student()> - assignments - ...
34f1196cd7908b2b7f4b42247a0f57115c3245bd
mag389/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
233
4.125
4
#!/usr/bin/python3 """ write to file appends mode""" def append_write(filename="", text=""): """ write to file, appends if it exists """ with open(filename, 'a') as f: num_chars = f.write(text) return num_chars
35b2b50217a25d362edba790fbb92bd054f858ba
UW-ParksidePhysics/python-functions-and-branching-lucca001
/f2c.py
156
4
4
#F = float(input("Input temopreratue (degrees F):")) def C(F): return (5.0/9.0) * (F - 32) #print(f"Yor input is equal to {C(F):.2f} degrees Celcius")
9e5cb9374c708735df771881ae3b402c94499257
tizzle-b-rizzle/shakespeare_text_adventure
/text-adventure.py
6,888
4.28125
4
name = input( "Hello! what is your name?\nplease type your name and then hit 'enter'\n") # note, choices are defined by the naming convention "choice_[first choice]_[second choice]..." so if the player chooses 1, 2, and then 1, that function will be named "choice_1_2_1" def choice_1_invalid(): choice_...
66304a07fbbd57151bf8a61a4d236daf7f006ea4
lchan20/COMP_1510_Lab_01
/room_painter.py
683
3.96875
4
COVERAGE = 400 length = float(input("Enter the length of the room in feet: ")) width = float(input("Enter the width of the room in feet: ")) height = float(input("Enter the height of the room in feet: ")) coats = float(input("Enter the number of coats of paint: ")) surface_area = (length*width) + (2*length*height) +(2*...
7e99f467e109c0d07a0276ddfc5d5bd7355ec4c1
rk2100994/python_basics
/polymorphism.py
269
3.59375
4
class Animal: def __init__(self): print("I'm in animal") class Dog(Animal): def talk(self): print("I talk in barking fashion") class Lion(Animal): def talk(self): print("I talk in roaring way") an1 = Lion() an2 = Dog() an1.talk() an2.talk()
e92489f6aa63134420aacfc88adcca85bc9e6311
christine-le/algorithms
/one_edit_apart.py
1,358
3.84375
4
class Solution(object): def oneEditApart(self, word1, word2): if len(word1) > len(word2): longerWord, shorterWord = word1, word2 else: longerWord, shorterWord = word2, word1 lengthDiff = len(longerWord) - len(shorterWord) if lengthDiff > 1: return False elif lengthDi...
ba449a87d42e75c00ea94fd231e1b4b3382e3abf
braeden-smith/Chapter-3
/Chapter 3 Excercise 2.py
842
4.1875
4
#Braeden Smith Chapter 3 Excericse 2 ''' Exercise 2: Rewrite your pay program using try and except so that your program handles non-numeric input gracefully by printing a message and exiting the program. The following shows two executions of the program: Enter Hours: 20 Enter Rate: nine Error, please enter numer...
40547b15e1f77f7b078558f202f87ee6b9c3db69
romitpatel/learn_python
/Ch10_Tuples/exercise_2.py
725
3.796875
4
fname = input('Please enter a valid file name: ') try: fhand = open(fname) except: print('Please enter an existing file name') exit() counts = dict() for line in fhand: line = line.rstrip() words = line.split() if not line.startswith('From ') or len(words) < 1: continue for word in words: ...
103496b50aae26cc6f8313771d0fbaa6bd6ff827
steveedegbo/learning_python
/Functions/functions.py
4,512
4.125
4
# # # # # #TAKES NAME & GENDER INPUT AND GREETS ACCORDINGLY # # # # # def greet(name, gender, age): # # # # # if gender == "male" and age >= 18: # # # # # print(f'Hello Mr {name}..!') # # # # # elif gender == "male" and age < 18: # # # # # print(f'Hello Mst {name}..!') # # # # # el...
7b833e07e872f68d03cdb5195f55ab2c58de70cd
IamConstantine/LeetCodeFiddle
/python/PascalTriangle.py
376
3.5
4
from typing import List def generate(numRows: int) -> List[List[int]]: result = [[1]] for row in range(2, numRows + 1): curr = [1] * row i = 1 j = (1 + row) // 2 while i < j: last = result[-1] curr[i] = curr[row - 1 - i] = last[i - 1] + last[i] ...
cc6d293b05462b11f0258877e26770fc5fcefa08
riturajkush/Geeks-for-geeks-DSA-in-python
/bit magic/prog2.py
1,050
3.5625
4
#{ #Driver Code Starts #Initial Template for Python 3 import math def getRightMostSetBit(n): return math.log2(n&-n)+1 # } Driver Code Ends #User function Template for python3 ##Complete this function def posOfRightMostDiffBit(m,n): m = int(bin(m).replace("0b",""),2) n = int(bi...
8b8792961a959e0b9646f24669b4c0a2d4b15bd9
Cowcoder21/Hangman
/Hangman.py
1,515
4.25
4
#!/usr/bin/env python # coding: utf-8 # In[84]: def guess(): target = input("The word the others have to guess is: " ) letters = 'abcdefghijklmnopqrstuvwxyz' max_attempts = 3 counter = 0 previous_guesses = [] while True: guess = input ("Guess a letter in the target word: ") ...
b7b12b5c836ee574b11b7cfbddbdb37af7385436
Matt-Robinson-byte/DigitalCrafts-classes
/python102/only-odds.py
148
3.984375
4
def is_even(number): if number%2 == 0: return True else: return False def is_odd(): return not is_even() def only-
7321a8c0ec9cc9435bea1b3bdae8e9f5e94a2e5f
deepaksharma36/Artificial_Intelligence
/Project2_MLP_Classification/src/trainMLP.py
13,689
3.90625
4
""" File: trainMLP.py Language: Python 3.5.1 Author: Karan Jariwala( kkj1811@rit.edu ) Aravindh Kuppusamy ( axk8776@rit.edu ) Deepak Sharma ( ds5930@rit.edu ) Description: It takes a file containing training data as input and trained neural network weights after some epochs. It uses batch ...