blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a7d42e6cc743f485f88ef9bacd8fe61c0876a89b
EzzeldinIsmail/Graphics
/turtle/lsystem.py
1,532
3.515625
4
""" Made by Ezzeldin Ismail This is a program which uses the l system to draw fractals. The l system works by having a starter string and changing it iteratively using a set of rules. To learn more about the l system you can go to: https://en.wikipedia.org/wiki/L-system To test it out just uncomment the type o...
bea091b2a0031607cd56e29077a14e81b06ca98a
alsgh4098/workspace_python
/venv/pkg/1__/01_module_variable.py
4,810
3.953125
4
#module_variable.py a = 3 b = 2 print(a+b) a = "hello" print(a) print(a*2) # hellohello #print(a-2) # error print('A') print('B') print('C') #파이썬에는 \n print마지막에 항상 숨어들어있다 #아래처럼 end를 없애주면 \n이 사라진다. print() print('A', end='') print('B', end='') print('C', end='') print('\n''a''b''c') print() print('A', end='\t...
926627eff061996e69848a9d890ac41551180768
robinnpark/Girls_Who_Code
/turtleShapes.py
1,041
4.53125
5
from turtle import * import math # Name your Turtle. #t = Turtle() # Set Up your screen and starting position. setup(500,300) #x_pos = -250 #y_pos = -150 #t.setposition(x_pos, y_pos) ### Write your code below: def drawnShape(turtle,sides,color): turtle.pencolor(color) drawnSides = 0 angl...
fff5acf768aaf416b4c13aa208aea36051cde72b
grollins/HP_lattice
/hplattice/Chain.py
16,068
3.609375
4
from numpy import array, zeros, int32, r_, append, sqrt, sum from .util import vec2coords, check_viability, compute_energy, is_nonsym, \ do_shift DTYPE = int32 class Chain(object): """ The 2D HP lattice chain. The chain is defined by monomers (beads), which can be either Hydrophobic (H...
fa8618770d6199b6e348c125a013c92c2ca63698
grollins/HP_lattice
/hplattice/Trajectory.py
2,092
3.8125
4
def open_file_stream(filename): """ Helper function to open a file for writing. :param str filename: open this path for writing """ return open(filename, 'w') class Trajectory(object): """ *Trajectory* objects write chain coordinates to output streams. They used to record the progress...
2775bddb536c4f7246a79c2f6a64a2f09b39ead1
lkuligin/quotes
/examples/grad_descent.py
2,938
3.859375
4
import numpy as np import pandas as pd from ggplot import * import traceback path = "C:/Users/kuligin/Downloads/turnstile_data_master_with_weather.csv" def normalize_features(df): #Normalize the features in the data set. try: mu = df.mean() sigma = df.std() df_normalized = (df - df.mean()) / df.st...
ed3f2ce04308ae2739acb813861e999a97c05b51
ZomkeyYe/Python-Learning
/test/test142.py
672
3.859375
4
import matplotlib.pyplot as plt import numpy as np import math import random x_r = [] y_r = [] def fractal(x0,x1,y0,y1,sp): l = math.sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)) if l<2 or sp>=9 : x_r.append(x0) x_r.append(x1) y_r.append(y0) y_r.append(y1) return r = random.r...
84dc49de3dccb98295d1cfe0d6ed8ad92196e084
ZomkeyYe/Python-Learning
/test/test123.py
381
3.53125
4
def party(lis): if lis[2] >= (lis[0]+lis[1])*2: return lis[0]+lis[1] else: return sum(lis)//3 if __name__ == '__main__': while True: try: T = int(input()) for i in range(T): lis = list(map(int,input().split())) lis.sort() ...
7809cbf02b1ee2b7df7449525a09bca939bca4fd
ZomkeyYe/Python-Learning
/test/test19.py
156
3.5625
4
# 正则表达式 import re line = "Cats are smarter than dogs" matchObj = re.match( r'.* are .*', line, re.M|re.I) if matchObj: print(matchObj.group())
4752b57970eaebb7a31e1d608c9985949980a72a
ZomkeyYe/Python-Learning
/test/test65.py
452
4
4
# 最长对称子字符串 def zomkey(str1): maxi = '' if len(str1) <= 1: return str1 else: for i in range(len(str1)): for j in range(len(str1)-1,i,-1): strr = str1[i:j+1:] if strr == strr[::-1]: if len(maxi)<=len(strr): ...
c3c2c0c5807fd696e15ffe6883ac9c71ea657b15
ZomkeyYe/Python-Learning
/test/test72.py
856
3.828125
4
# 群发问题 def zomkey(name,group): group = group.split(",") if name in group: return group else: return 1 def zomkey1(group1,group2): flag = False for i in group1: if i in group2: flag = True return list(set(group1+group2)) break if flag ==...
d1565b76d17dd97eba5c609862abfe1577cf4934
ZomkeyYe/Python-Learning
/test/test135.py
254
4.0625
4
#右下三角格式输出九九乘法表 # n = int(input()) n=9 for i in range(1,n+1): for k in range(1,n+1-i): print(end=" ") for j in range(1,i+1): product=i*j print("%d*%d=%2d" % (i,j,product),end=" ") print()
18bd11e51119301264826449c693c8b221dfd325
ZomkeyYe/Python-Learning
/test/test96.py
525
3.5
4
# 空汽水瓶 def main(n): if n == 1: return 0 flag = n//3 count = flag remain = n%3 noo = flag + remain while flag >0: flag = noo//3 remain = noo%3 count += flag noo = remain + flag if noo ==2: count += 1 return count if __name__ == '__main__': ...
85e0210c8d832ab51311f6f3c7bf58bbd08c51fb
noooxxi/python
/proj1.py
387
3.53125
4
import random import sys import os str1 = "funny life hack" str2 = "you guys be the judge" var1 = 0 var2 = 42 print("watch this") print(var1) print("dont know about the if tags but if the above displayed a zero then it worked") print("ok so check this out im gonna combine var3 with the next string") print("what...
ba98eecbdf1a6182de2a84ceae6be189c0e3acc2
raphaelkhan8/ParcelPathFinder
/hashtable.py
2,246
3.765625
4
# Implementation of a hash table (will be used for storing package data): # Class for individual hash table entry object class HashTableEntry: # Constructor def __init__(self, key, value): self.key = key self.value = value # Class for hash table data structure class HashTable: ...
586691b1cc3ae51c0c9f5eca88a9d6a9c5913e8d
DCapella/python-queues-stacks
/solution.py
664
3.9375
4
######################### # !!! SOLUTION CODE !!! # ######################### import sys class Solution: """Stacks and queues""" stack = [] queue = [] def pushCharacter(self, c): """Adds a chracter to the stack list""" self.stack.append(c) def enqueueCharacter(self, c): ""...
ac16398d33aa0d9b12dbe02eff43f159becb2404
bharathkumarmani/pythonProgram
/BasicPythonProgram/HollowRightAngleTriangle.py
227
4.0625
4
n = int(input("Enter the number of row's :")) for row in range(n): for col in range(n): if( col == 0 or row == n-1 or row == col ): print(row, end="") else: print(end=" ") print()
c221d39b7c785f21b1ba8f7093fdc91f9b3b7301
vncntcmnn/NBA-sim
/simulation/game.py
1,700
3.53125
4
import pandas as pd import random as rnd import numpy as np class GameNaive: """Game class to play a game between two teams. Scores for each one are sampled from a normal distribution using their past season scores. Args: teams_update (bool): Either to update the teams scores after a ga...
4e4fab379ff3053694f4ef62972a689943ee2e0c
70750/20190617
/entrance/P64_caculate.py
2,264
4.28125
4
''' print(3+5) print(3-5) print(3*5) print(3/5) print(3%5) print(5%4) print(3//5) print(7//3) print(2**3) print(4**3) a = 17 b = 15 c = 3 print("-------------") print(a+b) print(a-b) print(a*b) print(a/b) print(a%b) print(b%c) print(a//c) print(b//c) print(b**c) print("%%%%%%%%%%%%%") print("M"*10) print("@"*10) prin...
4579cab2145a02ef5b246582f2178bad0aa91d69
saloschiavo/PA4
/Map.py
2,279
4.0625
4
from HashTable import HashTable class Map(HashTable): def __init__(self, size=11): ''' The map inherits its first list from HashTable class, and adds second list of its own as child class ''' super().__init__(size) # holds keys # holds values self.values =...
8cdf823903784ac56d1a71c57fbf46bc27ecab1a
anonimato404/python
/ultiplayground/oop/animal.py
562
3.59375
4
class GenericAnimal: def __init__(self, name, speed=0) -> None: self.name = name self.speed = speed def __str__(self): return f"{self.name} is happy :)" def run(self, speed): self.speed = speed print(f"{self.name} runs with speed {self.speed}.") def stop(self):...
b4d8f163862748375409a4137adc9d4d6e5550a3
omar-jandali/movieProject
/movie.py
867
3.5625
4
import webbrowser #this is the class that will be used to create instances of each #movie that is going to be created class Movie(): VALID_RATINGS = ["G", "PG", "PG-13", "R"] #the init function is the main fuction that is going to be called when #the Movie class is called. and all of the variables are goi...
be645fd3aa501462916035bef040d55d89cdfd07
Hiteek/Hello_world_in_python
/class_2/if_else.py
1,130
4.15625
4
# x = 'Anthony' # Pedro tiene x años # print('Pedro tiene', x, 'años.') # # print('PEdro tiene {} años'.format(x)) # # print(f'Pedro tiene {x} años') # print(type(x)) # Operadores aritmeticos # x = 10 # print(x) # x = x + 5 # print(x) # x = x - 7 # print(x) # x = x*3 # print(x) # # x = x/5 # # print(x) # # x += 5 # #...
0fa541dc157ce16ad55e5211e88459eaaccc67b9
SatishMurthy/Python-Practice
/Hackerrank scripts.py
3,468
4.125
4
# #Polar Coordinates # # import cmath # # cnum = input('Enter complex number a+ij: ') # # #complex(input()) # # polarcoord = cmath.polar(complex(cnum)) # # for n in polarcoord: # print(round(n,3)) # #Average of distinct numbers from a given set of numbers # def average(array): # # your code goes h...
5c2a5d9247865c0c85abb73f3e05492a5838b92e
poketoff/python-register
/epic-register.py
631
3.5625
4
name_File = input("Введите имя txt файла(с расширением .txt): ") file = open(name_File, "w") first_Name = input("Введи имя: ") file.write(first_Name + "\n") second_Name = input("Введи фамилию: ") file.write(second_Name + "\n") login_Name = input("Введи логин: ") file.write(login_Name + "\n") email_Nam...
5b9fc14880812bfae0f9a455e58d2782eec4f18c
yuzumei/leetcode
/105.py
1,997
3.84375
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 buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode: '''前序:HGEDBFCA 中序:EGBD...
322956b6fabc1e42063e2acef53d30429f01a6e4
yuzumei/leetcode
/33.py
286
3.609375
4
def find(): nums = [4,5,6,7,0,1,2] target = 0 if not nums: return -1 left=0 right=len(nums)-1 while left<=right: mid=(left+right)//2 if nums[mid]==target: return mid if nums[0]<=nums[mid]: if print(find())
87e03935eede951621ca5feed9344a5080a8d8c3
yuzumei/leetcode
/224.py
1,347
3.59375
4
s = "-(1+(4+5+2)-3)+(6+8)" class Solution: def calculate(self, s: str) -> int: stack=[] stacknum=[] stack1=[] temp='' s='('+s+')' for alpha in s: if alpha=='(': stack.append(alpha) if len(stack1)!=0: stac...
64de0d93431e4ff7e9c26b561fa8de2d3aa08161
yuzumei/leetcode
/92.py
648
3.6875
4
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def reverseBetween(self, head: ListNode, left: int, right: int) -> ListNode: ans=ListNode(-1) temp=[] cnt=1 memo=0 while head: if cnt==left: ...
ee9799cb7d3bb9c7ac9b978ce8aebbda15b8d009
yuzumei/leetcode
/46.py
230
3.75
4
nums=[1,2,3] ans=[] def combine(a,b): if not a: ans.append(b) return for item in a: temp=a[:] temp.remove(item) tempb=b+[item] combine(temp,tempb) combine(nums,[]) print(ans)
b333055088cf4b8887f9d4ac1b2bc97a5635644f
yuzumei/leetcode
/快速排序.py
342
3.984375
4
def quicksort(temp): if len(temp)<2: return temp left=[] right=[] x=temp[0] temp.remove(x) for item in temp: if item>x: right.append(item) else: left.append(item) return quicksort(left)+[x]+quicksort(right) x=[5,6,8,1,4,6,9,7,4,2,6,7,10,3,5,4,9...
862748d4f2f2b91f6fa59c8cdd458ea5179b6a66
yuzumei/leetcode
/50周双周赛/5772.py
363
3.5625
4
class Solution: def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool: a,b,c = '', '', '' for s in firstWord: a += str(ord(s)-ord('a')) for s in secondWord: b += str(ord(s)-ord('a')) for s in targetWord: c += str(ord(s)-ord...
997fad0e3f3dfd94fc66b4635ca6984cab51ff80
yuzumei/leetcode
/52.py
515
3.796875
4
ans=0 def backtrack(row,n,leftexist,rightlist,collist): print(collist,leftexist,rightlist) global ans if row==n: ans+=1 return else: for i in range(n): if i not in collist and row-i not in leftexist and row+i not in rightlist: tempcol=collist+[i] ...
b1cea3dcdbffc5d600c39365047ad06f8a618358
yuzumei/leetcode
/162.py
231
3.671875
4
def find(): nums = [1,2,1,3,5,6,4] left=0 right=len(nums)-1 while left<right: mid=(left+right)//2 if nums[mid]<nums[mid+1]: left=mid+1 else: right=mid return right
96d5417c33fc69c8d41e8db1032d4a360001296b
alpapie/exo-python
/tp1/exo6.py
279
3.5625
4
nbrcopie=int(input("Entrer le nombre de photocopie a effectue: ")) if nbrcopie<=10: prix=nbrcopie*35 elif nbrcopie<=30: prix=((nbrcopie-10)*25)+(10*35) else: prix=((nbrcopie-30)*15)+(20*25)+(10*35) print("pour une photocopie de",nbrcopie,"page sa vous coutera",prix)
0198510c0e26c5dce6f02628860241d4a06dbbb8
alpapie/exo-python
/tp2/exo2.py
599
3.609375
4
phrase=input("entrer votre phrase: ") tabmot=phrase.split() print("Le nombre de mot est de",len(tabmot)) maxmot='' tabmaxmot=[] for mot in tabmot: if len(mot)>len(maxmot): maxmot=mot for grandmot in tabmot: if len(grandmot)==len(maxmot): tabmaxmot.append(grandmot) print("le mot le plus long est...
be6618bfb68d1797081abee666688adb65bc98d5
alpapie/exo-python
/tp1/exo5.py
217
3.921875
4
tempEau=float(input("entrer la temperature de l'eau: ")) if tempEau<=0 : print("etat solide de l'eau") elif 0<tempEau<100: print("etat liquide de l'eau") elif tempEau >=100 : print("etat gazeux de l'eau")
754d0956b4f2a7fcb63c35d7e6f94d1d82b01ab3
alpapie/exo-python
/tp3/grphiquer2.py
1,299
3.828125
4
from tkinter import* # fenetre=Tk() # fenetre.title("Bonjour Python") # #taille d'affichage du fenetre # fenetre.geometry('780x440') # #pour modifier la taille du fenetre # fenetre.maxsize(600,600) # fenetre.minsize(300,300) # # on poeut aussi interdire la modification de la taille du fenetre # # fenetre.resizable(hei...
15f9b99df58c41a864309623e406a239ead7eaf2
alpapie/exo-python
/tp3/exo21.py
528
3.875
4
import datetime # a) Date et heure actuelles now = datetime.datetime.now() print ("date courante est : ") print (now.strftime("%H:%M:%S %d/%m/%Y ")) # b) Année en cours print("Année en cours") print(now.strftime("%Y")) # c) Mois de l'année print("Mois de l'année") print(now.strftime("%b")) # d) Jour du mois print("jou...
28f22e3cb19d1549ed2db0d5ac156d54b5e89f04
hackerbot/python-the-next-level-intermediate
/ch60-61.recursionFibonacci.py
237
3.71875
4
# # def foo(n): # # if n == 1: # # return n # # else: # # foo(n-1) # # # 1, 1, 2, 3, 5, 8, 13, 21, 34... etc # def Fib(n): if n == 1 or n == 2: return 1 return Fib(n-1) + Fib(n-2) print(Fib(5))
be1d0c11326648c8139f2fa4299720060ad6e1ca
hackerbot/python-the-next-level-intermediate
/ch38.validFunctionTryExcept.py
680
4.3125
4
# Function we will create: # - solve --> Runs thru all possible combinations of testing each for valid # - fill_in --> Create a new formula replacing letters with numbers # - valid --> Tests our filled_in String import re def valid(formula): ''' Formula is valid only if it has no leading zero on ...
289f8c19efe3f0a186fe57029868cab878bc0d32
ravi4all/PythonFebOnline_21
/Functions/10-NestedFunctions.py
291
3.609375
4
def calc(): x = 12 y = 6 def add(): z = x + y print("Sum is",z) def sub(): z = x - y print("Sub is",z) # add(), sub() return add, sub # output = calc() # output[0]() # output[1]() add, sub = calc() add() sub()
3e84a08b555660e1e03c9324e44d4157932b8619
ravi4all/PythonFebOnline_21
/ExceptionHandling/03-example.py
308
3.609375
4
import io try: file = open('file_1.txt','w') file.write("Hello world") data = file.read() print(data) except io.UnsupportedOperation: print("Cannot read/write file") except FileExistsError: print("File Already Exists ") finally: print("File closed") file.close()
05569b65d3cad6897d60ec2e81497925001f90f9
ravi4all/PythonFebOnline_21
/GUI/basic_calc.py
2,419
3.859375
4
from tkinter import * from tkinter.font import Font window = Tk() window.geometry('600x500') main_label = Label(window, text="Basic Calculator", font = Font(size=18), fg='red') main_label.pack() label_1 = Label(window, text="Enter first number", font = Font(size=16), fg...
68337458eadaa6337d92170549c05c703c8aaac2
ravi4all/PythonFebOnline_21
/stone_paper_scissor.py
993
3.984375
4
import random options = ['stone', 'paper','scissor'] Cpu_score =0 user_score=0 attempt = 0 while True: cpu = random.choice(options) print(f"Your Score is {user_score}, CPU's score is {Cpu_score}") user = str(input('Your turn :')) if user == cpu: print("Draw") elif cpu == 'stone'...
c6a687b7f4733fe519a0830654fdbdb6896a6e4e
ravi4all/PythonFebOnline_21
/strings_methods.py
4,499
3.8125
4
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> text = "hello world, this is python" >>> text[0] 'h' >>> text[0:5] 'hello' >>> text[-1] 'n' >>> text.upper() 'HELLO WORLD, THIS IS PYTHON'...
515756bb6c35a71eea4177f2e69e97bb702a42de
RAHUL1231998/odoperpython
/.gitignore/SRTDICCONV.py
167
3.625
4
def conv(x): a = dict(s.split('=')for s in x.split(';')) return a; d = str(input("enter input string :")) f = conv(d) print(f)
a71ad635e930d2a146e600f8162d9fb017b87351
novellus/age_to_achieve_various_financial_goals_as_a_function_of_savings_interest_rate
/compare_integrated_happiness_between_immediate_retirement_and_optimal_retirement_age.py
20,014
3.78125
4
import math import matplotlib import pprint import numpy as np from matplotlib import pyplot as plt from collections import defaultdict def calc_x_inflation(x_n, n, interest_rate, annual_gross_earn_rate, annual_cost_of_living, inflation_rate, earning=False): # x_n+1 = x_n * 1.01 - 70000*1.03^n # x(n+1) = x(n)...
23c34ba3db69a79e5668daae193f76af16639d05
SDasman/CWM_MachineLearning_201
/NeuralNets/simple_dense.py
2,570
3.765625
4
import numpy as np from keras import Sequential, optimizers from keras.layers import Dense # Set the random seed to something so we get the same numbers each time. # seed is the same random numbers every time. np.random.seed(113017) # Features are interesting data points we want to feed into the Neural Network as inp...
c046fc438e08c652281488b3ded1bea0bf7613f4
rclarkmorrow/trivia_maze
/application/game/room/room.py
6,286
3.71875
4
class Feature: """ This is an empty class meant to hold room features in the future. """ def __init__(self): self.__info = 'not implemented' class Room: """ This class """ def __init__(self, position, features): self.__position = position # List of x, y vertices or None ...
a2059a3d12469670e8dc1bfd81c7194c63adab22
kashifpk/smpp5
/testing/threads.py
724
3.9375
4
import threading # remember in python simple data types are passed by value and objects are passed by reference #>>> a = 1 #>>> def f(x): #... x = x + 1 #>>> f(a) #>>> a #1 #>>> class A: #... a = 1 #>>> a = A() #>>> a.a #1 #>>> a.a = 2 #>>> def f2(o): #... o.a += 1 #>>> a.a #2 #>>> f2(a) #>>> a.a #3 class...
2edb7759c8bd697707fd9ca5ff65ec53b3ae9c4b
ameya-shukla/Calculator
/calculator.py
2,730
3.671875
4
from tkinter import * expression="" def press(num): global expression expression = expression + str(num) equation.set(expression) def equalpress(): try: global expression total = str(eval(expression)) equation.set(total) expression = "" except: equation.set("Error") expression="" def clear(): g...
fb7adae7c8fbeb5f18d54b4207374b71aeff8617
EspenEnes/PracticePython-
/Exercises/24. Draw A Game Board.py
454
3.734375
4
import pygame class gameBoard(): def __init__(self, size): self.size = size self.width = self.size[0] self.height = self.size[1] def board(self): self.squearex = " ---" self.squarey = "| " self.x = self.squearex * self.width + "\n" self.y = self.squa...
8e68fc08154273f40a11f7781b41f1fbb71452a6
EspenEnes/PracticePython-
/Exercises/6. String Lists.py
278
4.1875
4
def palindrome(): word = raw_input("Give me a palindrome") invword = word[::-1] if word.lower() == invword.lower(): print "Yes, this is a palindrome # %s #" % (word) else: print "You did not enter a palindrome " while True: palindrome()
cb4deb6d209bfc05cfe51ec1800faf548c46baff
narendraparigi1987/python
/exercises/Fraction_class.py
1,015
3.734375
4
class Fraction(object): def __init__(self,num,denom): assert type(num) == int and type(denom) == int, 'Expected int but unexpected format for args' self.num = num self.denom = denom def __str__(self): return str(self.num)+'/'+str(self.denom) def __add__(self,other)...
84dd9dada02f8a4e209c4380cbc799b71cc0ee19
narendraparigi1987/python
/exercises/rock_paper_scissors.py
867
3.96875
4
import sys def main(): print 'Welcome to Rock Paper Scissor Game' while True: quit = raw_input('enter "enter" to continue: ') if quit != 'enter': break else: input1= str(raw_input('Player 1 enter your choice: ')) input2= str(raw_input('Pla...
344d040605282ed24b8e89b9510699281743d8ce
narendraparigi1987/python
/exercises/Reverse_Word_Order.py
485
3.765625
4
import sys import random def get_input(help_text='enter string: '): return str(raw_input(help_text)) def get_list(text_string): return text_string.split(' ') def get_string(list_string): return ' '.join(list_string[::-1]) def main(): print 'welcome' text_string = get_input('enter string for reve...
b1fd203a23b45973efbf4cd84ab04881ea3ea627
the5enses/ACIT2515_assignment
/assn 4/abstract_esports_player.py
2,268
3.765625
4
class AbstractEsportsPlayer: """ Maintains details of an EsportsPlayer """ def __init__(self, id, first_name, last_name, player_name, age, type): """ Initializes the attributes of an EsportsPlayer """ AbstractEsportsPlayer._validate_input_integer('ID', id) self._id = id Abstrac...
5485485a8a433fef747826765d60089e70a374fb
erikxt/leetcode
/python/LRUCache.py
1,036
3.671875
4
class LRUCache: # @param capacity, an integer def __init__(self, capacity): self.capacity = capacity self.record = [] self.cache = {} # @return an integer def get(self, key): if self.cache.has_key(key): self.record.remove(key) self.reco...
78dbab5a3b709d87dff484e5dd687c58ac52ec32
sandychn/LeetCode-Solutions
/Medium/0071-simplify-path.py
352
3.75
4
class Solution: def simplifyPath(self, path: str) -> str: path_list = [] for name in path.split('/'): if name == '..': if path_list: path_list.pop() elif name != '.' and name != '': path_list.append(name) re...
b83b448c54b1ee6a2c7e85cfa372b8fbd4e6b1d5
sandychn/LeetCode-Solutions
/Algorithms/LinkedList/0082-remove-duplicates-from-sorted-list-ii.py
773
3.640625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def deleteDuplicates(self, head: ListNode) -> ListNode: last = dummy = ListNode() ignored = None while head: ...
6193a38ca21e960d8da9d24d221c9132851aaca1
nimRobotics/SpriD
/Additional/uitest2.py
3,194
3.9375
4
# https://likegeeks.com/python-gui-examples-tkinter-tutorial/ from tkinter import * # for using combobox from tkinter.ttk import * # for creating messagebox alert from tkinter import messagebox # for adding menu from tkinter import Menu # for Image from PIL import ImageTk, Image window = Tk() window.title("Welcome t...
5ccd7e3257b1b5dbe1d4399c21ae1021e4e7d70b
nithyagundamaraju1/the_python_workbook
/ex_14.py
202
4.0625
4
print("Enter your ht [ex: if your ht is 5 feet 3 inches, enter it as 5 3]:") ft,inch=input().split(" ") cms=(int(ft)*12*2.54)+(int(inch)*2.54) print(f"Your height in centimeters: {cms:.02f} cms")
9988d6a4c51708fd52b967bc5be2eaa0e4566fae
nithyagundamaraju1/the_python_workbook
/ex_43.py
325
3.96875
4
n=int(input("Enter denomination of a banknote: ")) if n==1: print("George Washington ") elif n==2: print("Thomas Jefferson") elif n==5: print("Abraham Lincoln") elif n==10: print("Alexander Hamilton") elif n==20: print("Andrew Jackson") elif n==50: print("Ulysses S. Grant") elif n==100: ...
07b51a702997129eb83a0d4f5517732096095e89
nithyagundamaraju1/the_python_workbook
/ex_51.py
734
4.25
4
g=input("Enter your grade:") if g=='A+' or g=='a+': print("Grade points: 4.0") elif g=='A' or g=='a': print("Grade points: 4.0") elif g=='A-' or g=='a-': print("Grade points: 3.7") elif g=='B+' or g=='b+': print("Grade points: 3.3") elif g=='B' or g=='b': print("Grade points: 3.0") elif g=='B-...
f22b76a919e40d190932fa9394cf9f77de065b10
nithyagundamaraju1/the_python_workbook
/ex_68.py
258
4
4
p=input("Enter 8 bits:") while p!= " ": if p.count("0")+p.count("1") !=8 or len(p)!=8: print("Not eight bits!") else: ones=p.count("1") if ones%2==0: print("Parity is 0") else: print("Parity is 1") p=input("Enter 8 bits:")
85db5cff53e299ea2d8804d67ee9bd83026481e1
nithyagundamaraju1/the_python_workbook
/ex_82.py
285
3.65625
4
BASE = 4.00 VARIABLE = 0.25 def taxi_fare(dist): units = (dist*1000) / 140 total = units * VARIABLE total = total+BASE return total dist=float(input("Enter distance in kms: ")) fare= taxi_fare(dist) print(f"The fare is $ {fare:.02f}")
5bab6df3d4aafbaf77871fe4617299cef7404c2c
nithyagundamaraju1/the_python_workbook
/ex_33.py
276
3.71875
4
n=int(input("Number of loaves of day old bread being purchased:")) print("Regular price: $3.49 each") reg=n*3.49 dis=((60/100)*3.49)*n tot=reg-dis print(f"Regular Price: ${reg:.02f}") print(f"Discount Rate: ${dis:.02f}") print(f"Total Price : ${tot:.02f}")
0b154658d28ce0b74206d4b56f4725b3db131fad
nithyagundamaraju1/the_python_workbook
/ex_72.py
195
4.09375
4
str=input("Enter palindrome:") pal=True for i in range(0,len(str)//2): if str[i] != str[len(str)-i-1]: pal = False if pal: print("Palindrome!") else: print("Not a Palindrome!")
a1418b8d7fec41f11acbcbb26d33d3b1bf4a0510
nithyagundamaraju1/the_python_workbook
/ex_11.py
134
3.703125
4
mpg=float(input("Enter the fuel efficiency in mpg: ")) cu=235.214583/mpg print(f"Fuel efficiency in Canadian Units is {cu:.02f} ")
1f5b364565b3efdf36340e85aa8ae2f7611b2df8
nithyagundamaraju1/the_python_workbook
/ex_25.py
221
3.765625
4
secs=int(input("Total duration in seconds:")) days=secs//86400 secs =secs%(24*3600) hrs=secs//3600 secs = secs%3600 mins=secs//60 secs = secs%60 print(f"Equivalent Time: {days:02d}:{hrs:02d}:{mins:02d}:{secs:02d}")
f8aaba6e78b82080c96708190c1d3802519530da
arvindsrikantan/ReinforcementLearning
/value_policy_iteration/deeprl_hw1/rl.py
19,188
3.59375
4
# coding: utf-8 from __future__ import division, absolute_import from __future__ import print_function, unicode_literals import numpy as np def print_policy(policy, action_names): """Print the policy in human-readable format. Parameters ---------- policy: np.ndarray Array of state to action nu...
9ca7ff4ee4dd31b2bc985beb8823ceeca6fd5195
acexyf/pythonLearning
/base/functional.py
272
3.640625
4
from functools import reduce def double(x): return x*x print(list(map(double, [1,2,3,4]))) print('') def fn(x,y): return str(x)+str(y) print(reduce(fn, [1,2,3,4])) print('') def is_odd(n): return n%2==1 print(list(filter(is_odd, [1,2,3,4,5,6,7,9])))
ebf6e747967d1feb1742fd6c715fa260781f3ad2
acexyf/pythonLearning
/base/func.py
495
3.578125
4
import math def move(x, y, step, angle = 0): nx = x + step * math.cos(angle) ny = y + step * math.sin(angle) return nx, ny x,y = move(100,100, 60, math.pi/6) print(x,y) print('') def quadratic(a, b, c): x1 = 0 x2 = 0 if a == 0: x1 = -b/c x2 = -b/c else: delt = ma...
3c8f7a627fe51c23a53b06709da09b280bc85aef
acexyf/pythonLearning
/base/class.py
325
3.765625
4
class MyClass: """一个简单的类实例""" i = 12345 def __init__(self): self.data = ['1'] def f(self): return 'hello world' # 实例化类 x = MyClass() # 访问类的属性和方法 print("MyClass 类的属性 data 为:", x.data) print("MyClass 类的方法 f 输出为:", x.f())
401269081f8e3f3071bd87fe76c19b607d30fac5
ChaksUdacity/Openstreet-map
/audit_office.py
3,867
3.59375
4
""" Your task in this exercise has two steps: - audit the OSMFILE and change the variable 'mapping' to reflect the changes needed to fix the unexpected office types to the appropriate ones in the expected list. You have to add mappings only for the actual problems you find in this OSMFILE, not a generaliz...
38868acef093875864bee0e833906c267543b8c5
septem776/LeetCode
/python/Balanced Binary Tree.py
657
3.71875
4
# Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # @param root, a tree node # @return a boolean def isBalanced(self, root): if root is None: return True diff = ...
08876b1b00e7b785881c9496ecac5fe61761112d
samskinn/Projects
/Numbers/bidec.py
828
4.34375
4
#Create a converter that changes binary numbers to decimals and vice versa def b_to_d(number): var = str(number)[::-1] counter = 0 decimal = 0 while counter < len(var): if int(var[counter]) == 1: decimal += 2**counter counter += 1 return decimal def d_to_b(number): binary = '' while num...
7cf2b63a1eea470165fb8c3988cfc6ce53bfc903
noaisr1/PythonMinesweeperGame
/minesweeper.py
5,444
3.734375
4
""" Student: Noa Israeli ID: 316392356 Assignment no.: 4 Program: minesweeper.py """ import random def makeBoard(n): board = [[0 for column in range(n)] for row in range(n)] return board def makePlayerBoard(n): playerBoard = [[' ' for row in range(n)] for column in range(n)] return playerBoard def ex...
dc4112d700f8362bae058b6e7ef34f0ec3ee1046
master-sandman/python-stuff
/classtest.py
3,062
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function class MyClass(object): myvar = "I was created at class level." def __init__(self): print("---Begin of constructor---") print(">>> MyClass.myvar: %s" % MyClass.myvar) print(">>> self.myvar: %s" % se...
5a4ee3bc5a19773b9db55240b7c6f98445e2a8e8
ldkl123/algorithm_code
/Programers/Python/before_2019_09_23/Bfs_Dfs/queue_prac.py
159
3.546875
4
#-*- coding:utf-8 -*- import queue q = queue.Queue() lst = [] lst.append(1) lst.append(2) for val in lst: q.put(val) print(q) print(q.get()) print(q)
ba62580bbe92e3f3774397a04a57b04c6b48df6b
ldkl123/algorithm_code
/Programers/Python/2019_09_30/joystick/process/joystick_1_2.py
1,296
3.78125
4
# Developed by "DoKyu Lee" # Date: 2019.09.30 # Version: 1.2 def solution(name): answer = 0 name = list(name) for al in name: answer += alpha(al) answer += move(name) print(answer) return answer # Counting changing alphabet joystick operation def alpha(alphabet): al = ord(alph...
6a6acbd401d69d31ccb636102b81f3517284d90d
ldkl123/algorithm_code
/Baek/2019_09_23/Python/process/maze/maze_1_3.py
1,466
3.625
4
# Developed by "DoKyu Lee" # Date: 2019.09.22 # Version: 1.3 import queue r, l = map(int, input().split(" ")) maze = [] #up down left right move = [(0, 1), (0, -1), (-1, 0), (1, 0)] # Added 'left' operation # Making Queue for BFS q = queue.Queue() # Making a maze for i in range(r):...
157d529e470bf96d8c9a057f539328a598be8d83
tangweejieleslie/PythonSandbox
/basics/SliceNotation.py
266
3.59375
4
# https://railsware.com/blog/python-for-machine-learning-indexing-and-slicing-for-lists-tuples-strings-and-other-sequential-types/#:~:text=One%20of%20the%20reasons%20it's,add%20its%20support%20as%20well. list = [0,1,2,3,4,5,6,7] print(list[1:4]) print(int("10",2))
62065523c30ef83683a788e2067189b9f88ba743
Shanukusai/python_basics
/lesson02/task0202.py
792
4.5
4
# Для списка реализовать обмен значений соседних элементов, т.е. # Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т.д. # При нечетном количестве элементов последний сохранить на своем месте. # Для заполнения списка элементов необходимо использовать функцию input(). my_list = list(input('Введите свое имя:...
0cbe34f30d31c26ebc7dd542270a80134e91451d
Shanukusai/python_basics
/lesson04/task0405.py
671
4.15625
4
# Реализовать формирование списка, используя функцию range() и возможности генератора. # В список должны войти четные числа от 100 до 1000 (включая границы). # Необходимо получить результат вычисления произведения всех элементов списка. # Подсказка: использовать функцию reduce(). import functools print("The multiplic...
b216461815a65db502d1dd3f1570a66fc1560c1a
Shanukusai/python_basics
/lesson05/task0501.py
593
4.125
4
# Создать программно файл в текстовом формате, записать в него построчно данные, вводимые пользователем. # Об окончании ввода данных свидетельствует пустая строка. with open("task01.txt", "w", encoding='utf-8') as f_obj: string = input('Enter to write to the file. To finish, the line must be empty. ') while st...
f6ed182afb51a078c909e4a231af8c908f5b23b3
Shanukusai/python_basics
/lesson03/task0302.py
1,300
4.09375
4
# Реализовать функцию, принимающую несколько параметров, описывающих данные пользователя: # имя, фамилия, год рождения, город проживания, email, телефон. # Функция должна принимать параметры как именованные аргументы. Реализовать вывод данных о пользователе одной строкой. # Это универсальненько # def user_data(**kwar...
6b9d69aecfce4294b8c5abc481ff1380f4c7a164
MSalarkia/python_data_structures
/datastructures/stack/stack.py
751
3.578125
4
__all__ = ['EmptyStackException', 'Stack'] class EmptyStackException(Exception): pass class Stack: """ this class implements stacks using a python list which is not ideals """ def __init__(self): self._items = [] def push(self, item): self._items.append(item) def pop(s...
83d42e2d488b0665ba90b7609c0b4d8798b4ba03
faellacurcio/rp
/TR3_RP/rp_elm_class.py
1,716
3.828125
4
import numpy class ELM: """ ELM Class functions: -fit(x,y) -test(x) """ def __init__(self, neurons, a=1): """ neurons number of hidden neurons a const value of sigmoid funcion """ self.neurons = neurons self.a = a self...
48d436d80b5022f83ea6f5ea6170c2c9d2aa7504
kszpakowicz/Binary_Search_Py
/SZPAKOWICZ_3.2.py
1,327
4.21875
4
#Binary Search function #Takes two input parameters - a text file and a int value #Searches for the value within the text file using a binary search algorithm #Returns the numbers of comparisons done and the index position of the value #(or -1 if not found) def biSearch(file, value): nList = list(map(int, fi...
e84df238379c28b828cf05ec9c8b509cc79557bf
Capcode98/exercicios-PYTHON3-MUNDO2
/exercicios060.py
155
3.890625
4
n = int(input('digite um numero do qual vc queira o seu fatorial: ')) k = n c = 0 while (n + (- c) - 1) != 1: k = k * (n + (-c)-1) c += 1 print(k)
06f2d1379af7566156459e2c93ce60d6dfca5952
Capcode98/exercicios-PYTHON3-MUNDO2
/exercicios039.py
384
3.921875
4
d = input('em qual dia vc nasceu?') m = input('em qual mes vc nasceu?') a = int(input('em qual ano vc nasceu?')) if a < 2002: print('voce ja deveria ter se alistado a {} anos'.format(((a-2002) ** 2) ** (1/2))) elif a > 2002: print('voce vai ter que se alistar daqui a {} anos'.format(((a-2002) ** 2) ** (1/2))) e...
e1de826436d2ebf03837114b134ccbf7aa0ba194
Capcode98/exercicios-PYTHON3-MUNDO2
/exercicios040.py
222
3.90625
4
n1 = float(input('qual a primeira nota?')) n2 = float(input('qual a segunda nota?')) m = (n1 + n2) * (1/2) if m < 5: print('reprovado!') elif 5 <= m < 7: print('recuperação!') elif m >= 7: print('aprovado!')
00f85eb980358431eeab902ee4268c8d5c855efd
Capcode98/exercicios-PYTHON3-MUNDO2
/exercicios069.py
701
3.625
4
ch = 0 mm20 = 0 pm18 = 0 while True: nome = str(input('Qual seu nome? ')).strip().lower().capitalize() idade = int(input('Qual sua idade? ')) sexo = '' while sexo != 'M' and sexo != 'F': sexo = str(input('Qual seu sexo?[M/F] ')).strip().upper() if idade < 20 and sexo == 'F': mm20 += ...
168b4ff9425dd4c571bd70f2fe37af12dccbedd6
Capcode98/exercicios-PYTHON3-MUNDO2
/exercicios051.py
161
3.90625
4
n = int(input('qual o inicio da pa?')) f = int(input('qual o ultimo termo da pa?')) r = int(input('qual a razão da pa?')) for c in range(n, f, r): print(c)
f6f506012590d78ac8f85e1be729fb8caf53dd71
vikashresources/CrackTheCode
/BigO.py
2,067
4.21875
4
''' Complexity - O(n) time and O(n) space For stack, it would require O(n) space and as if we need to create a array of size n. Each of these calls is added to the call stack and takes up actual memory ''' def get_sum(n): if n <= 0: return 0 return n + get_sum(n - 1) print(get_sum(5)) '''In below f...
40b3b79c25baf6db8a38c8fc99de914dae335a91
zbentley/laz-teaching
/materials/25-08-15-sorting_and_oop_multilanguage/sort.py
815
3.6875
4
#!/usr/bin/python class MyThing: value = None def __init__(self, value): self.value = value def getValue(self): return self.value a = [ MyThing(num) for num in (1, 3, 2, 5, 4) ] ############ Begin Sorting ####### # Must be at head of list val = 5 nothing_changes = 0 first_goes_after_last = 1 last_goes_...
1f22d9ec067fef28391311101b587b0da3f72bce
Mahantesh1729/python-36
/Activity_03.py
247
4.03125
4
>>> string1="Good " >>> string2="morning\n" >>> concatenated_string=string1+string2 >>> print(concatenated_string) Good morning >>> print(concatenated_string*5) Good morning Good morning Good morning Good morning Good morning >>>
4ee4f4427a9dc2dae57b192af5f97b85b13e3f39
Pangm/OJ
/coding-interviews/9 Fibonacci/JumpFloor.py
2,161
3.609375
4
# -*- coding:utf-8 -*- class Solution: def jumpFloor(self, number): # write code here # return self.jumpFloor_loop(number) return self.jumpFloor_formula(number) def jumpFloor_loop(self, number): # write code here if number == 0: return 1 eli...