blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
09aced62b0910bfebdcfeb4080b113b5c09795d4
Christopher-Wirt/Advent-of-Code-2019
/day1-part2.py
322
3.609375
4
import math def calcFuel( mass ): if(mass <= 0): return 0 fuel = math.floor(mass / 3) - 2 if fuel <= 0: return 0 return fuel + calcFuel(fuel) f = open('day1-input.txt', 'r') x = f.readlines() f.close() print(len(x)) sum = 0 for mass in x: sum = sum + calcFuel(int(mass)) print(su...
b400bd75b0f1312f06c15cc7329090a88db45cad
umangtank/mini-projects
/stone-paper-scissor.py
2,640
4.125
4
# stone paper Scissor import random lst = ['s','p','S'] chance = 10 no_of_chance = 0 computer_point = 0 human_point = 0 print(" \t \t \t \t stone,paper,scissor\n \n") print("s for stone \np for paper \nS for Scissor \n") # making the game in while while no_of_chance < chance: _input = input('Stone,paper,sissor:...
5d91ad8da30e2ea7b0a228ce7c4ce85a1d00b7fe
mayakeren/DevOps
/Assignments/17.02 Assignment.py
756
3.5625
4
#A. first = 7 second = 44.3 print(first + second) print(first * second) print(second / first) #B. a = 8 a = 17 a= 9 b = 6 c = a+b b = c+a b = 8 print(a, b, c) #C. # No, but there should be a space before = in the second one name = "john" print(name) name='john' print(name) #Suggested edit: ad...
990698a8757c2302255ab16d6ba957b13a21f534
alvas-education-foundation/prashanth
/coding_solutions/captilaze_13-06.py
185
4.25
4
test_str = input() print("The original string is : " + str(test_str)) res = test_str[0].upper() + test_str[1:] print("The string after uppercasing initial character : " + str(res))
397d4b5db663e6bd76c3b8362c8c427327bd7162
alvas-education-foundation/prashanth
/coding_solutions/missingnumber_22-5.py
231
3.71875
4
def MissingNo(A): n = len(A) total = (n + 1)*(n + 2)/2 calsum = sum(A) return total - calsum # Driver program to test the above function l=[] l=int(input("Enter the array")) miss = MissingNo(l) print(miss)
479f9507d76f9da9a6ae94b236fd3818652b66b2
Answerman/Coffee-Machine
/Problems/The farm/task.py
1,061
3.609375
4
chicken = 23 goat = 678 pig = 1296 cow = 3848 sheep = 6769 money = int(input()) n_sheep = money // sheep if n_sheep == 0: n_cow = money // cow if n_cow == 0: n_pig = money // pig if n_pig == 0: n_goat = money // goat if n_goat == 0: n_chicken = money // ...
2d15b623c9ba427a659e3639c8608f3baa91f225
Ankitahazra-1906/python
/creating window.py
393
3.78125
4
from tkinter import * window=Tk() btn=Button(window, text="This is Button widget", fg='blue') btn.place(x=80, y=100) lbl=Label(window, text="This is Label widget", fg='red', font=("Helvetica", 16)) lbl.place(x=60, y=50) txtfld=Entry(window, text="This is Entry Widget", bd=5) txtfld.place(x=80, y=150) window.tit...
f66fecfde0d866ed53894f92d83ea62a341530a9
SamLojpur/TextVenture
/textParser.py
15,981
3.5625
4
import worldLocations import gameUpdate import sprites MAGIC_SPELL = "finances" """ Description: Handles the event when the player uses the magic spell Arguments: player_cast(_player_state): The current state of the player _: A place holder Returns: Lets the player jump o...
f286576f00b0504ae3544f2bad28739793547bbf
Mayank-dhyani/PATTERN_MATACHING
/pattern printing.py
402
4.03125
4
#pattern printingi print("how Many Row you wnat to print:-") num=int(input()) print("type 1 or 0:-") num1=int(input()) new=bool(num1) if new==True: for i in range(1,num+1): for j in range(1,i+1): print("*",end=" ") print("\n") elif new==False: for i in range(num,0,-1): ...
8081158e7a13bf7b776387de01654c06a9251e84
SimplyLinn/ircbot
/lib/caesar.py
217
3.75
4
# caesar cipher in Python from string import ascii_lowercase as lc, ascii_uppercase as uc def rot(n): lookup = str.maketrans(lc + uc, lc[n:] + lc[:n] + uc[n:] + uc[:n]) return lambda s: s.translate(lookup)
f411f2a31c86d318cf2d2c58a8cd095164b9b787
psychoAB/OOP-Laboratory-01-59
/12/pythonRush/compute_gpa.py
815
3.75
4
#!/usr/bin/python3 coursesFile = open('courses.txt', 'r') myGradesFile = open('my_grades.txt', 'r') coursesFileString = coursesFile.read() myGradesFileString = myGradesFile.read() coursesFile.close() myGradesFile.close() coursesCredit = {} myGrades = {} credits = 0 gpa = 0 for line in coursesFileString.split('\n'): ...
e215d1f1f8c938bd767f542c07568b48e471ad11
lschachter/AdventOfCode
/2018/Day_09/findHighScore.py
1,805
3.578125
4
class Marble: def __init__(self, name): self.name = name self.left = None self.right = None def __str__(self): left = self.left.name if self.left else "None" right = self.right.name if self.right else "None" return f'Marble {self.name}: ({left}, {right})' def main(): gameInput = open('marbleInput.txt...
b3692ff0f8502fc5b8852b07e912bd5dea6f5fb5
lschachter/AdventOfCode
/2020/day_9/code.py
1,279
3.703125
4
def parse_input_file(): input_file = open('2020/day_9/input.txt', 'r') data = list(map(int, input_file.read().split('\n'))) input_file.close() return data def decrypt_data(data, preamble_length): data_length = len(data) for i in range(preamble_length, data_length): if can_two_sum(data...
3dc892e76feea40cab88a1ab96ea37b995e99651
yash5015/Tkinter-Text-Editor
/Tkinter/Create_MenuBar.py
1,126
3.578125
4
import tkinter as tk from tkinter import ttk win=tk.Tk() win.title('MenuBar') def func(): print("func called") # *******************************SIMPLE MENUBAR**************************** # menubar = tk.Menu(win) # menubar.add_command(label='Save',command=func) # menubar.add_command(label='Save As',command=func) #...
5da52affc6f54587986aaade22f463ef94a1af5c
dooking/LikeLion
/session5/class.py
974
3.578125
4
class FourCal: def __init__(self, name, age, school): self.name = name self.age = age self.school = school self.add_count = 0 self.sub_count = 0 self.mul_count = 0 self.div_count = 0 def add(self, n1, n2): self.add_count += 1 return n1 + n2...
97633392300141def76749b9766d2d7e1a5df8e9
jamal-k/musicore-app
/app/flask_backend/data/utils.py
689
3.796875
4
from math import radians, cos, sin, asin, sqrt # function from https://datascience.stackexchange.com/questions/49553/combining-latitude-longitude-position-into-single-feature def single_pt_haversine(lat, lng, degrees=True): """ 'Single-point' Haversine: Calculates the great circle distance between a point ...
72375f2b11c2461e2ec001b8241b2dba4624619a
tangfastic/book_catalogue
/book_catalogue.py
3,544
4.125
4
"""Book Catalogue to store a directory of all your books.""" class Book: '''Represents a book in a catalogue.''' def __init__(self, title, authors, subject, isbn): '''Initialise a book with title, authors, subject, isbn and dds.''' self.title = title '''Authors attribute should be enter...
2a402087c2a3211ea3f49c8bfca8d555c1767987
zhengxiaocai/jksj_core
/ch06/py0603_nlp.py
1,080
3.578125
4
# 自然语言处理,统计词频 # r 读取,w 写,rw 读写都有,a 追加 # r+ 读取并更新,不会清空;w+ 写入并更新,会清空。 # >>TODO: 权限管理比较重要,如果只要读取,就不要申请写入。 import re def parse(text): # 使用正则去除标点符浩和回车 text = re.sub(r'[^\w]', ' ', text) # 转换为小写 text = text.lower() # 生成单词list word_list = text.split() # 去除空 word_list = filter(None, word_li...
702ee605ebbef925e078ae85056020effb41363a
zhengxiaocai/jksj_core
/ch14/py1401_test.py
890
3.984375
4
if __name__ == '__main__': l1 = [1, 2, 3] l2 = list(l1) l3 = l1 l4 = l1[:] print(l1 == l2) print(l1 is l2) print(l1 == l3) print(l1 is l3) print(l1 == l4) print(l1 is l4) # >>TODO: == 是比较值是否相等;is 是比较址是否相等。 a = 10 b = 10 print(a == b) print(id(a)) pri...
4a7ba6b6dd5bb6eed92603c93e017e3d38d123f7
zhengxiaocai/jksj_core
/ch03/py0301_list_tuple.py
3,223
4.09375
4
""" 列表和元组: 相同点:都是一个可以放置任意数据类型的有序集合 不同点: 列表:动态的,长度大小不固定,可以任意的增删修改元素 mutable 元组:静态的,长度大小固定,不可以增删改元素 immutable """ if __name__ == '__main__': list01 = [1, 2, 'Hello', 'world'] # 列表中同时包含int String print(list01) tup01 = ('jason', 22) print(tup01) list02 = [1, 2, 3, 4] lis...
e5e720dff84d44fc681457fcf4cb196e7dd1f843
hayleylandsberg/Python-Live-Codes
/07-11-orientation-testing101/test-intro.py
610
3.609375
4
import unittest from palindrome import Palindrome class PalindromeTest(unittest.TestCase): @unittest.skip("demonstrating skipping") def test_fun_returns_8(self): self.assertEqual(palindrome.fun(8), 8) def test_is_palindrome(self): pal = Palindrome() self.assertTrue(pal.is_palindrome("mo...
4102ec07b238015877248a8ee0f297815a92b03f
abhishekmulay/ds-algo-python
/datastructures/singly_linkedin_list/SinglyLinkedListTest.py
1,012
3.515625
4
import unittest from SinglyLinkedList import SinglyLinkedList class SinglyLinkedListTest(unittest.TestCase): def test_list_count(self): lst = SinglyLinkedList() self.assertEqual(lst.size(), 0, " Count should be 0") lst.add("some data") self.assertEqual(lst.size(), 1, " Count shou...
d926132feacc5b847c73f02cc5b33d4afb807455
s905060/JumbleSort
/JumbleSort2.py
2,575
4.25
4
# Enter your code here. Read input from STDIN. Print output to STDOUT #!/usr/bin/python #Check if number is valid def is_number_valid(numer): lower = -999999 high = 999999 try: if (lower <= int(number)) and (int(number) <= high): return True else: return False ex...
66e7bb53bd2083778e9986942a7f39f284ede122
collaborative-music-lab/NIME
/Instruments/Mbira/python/sensorInterfaces/monoPitch.py
1,128
3.71875
4
import math class MonoPitch: '''use a number of digital values to generate a single output pitch''' def __init__(self,numInputs,mode="major", basePitch = 60): self.numInputs = numInputs self.mode = mode self.basePitch = basePitch self.curVals = [] self.customScale = [] transTable = [1,2,4,7,-7] major = ...
657baa9da2edc2b0d00356cb1bc208afd25cc08e
moraisalysson/UNIPE-MY-CODES
/URI/2581.py
110
3.515625
4
casos = int(input()) cont = 0 while(cont < casos): input() print("I am Toorg!") cont += 1
db1478dff76bae4bb299063a7a82377259260d7b
uberalex/pygame-tutorials
/chp2/helloworld.py
440
3.796875
4
#this is the first example of the python game library tutorial. # http://inventwithpython.com/pygame/chapter2.html import sys, pygame from pygame.locals import * pygame.init() DISPLAYSURF = pygame.display.set_mode((400,300)) pygame.display.set_caption('Hello World!') while True: # main event loop for event in pygam...
66b7c7438e1aab8865ebe4968da9d0b0b4aaf711
1496-rajeev/python-oop
/self.py
560
3.671875
4
class Employee: age =20 def meth1(self): self.name = "ravan" age = 40 print("meth1 name ", self.name) # with "self" attribute available for the life of the class print("meth1 age ", age) #witjout "self" attribute is valid only inside the method def meth2(self): print...
779c9aec88ad539e88307edfb5986760c285cb7b
mzfr/Project-Euler
/In python/10.py
445
3.765625
4
# Find the sum of all the primes below two million. def isprime(num): flag=0 for i in range(2,int(num/2)): if (num%i==0): flag = flag+1 if (flag==0): return True else: return False def main(): i = 0 sum_ = 0 while(i<200000): if(...
f27fd04926557fe271cbc6cf21fcc7a5dd07f5f8
mzfr/Project-Euler
/In python/23.py
649
3.71875
4
# sum of all the numbers that cannot be written as sum of two abundant number def divisor_sum(num): sum_ = 0 flag = num for i in range(1,int(flag/2)+1): if (flag%i==0): sum_ += i if(sum_ > num): return False else: return True def main(): store ...
9c0495a926c9909007c6f58ef5469be6b491b2fb
hd1534/A.N.S.I.-algorithm
/개인적으로 푼 문제/실버/피보나치 함수/피보나치 함수.py
474
3.734375
4
# https://www.acmicpc.net/problem/1003 def fibonacci(n): arr = [[1, 0], [0, 1]] # [0의 갯수, 1의 갯수], for i in range(2, n+2): arr.append([arr[i-1][0] + arr[i-2][0], arr[i-1][1] + arr[i-2][1]]) return arr def sol(): arr = fibonacci(40) for _ in range(int(input())): print(*arr[int(...
77c53ea54a625e0d65a6f773e3296fa5ed98f2c0
hd1534/A.N.S.I.-algorithm
/개인적으로 푼 문제/실버/N과 M (1)/N과 M (1).py
343
3.671875
4
# https://www.acmicpc.net/problem/15649 def permutations(arr, m, li): if (m == 0): print(li) return for i in arr: permutations([x for x in arr if x != i], m-1, li + str(i) + " ") def sol(): n, m = map(int, input().split()) permutations(range(1, n+1), m, "") if __name__ ==...
1ed0d06c7c3a6e54752889d43379eb8284e96186
hd1534/A.N.S.I.-algorithm
/개인적으로 푼 문제/브론즈/벌집/벌집.py
268
3.734375
4
# https://www.acmicpc.net/problem/2292 def sol(n): n -= 1 # 시작 자리는 세지 않는다. m = 6 count = 1 while n > 0: n -= m m += 6 count += 1 return count if __name__ == "__main__": print(sol(int(input())))
cb3467b5a535b08a00c03101768d57be0490fdd4
Ahd-kabeer/python-practices
/firstproject/mycode.py
247
3.765625
4
#x=5 #y=13 #z=x+y #print(z) #X=int(input("Enter 1st Number")) #Y=int(input("Enter 2nd Number")) #Z=X+Y #print(Z) # ch=input("enter a character") # print(ch) # ch1=input("Enter a Char") # print(ch1[0]) # ch2=input("Enter a Char")[0] # print(ch2)
139b163a388e81934537b44a69edb9e9fc59c557
sprnik/labs
/2_курс/численные_методы/1/1.py
217
3.53125
4
import math def main(): Δ = 2 x = 3 ε = 10**(-5) while abs(x-Δ) >= ε: x = Δ Δ = x + 2*(math.log(x)-x+1.8) print(f"{Δ:.{7}f}") if __name__ == "__main__": main()
24212b22e1c58df1956f79c3bc6920970348a62b
Sean-Horner-SmoothStack/smoothstack_pce_training
/assignment_2.b/main.py
2,381
4.4375
4
def assignment2_b_1(): multi_type_list = [100, "potato", 2.65] print(multi_type_list) def assignment2_b_2(): nested_list = [1, 1, [1, 2]] print("Ro get the 2 out of the nested array, the inner-array's position in the outer-array,") print("then the index of the 2 in the inner-array, like ...
6454742bec59a3fc6b717ba45d4b3afd57497033
mateobassini/trabajo-final-programacion-
/parser_commands.py
537
3.515625
4
from commandwords import CommandWords from command import Command class Parser: def __init__(self): self.commands = CommandWords() def getCommand(self): word1 = None word2 = None inputLine = input("> ") text = inputLine.split(' ') if (len(text)>0): ...
44bfd65eb31562a40d0b00d6d827e98b660c2c30
chookmook29/usdice
/dice.py
5,155
3.828125
4
import random weather = input('Weather: Fair(f), Poor(p), or Severe(s)?') loop = 0 while loop == 0: attacker_drm = 0 defender_drm = 0 move_points = 0 unit = input('Unit: German(g), Soviet(s), or Axis Minor?') unit_type = input('Leg unit(l), mobile(m), or Air Strike(a)?') if unit_type == 'l': move_points = 8 e...
ed76a89b12bb3ec94efa5a92347c2a9e88a2c42d
josephsivits/pythonClasses
/polymorphism.py
684
4.15625
4
#program to show basisc of polymorphism class Account: def __init__(self): self.userName = "" self.password = "" self.id = 0 def loginInfo(self): self.userName = input("Enter Username: ") self.password = input("Enter password: ") self.id = int(input("Enter id:...
fb980732c12c48254e5007d89dc41bb2539d1c94
josephsivits/pythonClasses
/polyex4.py
647
3.828125
4
# polymorphism -including Functions and Objects class computer: def programs(self): print("Undergraduate and Graduate Programs") def courses(self): print("Computer Science1") print("Software Engineering") def students(self): print("Undergraduate: 65") print("Graduat...
ba93c2297bc2e54f9b2b49523595813e63dbcd09
josephsivits/pythonClasses
/createtable.py
1,161
4.125
4
# importing module import sqlite3 # connecting to the database connection = sqlite3.connect("mytable.db") # Cursor crsr = connection.cursor() # if first time running need node below # SQL command to delete the table sql_cmd = """Drop table s_emp;""" # execute the statement crsr.execute(sql_cmd) # SQL command to...
92276121ec3312409f05c3849aed01dfcdae981e
narges-zh/assignment2
/second to time.py
111
3.640625
4
s=int(input('enter second:')) h=s/3600 m=s/60 s1=s%3600 print('time=' , int(h) , ':' , int(m) , ':' , int(s1) )
ce98186297ca6119e94e83d0e581454f2a1482b5
terintelivia/probleme-IF-FOR-WHILE
/problema 9 IF FOR WHILE.py
210
3.6875
4
n=int(input("Dati un numar:")) suma=0 for i in range(1,n): if n%i==0: suma+=i print(suma) if suma==n: print("este un numar perfect") else: print("nu este un numar perfect")
46d04e56d7d30a7e754778fd246d267b3badd83b
JanKnapen/AoC_2016
/Day_06/main.py
512
3.671875
4
import collections def get_message(part): dict = {} for line in lines: for i in range(len(line)): if i not in dict: dict[i] = [line[i]] else: dict[i].append(line[i]) result = "" for i in dict: result += collections.Counter(dict[i]...
9212c3970d98cc4e8fd724902ef84c702b943e6c
JinwooPark00/TreeGame_dev
/Tree/tree.py
1,210
3.515625
4
import tree_constants as constants class Tree(): def __init__(self): """Base Tree Base max movement of 6 Base max health of 10 Init water level of 10 Init light level of 10 """ self.max_movement = constants.BASE_MOVEMENT self.max_health = constant...
3f22c583c987222f6e9ba711b4e2435cd746c5fa
wekesa1998/simplePythonprojects
/strings.py
281
3.90625
4
firstname=" duncan" print(firstname+"wekesa") print(firstname*5) print(r"i don't like walking at night'am usually scared'") print('i have\'nt taken anything') print(firstname[0]) first="wekesa" print (first[0]) print(first[-1]) print(first[:2]) print(len(first)) print(first[0:6])
88f181dcd33cbf9833a59bf7ad9268ead3a9db39
pratikaher88/SenselWork
/PycharmProjects/Sensel/Trial/trial7.py
859
3.65625
4
import numpy as np import scipy as sp import scipy.interpolate import matplotlib.pyplot as plt # Generate some random data y = (np.random.random(10) - 0.5).cumsum() x = np.arange(y.size) def func(x, a, b, c): return a * np.exp(-b * x) + c # Generate some data, you don't have to do this, as you already have your...
d128e1d9ba5cba5aca4b550e4f777ab6e04b85ea
MahmoudAH/NTL
/file.py
356
3.703125
4
def main(): # out=open("hello.txt","w") #to delet old and add new out = open("hello.txt", "a") #to add alla elqdem out.write('welcome to python\n i wil won \n alla karim') out.close() readfile=open("hello.txt","r") for line in readfile: print( line ) readfile.close...
6cf1eb7326b205a7f0d61d222ef35a7b841a9b9e
MahmoudAH/NTL
/fr.py
2,082
4.09375
4
#def main(): #print("welcome from python") #if __name__ == '__main__':main() #n="mahmoud" #print (n,type(n)) #def main(): #num=int(30/6) #print(num,type(num)) #if __name__ == '__main__':main() #amount=88 #data="{} is hight or {} is low or {} f".format(amount,88,1) #data="my name is khan" #print(data[11]) ...
3228ba44d90db34a0ae13b0ac4fb5222a08b5bc1
MahmoudAH/NTL
/kwargs.py
595
3.6875
4
class car: # def __init__(self): ## print("lkjdgf") def __init__(self,**kwargs): self.data =kwargs def get(self): print("name is ",self.data["name"]) print("age ",self.data["age"]) # print("value is ",self.data["value"]) # def set(self, name): def set_age(self,age): ...
9ef06c9ec5ffd97e669336bd761199436b2c3e7b
isakaaby/fys3150
/read_sol_plot.py
779
3.59375
4
import numpy as np import matplotlib.pyplot as plt infile = open("solution.txt", 'r') N = int(infile.readline()) #Filling the start boundaries x = [0] #grid points v = [0] #tridiagonal solutions u = [0] #analytic solutions for line in infile: numbers = line.split() x.append(float(numbers[0])) v....
c1b967679a21d5c7a824fc1af8f5f1ba1b8b2283
vbaddam/LeetCode
/Arrays/Merge Intervals.py
668
3.640625
4
class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: intervals = sorted(intervals) s = [] i = 0 while i < len(intervals): if not s: s.append(intervals[0]) i = i + 1 elif s[-1][-1] >= intervals[i][0] an...
770963a03c0cd0d10ecb0bb4111d9b1d2e162ed9
vbaddam/LeetCode
/Arrays/414_Third_Maximum_Number.py
239
3.625
4
class Solution: def thirdMax(self, nums: List[int]) -> int: snums = sorted(list(set(nums)), reverse = True) if len(nums) >= 3 and len(snums) >= 3: return(snums[2]) else: return(snums[0])
30d08e329d73ef8a045758b2157dfc80259a5e15
Sir-Lance/CS1400-Python
/practice/ints2.py
412
3.90625
4
a,b,c = eval(input("Enter 3 numbers: ")) if a > b: if b > c: print("Spam please!") else: print("It's a late parrot!") elif b > c: print ("Cheese Shop") if a >= c: print ("Cheddar") elif a < b: print ("Gouda") elif c == b: print("Swiss") else: print("Tr...
e5918e0b6fb96e36fea3274c57157822c67324d8
Sir-Lance/CS1400-Python
/practice/function2.py
186
3.78125
4
def area(length): result = 6 * length ** 2 return result def vol(length): result = length**3 return result length = int(input("yikes")) print(.f "yikeroons{vol}")
79819936b07bc5c93515987d86ac5ffb9c593c9a
CWaltz99/Towers-of-Hanoi
/tower.py
563
3.65625
4
class Tower(list): def __init__(self, name): super().__init__() self.__name = name def get_name(self): return self.__name def move(self, dest_tower): dest_tower.append(self.pop()) return dest_tower def __str__(self): tow_str = 'Tower' + sel...
ac578ffe41c8afd271090de69a7575ef5b7d0da4
jaccharrison/spice-waveform-gen
/bus/unit.py
946
3.625
4
from decimal import Decimal import logging import re Unit_regexp = re.compile(r'^([0-9e\+\-\.]+)(t|g|meg|x|k|mil|m|u|n|p|f)?') '''Returns a Decimal equivalent to a string with number and SPICE unit''' def unit(s): """Takes a string and returns the equivalent float. '3.0u' -> 3.0e-6""" mult = {'t' :Decima...
3da3ec9261e990fd2be7f130e868f8d12e9eecdf
abdulmoizshaikh/Logic-Building-Programs
/hello.py
125
3.90625
4
def factorial(n): if n==0: return 1 elif n>0: return n* factorial(n-1) res=factorial(5); print(res)
230217187af7422d51e61407fb0a632442858d1f
atraore1/poetry-slam-abba
/main.py
694
3.703125
4
from random import choice def get_file_lines(filename): in_file = open(filename, "r") lines = in_file.readlines() in_file.close() return lines def lines_printed_backwards(lines_list): lines_list.reverse() lines_length = len(lines_list) for i in range(lines_length): line = lin...
94f3fecc7a3c423c136d83b9969f0519c6d44eb9
Sousf/Agar.io-bot
/hive/vectors.py
4,038
3.90625
4
### LIBRARIES ### import random import math from dataclasses import dataclass # Standard vector stuff, with a few useful methods for this particular project @dataclass class Vector(): x : float = 0 y : float = 0 # returns the addition of this vector and the passed vector def __add__(self, v): ...
16808913ab855087731276f9686d830482bac281
lemonase/programming-challenges
/leetcode/005-longest-palindromic-substring.py
726
4
4
# Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. def longestPalindrome(s): rev = "".join(reversed(s)) output = '' for i in range(len(s)): for j in range(i, len(s)): rev = "".join(reversed(s[i:j])) if s[i:...
8063c221b4fc41e961a836973a6b578c262192e1
lemonase/programming-challenges
/leetcode/challenges/2020/april/week-1/move_zeros.py
452
3.53125
4
#!/usr/bin/env python class Solution: def moveZeroes(self, nums: [int]) -> None: """ Do not return anything, modify nums in-place instead. """ zc = 0 for i in range(len(nums)): if nums[i] == 0: zc += 1 for i in range(zc): num...
97b01118a9f0f91eec48c9744c62d556da208bb7
emjrymer/BlackJack
/player.py
1,453
3.75
4
from deck import Deck deck = Deck() deck.make_deck() class Player: def __init__(self): self.hand = deck.create_player_hand() self.value = deck.get_player_value(self.hand) def show_player_hand(self): return self.hand def player_hand(self): return self.value def play...
5eebf7d9b7399018b8a97e6d69b038cde98230bd
Cheon-Jihoon/Kaist-Study
/week1/mystudy.py
440
3.5625
4
def is_valid(driver, registered): for i in range(2): if driver[i] != registered[i]: return False return True def check(driver, registered_list, arrested_list, num_suspects): for i in registered_list: if is_valid(driver, i): return False else: arr...
a15e6f7d8041e4c1b40dd51507e616e8849a4ae7
raghavchitkara/Data-Structure
/single_linked_list.py
4,093
4.21875
4
#implementing linked list in pythton class Node() : def __init__(self): self.data=None self.next=None def set_data(self, data): self.data=data def get_data(self): print(self.data) return self.data def set_next( self, next): self.next=next def g...
5215011ffa389f9f44ec6b2c9ad104612c760c1b
CS3398-Luna-Sea/SeeBus
/backend/bus.py
6,996
3.75
4
import translate import time class Bus: def __init__(self, id, name, route, location, heading, speed, last_stop, last_update): """ Creates a bus object initializing all fields. :param id: Integer ID of the bus. :param name: String name of the bus. :param route: Integer rou...
31c59ce32a1b4720f3162a3330278717952bab5f
sayalishah/PythonAssignments
/Assignment3_3.py
482
3.8125
4
import functools def ReturnMinNo(arr): max = arr[0] for iCnt in range(len(arr)): if(max>arr[iCnt]): max= arr[iCnt] return max def main(): arr=[] print("Enter Size Of Array") size =int(input()) for i in range(size):arr.append(int(input())) print("Min ...
a02ab4f166e5d85c7eb6426ae9e9ad1c3f6c6507
ian-garrett/CIS_122
/Assignments/Week 3/Lab3-4.py
86
3.515625
4
# Ian Garrett # Lab3-4 price = input("Enter the price: ") print (round(float(price), 2))
251926486708c93256041412609566357ed7b068
ian-garrett/CIS_122
/Assignments/Week 7/Lab7-Extra Credit 1.py
2,228
3.828125
4
# by Ian Garrett' # Lab 7-Extra Credit 1 # In saving pictures, I decided to also append the color and bg color of the image to the favorites list print ("Welcome to my turtle program\n") import turtle turtle.speed(0) def draw_picture(angle, number_of_lines, color, bgcolor): for i in range (number_of_lines): ...
83a279fd0a5da0d37dba2243a572afaf222db8ed
ian-garrett/CIS_122
/Assignments/Week 5/Lab5-1.py
543
4.03125
4
# by Ian Garrett # Lab5-1 print ("Tiny National Bank of Walterville\nCredit Card Payments") reset = 'y' while reset == 'y': account_balance = round(float(input("\nCredit card balance? ")),2) # insert if/elsif statement for returning payment due reset = input("\nAnother customer (y or n)? ") def get_minpa...
91f02bc53ad425dfbd8a748b4837ca7285ede86a
moral50/Practicas
/PYHTON/diccionario py.py
4,735
4.59375
5
#Diccionario #Un diccionario es una colección desordenada, modificable e indexada. En Python, los diccionarios se escriben con llaves y tienen claves y valores. thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict) #Acceder a elementos #Puede acceder a los elementos de un diccionario...
da8acce527dacca44d7a82748007435f7dbc4063
moral50/Practicas
/PYHTON/alzanze py.py
1,533
4.53125
5
#ALCANZE DE PYTHON #Alcance local #Una variable creada dentro de una función pertenece al ámbito local de esa función y solo se puede usar dentro de esa función. def myfunc(): x = 300 print(x) myfunc() #Función dentro de la función #Como se explicó en el ejemplo anterior, la variable xno está disponible fuera d...
444db7acc1b274bf770ca6cf935e0a092df25b84
moral50/Practicas
/MONGODB/ordenar.py
588
3.6875
4
#Ordene el resultado alfabéticamente por nombre: import pymongo myclient = pymongo.MongoClient("mongodb://localhost:27017/") mydb = myclient["mydatabase"] mycol = mydb["customers"] mydoc = mycol.find().sort("name") for x in mydoc: print(x) #sort ("nombre", 1) # ascendente #sort ("nombre", -1) # descendente #Or...
ff712826027996dbdb70b8e7b9efcca51c55221d
moral50/Practicas
/PYHTON/formato de cadena py.py
1,649
4.40625
4
#Formato de cadena de Python #Formato de cadena () #El format()método le permite formatear partes seleccionadas de una cadena. #A veces hay partes de un texto que no controlas, ¿tal vez provienen de una base de datos o de una entrada de usuario? #Para controlar dichos valores, agregue marcadores de posición (corchetes ...
a829e200bcf4e52af27f9f21080e4b1ad777cfe3
moral50/Practicas
/PYHTON/LISTAS/cambiar elementos lista py.py
1,588
4.25
4
#CAMBIAR EL VALOR DE UN ARTIULO #Para cambiar el valor de un artículo específico, consulte el número de índice: #Cambie el segundo elemento: thislist = ["apple", "banana", "cherry"] thislist[1] = "blackcurrant" print(thislist) #Para insertar más de un elemento, cree una lista con los nuevos valores y especifique el n...
e30acdf9bfaace7b4ea673e337fa057786925924
moral50/Practicas
/PYHTON/LISTAS/metodos lista py.py
750
4.28125
4
#METODOS DE LISTA #Python tiene un conjunto de métodos integrados que puede usar en listas. #Method Description #append() Adds an element at the end of the list #clear() Removes all the elements from the list #copy() Returns a copy of the list #count() Returns the number of elements wi...
b1b48913db25bf927160ed31807460db2511d104
belfner/hangman
/WordGuesser/clean_guess.py
11,644
3.734375
4
import pickle from typing import List, Tuple, Dict class WordGuesser: # all letters in order of their frequency in english according to # 'https://www3.nd.edu/~busiforc/handouts/cryptography/letterfrequencies.html all_letters = 'eariotnslcudpmhgbfywkvxzjq' # signals whether to count the same letter m...
a1e5442d61c040493b455197e96d77680c8f81e9
aoieop/python_camp
/camper_program.py
1,273
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ PyCamp: a collaborative project Bugs found: To fix: crashes when user types words """ import math import random import time def squares(): print("Choose a number 1 through 100.") number = int(input()) square = number**2 print("The square...
945fb7ee151a509e318d51bca45458c6743d310c
freddywilliam/POO_y_Algoritmos
/Ordenamiento/inserccion.py
894
3.609375
4
def inserccion(lista): n = len(lista) for i in range(1, n) valor_actual = lista[i] posicion_actual = i while posicion_actual > 0 and lista[posicion_actual - 1] > valor_actual: lista[posicion_actual] = lista[posicion_actual - 1] posicion_actual -= 1 list...
9a6a2d40ad743ae8a473f56ce501d2d96c0890f3
freddywilliam/POO_y_Algoritmos
/Optimizacion/morral.py
775
3.78125
4
def morral_ejemplo(morral, pesos, valores, n): # Caso base / Evita que se vaya al infinito. if n == 0 or morral == 0: return 0 # Termina caso base # Pregunta si alcanza el objeto en mi mochila mochila if pesos[n - 1] > morral: return morral_ejemplo(morral, pesos, valores, n - 1)...
46c875f5f056b0470117da21952e5a02e3325bed
krusovaa/UdP_zkouska
/morse_translator.py
4,443
4.28125
4
def load_text(): """load text to be translated to morse code""" while True: inp = input('Enter an absolute path to a text file that you want to translate to morse code: ') try: # load text file into local variable with open(inp, 'r', encoding='utf-8-sig') as f: ...
269e877154f3bc3d9594d27a2a26439d88c05e0b
pradeepchhetri/mindfuck
/mindfuck.py
2,680
3.578125
4
#!/usr/bin/env python import sys import getch def execute(filename): """ Executes the content of the file """ f = open(filename, "r") eval(f.read()) f.close() def eval(code): code = clean(list(code)) bracemap = build(code) cells, codeptr, cellptr = [0], 0, 0 while codept...
175e5574b32417836b4274f9641d68f2c13f19f4
MonsieurBarti/ProjetSysteme
/python/version2.py
268
3.734375
4
def syracuse(n, cpt): if (n%2 == 0): n /= 2 else: n = 3*n+1 if (n != 1): syracuse(n, cpt+1) else: print("Nombre de valeurs: ", cpt+1) if __name__ == '__main__': n=int(input ("entrez un nombre: ")) syracuse(n, 1)
d93829d8b6acb2799f20f142df489b2732086d23
projects-ls/Lambda-School-Day-116-119-Data-Structures
/heap/generic_heap.py
1,658
3.71875
4
class Heap: def __init__(self, comparator=lambda x, y: x > y): self.storage = [] self.comparator = comparator def insert(self, value): self.storage.append(value) self._bubble_up(self.get_size()-1) def delete(self): if self.get_size() < 1: return ...
378baaaf8be4c2300abec5299430d90eea0d0dec
manish1822510059/Python-Basic-Projects.
/Story Generator/story-generater.py
614
3.734375
4
import random when = ['A few year','Yesterday','Last night','A long time ago','On 20th jan'] who = ['a rabbit','an elephant','a mouse','a turtile','a cat'] name = ['Ali','Miriam','daniel','hoouk','starwalker'] residence = ['Barcelona','India','Germany','Venice','England'] went = ['cinema','University','seminar','...
bf09ecd6af160dfc1adcaed004ef4f832e7071d9
manish1822510059/Python-Basic-Projects.
/python tips and tricks/tip_1.py
149
3.65625
4
# Using split take many input using one input statement x, y, z, p = input('Give Me Numbers: ').split() print(x) print(y) print(z) print(p)
a9339dc475787b1bf77812e569b5d5649a98f934
blafuente/Intro-To-Python-refresh
/variables.py
179
3.59375
4
age = 30 sentence = "This is a sentence" Brian = 11 myName = "Brian" print("Hello my name is " + myName + ". I am " + str(age) + '.') M, A, O = 1, 2, 3 print M print A print O
0e1690b6e1aad225012e0ef50d38a29568983e75
Ravi007Teja/HactoberFest
/bitwise_operators.py
621
3.890625
4
#!/usr/bin/python def TurnOffBitPosition(number, bit_position): x = 1 x = x << (bit_position - 1) if number & x: x = ~x return number & x return number def ReplaceSpecificBits(no1, no2, position, bits): x = 1 x = x << bits # 1 << 4 :- 00010000 x = x - 1 # 00001111 x = x...
6c1d6adee7f81fb610125fbac5f19699967369c9
ipero/python_learning_curve
/codecademy/practice.py
2,826
4.21875
4
# Write a function called digit_sum that takes a positive integer num as input # and returns the sum of all that number's digits. def digit_sum(num): digit_sum = 0 number = str(num) for digit in number: digit_sum += int(digit) return digit_sum print digit_sum(1234) # find factorial of positiv...
506cd8f9e544ba0476545832c72e55fec806d660
ochtersk/CHEMBOX
/refdata/DataUnits.py
7,599
3.953125
4
from collections import Counter from pprint import pformat class DataUnits(): """ A class used to represent Units for DataValue calculations Attributes ---------- units : a list of 2 lists the first list is a list of strings representing numerator units the second list is a list of...
1959c4f1d51e64d01600c0a971aba6aa30542c6f
romainjln/Functionnal-Programming-Python
/FP-graph_solver.py
6,242
3.96875
4
import unittest from functools import reduce # Iterates function f on x until the result verifies the condition p. def loop(p, f, x): return x if p(x) else loop(p, f, f(x)) # Returns True if set s contains an element x such that p(x) = True. def exists(p, l): return any(map(lambda x: x if p(x) else None, l)...
15fa909ecfa083242e1f84ef90f749b2fd8a519f
Bahram3110/d9_w2_t4
/task2.py
221
4
4
given_number = int(input()) if (given_number % 3 == 0) and (given_number % 5 == 0): print("HahaHoo") elif given_number % 3 == 0: print("Haha") elif given_number % 5 == 0: print("Hoo") else: print ("Aaaaa")
32ac3469be946e0407d4c2b7e2d4a246dbc8f5cf
zukapa/basePython
/L5/2.py
265
3.78125
4
with open('small_text.txt', 'r', encoding='utf=8') as my_file: lines = 0 for line in my_file: lines += 1 num_words = line.split() print(f'{line.strip()} - {len(num_words)} сл.') print(f'Всего {lines} строки')
0d9f9f3c4fd56002f9e7af5bd6d674787d8bfd7f
zukapa/basePython
/L4/5.py
157
3.609375
4
from functools import reduce def my_f(num1, num2): return num1 * num2 print(reduce(my_f, [num for num in range(100, 1001) if num % 2 == 0]))
79c1af240892af8296c60a965cc115dc47087605
zukapa/basePython
/L4/4.py
128
3.59375
4
my_list = [23, 4, 8, 8, 29, 2, 2, 2, 9, 4, 7, 11] new_list = [el for el in my_list if my_list.count(el) < 2] print(new_list)
90b45e70f7d1d9dc60608f5bb627fe6665260259
zukapa/basePython
/L1/3.py
140
3.65625
4
n = int(input('Введите число n ')) n1 = str(n) + str(n) n2 = str(n) + str(n) + str(n) n3 = int(n) + int(n1) + int(n2) print(n3)
c1b357c86469cda40184b17fdeec7a049b48f26b
pavelrosh/Checkio_task
/Sun_angle.py
711
3.890625
4
def sun_angle(time): delta = 90 / 6 delta_second = delta / 60 hours, minute = time.split(":") # print(int(hours), int(minute)) hours = int(hours) minute = int(minute) if (hours == 6 or hours == 18) and minute > 0: return "I don't see the sun!" if hours >= 6 and hours <= 18: ...
4d42c5522c39e799cdfcb0a23ed3e35c85693677
Inamdarpushkar/OOP_warmup
/1.py
491
3.9375
4
# Pyhton Object Oriented Programming class Employee: def __init__(self,first,last,pay): self.first=first self.last=last self.pay=pay self.email=first+'.'+last+"@company.com" def full_name(self): return ('{} {}'.format(self.first,self.last)) emp_1=Employee('Chinmay','D...
f99a23a1600982536589eae2f2deaf9cc1215d0b
SoccerAL29/Frog1
/untitled2/venv/print stars 2.py
87
3.953125
4
for i in range(3): for j in range(2): print("This is i:",i, "This is j:",j)
33889eb718ecf4548956311a0b3e9d11e6e8057a
3a-ia-ensc/track-rl
/src/Vector.py
1,729
4.09375
4
# -*- coding: utf-8 -*- """ Vector.py """ __author__ = "Simon Audrix and Gabriel Nativel-Fontaine" __credits__ = ["Simon Audrix", "Gabriel Nativel-Fontaine"] __copyright__ = "Copyright 2021, Apprentissage par renforcement" __version__ = "1.0.0" __email__ = "gnativ910e@ensc.fr" __status__ = "Development" from math im...
89254bc26646ab7df2627e0353710744b4b407a2
Smar-Ben/puissance4
/power4.py
11,488
3.78125
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 1 20:11:09 2020 @author: Benoit """ from random import randint class Board: def __init__(self): #nombre de ligne self.row = 6 #nombre de colonne self.col = 7 #tableau de jeu self.tab = [ [ ' ' for i in rang...