blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a0a1f6693a48f937ec924e25e06ea4749e9b93fa
malyenovska/HW1
/hw5.py
639
3.546875
4
import sys, csv def parse(filename: object, bed: object) -> object: max_list = [] with open(filename) as csvfile: reader = csv.reader(csvfile, delimiter=',') for each in reader: try: max_list.append([each[0], int(each[3])/int(each[1])]) except: ...
f828d6d18f3db7f8ee8e861dab3a95655b783f08
bangarangler/Whiteboard-Pairing
/ClimbingStairs/climbingStairs.py
590
3.71875
4
def naive_climb_stairs(n): if n < 0: return 0 elif n == 0: return 1 else: return naive_climb_stairs(n-1) + naive_climb_stairs(n-2) + naive_climb_stairs(n-3) def memoized_climb_stairs(n, cache): if n < 0: return 0 elif n == 0: return 1 elif cache[n] > 1: return cache[n...
6402cdeec4c80f38daefd743b4f2a1ac72edddbb
nsrhkr/data-structures-and-algorithms
/chap01/sum1ton_while.py
221
3.59375
4
# 1からnまでの総和を求める print('1からnまでの総和を求めます') n = int(input('nの値:')) sum = 0 i = 1 while i <= n: sum += i i += 1 print(f'1から{n}までの総和は{sum}です')
820a6b7580be83465d1c83cdae883bca68696669
Prit-Italiya/TheIntellegiHangman
/trial1.py
1,230
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jul 18 09:30:14 2018 @author: jayneel """ from hangman import hangman from beforegame import getword #take word randomly from database word,ngames,nsolved,nmoves,nhits,diff,z=getword() print(word) #Database Schema: Word Noofgames Noofsolved Noofmoveswh...
afeb35405358131413c1370d0b3902d75348f37b
Nikunj-kumar/Python
/Turtle_race.py
998
3.65625
4
#turle race from turtle import * from random import randint speed(20) penup() goto(-140,140) for step in range(16): write(step) right(90) forward(10) pendown() forward(150) penup() backward(160) left(90) forward(20) a = Turtle() a.color('red') ...
89b4a429818311e57f7dc2c9625929d53a491905
rkmsh/Cracking-The-Coding-Interview
/array&strings/urlify.py
799
4.0625
4
#!/usr/bin/python3 #Write a method to replace all the spaces #with '%20' #Take the string from the user que = input("Enter your string: ") count = 0 for i in range(len(que)): if(que[i] == " "): count = count + 1 #Count total spaces index = (len(que)+2*count) #Total memory required to store the new ...
d3db3363a8674e74a49470eabeeb8c1b801ba9be
rkmsh/Cracking-The-Coding-Interview
/array&strings/isunique.py
531
4
4
def main(): #question one of first exercise #Get the string from the user ans = input("Enter the string: ") check = [] #Define a list n = 0 for i in ans: if i in check: print("Duplicate!!!") #If the element already exist in the list print Duplicate n = 1 ...
e96315ab2763bcd977242245ad1aea32d2a927bb
rkmsh/Cracking-The-Coding-Interview
/Stacks_and_Queues/ThreeInOne.py
3,047
4.5
4
#!/urs/bin/python3 # # # This program implements three stacks of into a single array # # # Defining a class for the stacks class stacks: def __init__(self, stackSize): self.array = [None] * stackSize * 3 self.stackCapacity = stackSize self.first = -1 self.sec = stackSize - 1 ...
2c2c8223aaadbc68df510e5807e1575a2eb96e19
saqibwaheed786/100DayofCode
/Day20/exercise5.7.py
862
4.5
4
# 5-7. Favorite Fruit: Make a list of your favorite fruits, and then write a series of # independent if statements that check for certain fruits in your list. # • Make a list of your three favorite fruits and call it favorite_fruits. # • Write five if statements. Each should check whether a certain kind of fruit # is i...
9f1af7bb21f51d176340faadf88bbb062b787c25
saqibwaheed786/100DayofCode
/Day29/album.py
1,161
4.6875
5
# 8-7. Album: Write a function called make_album() that builds a dictionary # describing a music album. The function should take in an artist name and an # album title, and it should return a dictionary containing these two pieces of # information. Use the function to make three dictionaries representing different # al...
50917ca9dfb3867b3888407a5fd42d6b6ba778d9
saqibwaheed786/100DayofCode
/Day24/exercise6.8.py
1,123
4.03125
4
# 6-8. Pets: Make several dictionaries, where the name of each dictionary is the # name of a pet. In each dictionary, include the kind of animal and the owner’s # name. Store these dictionaries in a list called pets. Next, loop through your list # and as you do print everything you know about each pet. # --------------...
4e1e657bcbf3bec4070ef4a37244fde3e8945a59
saqibwaheed786/100DayofCode
/Day20/exercise5.10.py
1,177
4.34375
4
# 5-10. Checking Usernames: Do the following to create a program that simulates # how websites ensure that everyone has a unique username. # • Make a list of five or more usernames called current_users. # • Make another list of five usernames called new_users. Make sure one or # two of the new usernames are also in the...
461065b1118b3c95d7114c53c7fab3eb7a81bffa
saqibwaheed786/100DayofCode
/Day27/exercise7.8.py
931
4.21875
4
#7-8. Deli: Make a list called sandwich_orders and fill it with the names of various # sandwiches. Then make an empty list called finished_sandwiches. Loop # through the list of sandwich orders and print a message for each order, such # as I made your tuna sandwich. As each sandwich is made, move it to the list # of fi...
f9f20a778508e7dacbd0da63d7a2799066cb731d
tarkilhk/HongKongBus
/src/main/HongKongBusPythonDisplay/BusTimeToDisplay.py
905
3.546875
4
class BusTimeToDisplay: busNumber = '0' arrivalTime = '' distance = '' isAnError = False color = (0, 0, 0) arrivalTime24H = '' def __init__(self, busNumber='0', arrivalTime='', distance='', isAnError=False, color=(0,0,0)): self.busNumber = busNumber self.arrivalTime = arriva...
7f2469aba5773d4c6d0b872b26210efa09b13c3f
shitchell/defbench
/examples/in_depth.py
2,704
3.53125
4
import requests import defbench from pprint import pprint my_set = set() my_list = list() filled_list = [None]*10000 def populate_set(count: int = 20): global my_set for i in range(count): my_set.add(str(i)) def populate_list(count: int = 20): global my_list for i in range(count): my_list.append(str(...
8357ff717d9b7401603b2b88ba672cd602b0cf24
Masayo4/DSFSA
/src/script/getindex.py
1,450
3.609375
4
import math def get_index(dif_list): index_list =[] add_indexlist = list(enumerate(dif_list)) get_index_list = sorted(enumerate(dif_list), key=lambda x: x[1]) print(get_index_list) median_upper = math.ceil(len(get_index_list)/2) medien_lower = math.floor(len(get_index_list)/2) #print(get_...
b2df0592b23d7065d09a9a568fcaa228443d3d33
wsjswy/Alg
/sort/quick_sort.py
2,588
3.75
4
import random def quick_sort2(L, left, right): i = left j = right if (left >= right): return base = L[left] while i < j: while (i < j and base <= L[j]): j = j - 1 #此时走到L[j]比base小的地方,此时将L[j]赋值给L[i] L[i] = L[j] #此时走到L[i]比base大的地方将L[i]赋值给L[j...
a4f141275668de3a7082285d0457fe4c6323a461
dianakakoma/rock_paper_scissors
/rock_paper_scissors.py
1,271
4.4375
4
#This rock, paper, scissors game is for a computer and human. #import random module for the computer's guess import random #create a list of valid inputs options = ["rock","paper","scissors"] "rock" > "paper" > "scissors" #generate a random guess from the computer computerChoice = options[random.randint(0,2)] #as...
26b51d197839b963e7d30c97a3a458d374bc7ef4
DuSheridan/PythonFacultyAssignments
/Lab9/Plane.py
2,980
3.59375
4
from Lab9.Passenger import Passenger class Plane: def __init__(self, name, number, company, number_of_seats, destination, passenger_list): self.name = name self.number = number self.company = company self.number_of_seats = number_of_seats self.destination = destination ...
84f2816bb8777b085ae21db14581e7e6e5099e85
dmitry-uraev/stunning-chainsaw
/project_euler_python/task6.py
688
3.90625
4
""" the sum of the squares of the first ten natural numbers is 385 the square of the sum of the first ten natural numbers is 3025 hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025−385=2640. find the difference between the sum of the squares ...
4d7ec13a3f82ec391df12b0ce35ceff8499bc894
szutu/DockerImageofPython
/file1.py
63
3.578125
4
name =input('Podaj swoje imie: ') print("Witaj " + name+ "! ")
6143dff3d3c701dc71f728dbc6845c9ca7b4b10a
SuveenMekala/Hackerrank
/30 days of Code/Day 8: Dictionaries and Maps.py
280
3.5
4
import sys n=int(input().strip()) phoneBook={} for i in range(n): S=(input().split()) #print(S) phoneBook[S[0]]=S[1] #print(phoneBook) while True: k= str(input()) if k not in phoneBook: print('Not found') else: print((k+'='+phoneBook[k]))
533bca14fd5ae43536b57e6135067534eeaf2717
jbran/euler
/10-SumOfPrimes/getPrimes.py
589
3.5625
4
import math # Our initial seed of prime numbers up to 99 prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] def findPrimeUpTo(n): i = 99 while i <= n: i += 2 #only need to check odds if checkIfPrime(i): prime.append(i) retur...
b102f9a521f6f80837a6e7082e2ef18f456850eb
austin201/rpg-game
/Armor1_2.py
6,935
3.546875
4
import random # class Equipment(object): RARITY = ["Garbage","Useless","Better","Great","Amazing"] def __init__(self,eqType): self.raritylevel, self.rareMod = self.pickrare() self.eqtype = eqType def pickrare(self): x = random.randint(1, 10) if x >= 1 and x <= 2: ...
255a0b764804479314d3da975594dff1329efb8d
ekhtiar/Python_for_Informatics_Solutions
/Ex_3/Ex_3_2.py
813
4.125
4
#!/usr/bin/env python #adjust your shebang line #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 #take input from user and convert to float hours = raw_input("How ...
52da040af9a07d01b207beaf5eea1ddcd6bd8b08
poulor/SudokuSolver
/solver.py
2,419
3.921875
4
board = [ [7,8,0,4,0,0,1,2,0], [6,0,0,0,7,5,0,0,9], [0,0,0,6,0,1,0,7,8], [0,0,7,0,4,0,2,6,0], [0,0,1,0,5,0,9,3,0], [9,0,4,0,6,0,0,0,5], [0,7,0,3,0,0,0,1,2], [1,2,0,0,0,7,4,0,0], [0,4,9,2,0,6,0,0,7] ] def print_board(bd): for i in range(len(bd)): if i % 3 == 0: print(" - - - - - -...
28f006684aa121a238837d5b05b8e9cc56d54599
itamar20-meet/meetyl1201819
/lab8.py
686
4
4
import turtle from turtle import* import random class ball(Turtle): """docstring for ball""" def __init__(self,radius,color,speed,x,y): Turtle.__init__(self) self.shape("circle") self.shapesize(radius/10) self.radius = radius self.color(color) self.speed = speed self.x = x self.y = y '''self.dx = dx...
0b2cb0d989728f0c573542baf3b2fa3be381877a
rajivalbino/PyVision
/drafts/ImageProcessing/improc02.py
1,610
3.515625
4
# Image Processing basic techniques with OpenCV # Tutorial from PyImageSearch import argparse import imutils import cv2 # Argument parser ap = argparse.ArgumentParser() ap.add_argument("-i", "--image", required=True, help="input image") args = vars(ap.parse_args()) # Load img = cv2.imread(args["image"]) cv2.imshow("i...
a5011b8f62525333e527e76c2ef56fd5d6bc9498
nowcoder120/pythonThreading
/CombineFiles.py
766
3.515625
4
""" This class will attempt to use threads to read in files and locks to safely write them out to a single file """ from os import listdir from os.path import isfile, join from FileReader import FileReader import threading # constant for input directory INPUT_DIR = './inputs/' # name for thread logging THREAD_...
9d8eac841fc11e772f7edbe4e29e1a3a6c67278f
zfssn/myPython
/01.py
841
3.90625
4
''' 定义一个学生类 ''' class Student(): #定义一个空类 pass #定义一个对象 mingyue = Student() #定义一个学习Python的学生类 class PythonStudent(): #用None给不确定的变量赋值 name = 'zf' age = 18 course = ['Python','Java','Php'] #定义个一个做功课的方法 def doHomework(self): print('我在做功课') return None #查看类的内容 #print(Pyt...
efbdf3a1784490dca2d751d070954f10997f351a
ck89119/Algorithm
/LeetCode/simplify_path.py
552
4.0625
4
#!/usr/bin/python class Solution: # @param path, a string # @return a string def simplifyPath(self, path): foo = path.split('/') stack = [] for item in foo: if item == '.' or item == '': continue elif item == '..': if len(stack) != 0: stack.pop(-1) ...
c840de7f1381d450c70ec69070a6a63fcd96d39b
ck89119/Algorithm
/LeetCode/search_in_rotated_sorted_array_II.py
950
3.609375
4
#!/usr/bin/python class Solution: # @param A, a list of integers # @param target, an integer to be searched # @return an integer def b_search(self, A, target, l, r): while l <= r: mid = (l + r) / 2 if A[mid] == target: return mid if A[mid] < target: l = mid + 1 ...
630758d6469693cba639ccb8a24d224245ceb9b7
ck89119/Algorithm
/LeetCode/length_of_last_word.py
260
3.828125
4
#!/usr/bin/python class Solution: # @param s, a string # @return an integer def lengthOfLastWord(self, s): if len(s) == 0: return 0 words = s.split() if len(words) == 0: return 0 else: return len(words[-1])
bf0a94fa1bf4cf309d46e67703e05ac8583b94a8
ck89119/Algorithm
/LeetCode/convert_sorted_list_to_binary_search_tree.py
926
3.9375
4
#!/usr/bin/python # Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None cl...
6bde2cdb1c8bba0d94667a098ca514a821563ee4
ck89119/Algorithm
/LeetCode/validate_binary_search_tree.py
768
3.953125
4
#!/usr/bin/python # 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 dfs(self, root): ans1 = root.val ans2 = root.va...
a19668a78f649b68fb7fdc37e012f4373a351652
ck89119/Algorithm
/LeetCode/valid_number.py
359
3.578125
4
#!/usr/bin/python import re class Solution: # @param s, a string # @return a boolean def isNumber(self, s): reg = "^[-+]?(\d+\.?|\.\d+)\d*(e[-+]?\d+)?$" s = s.strip() if s == '': return False match = re.search(reg, s) if match: return True else: return False s = Soluti...
9e9eb5fd168ad2920d5944084d5dbc614de662b6
AnkithaBH/Python
/Basics/Palindrome.py
181
4.21875
4
num=int(input("Enter any number:")) num=str(num) num1=num[::-1] if num==num1: print("The number is a palindrome") else: print("The number is not a palindrome")
17b110823edde5af42883bd1713ba0ec59b1c71b
AnkithaBH/Python
/Basics/Greater_Smaller_2nos.py
267
4.1875
4
#Greater or smaller both can be done changing if condidtion NUM1=int(input("Enter any number:")) NUM2=int(input("Enter any number:")) if NUM1 > NUM2: print(str(NUM1)+ " is greater than "+str(NUM2)) else: print(str(NUM2)+ " is greater than "+str(NUM1))
442c64678da3bd64053dd4c2255dcf419db889b6
moraesslucas/python-escalonador
/fibonacci.py
158
3.59375
4
def f(n): if n == 0: return 0 if n == 1: return 1 else: a = f(n-1) b = f(n-2) return a + b print(f(100))
8cf831f7e5c26690ec1c157f10cc247219a51a89
dinesharsenal/Project
/CarpoolSystemProject/CarPool/CarPoolSystem.py
978
3.609375
4
''' Module Name: carPoolSystem Description: It gives multiple options to user to ceate account,login,enter carpool system,or view ratings of different drivers Last edited by:Dinesh Date:06/10/2018 ''' import Register as rg import Login as lg import carPool as cc import viewRating as vr def carpoolSystem()...
b99329229f2a6ce1eec89f7e6870a69540eaa9d6
MrVJPman/Teaching
/Other/ChallengePythonQuestions.py
4,339
3.9375
4
#Questions Source #https://docs.google.com/document/d/1-WQhkeOrW2pnnB2_jMIk6nNovlDekuyyE30zZRQ171k/edit?usp=sharing #Question 1 def not_same(data_structure_one, data_structure_two): if len(data_structure_one) > len (data_structure_two) or len(data_structure_one) < len (data_structure_one): return True ...
ebc0b4d89f60bdb5d841d4ca97c57d4c04abca17
MrVJPman/Teaching
/ICS3U1/Exercise Solutions/Exercise 8 Solutions.py
981
4.15625
4
#Question 1) Create a variable set to an empty list var = [] #Question 2) Create a second variable using the variable from question 1 and 10 values of your choice. #You shouldve created a List. var2 = var + [0,0,0,0,0,0,0,0,0,0 ] #Question 3) Use len() somehow in an READ from the left operation to retrieve the la...
6e15493219a2db869be3eb894d864c8096ce59f4
MrVJPman/Teaching
/ICS3U1/Exercise Solutions/Exercise 19 Solutions.py
2,248
4.3125
4
#Question 1) Raise a BaseException exception with a relevant error message #raise BaseException("Base Exception!") #Question 2) Create a program that calculates the reciprocal of a given integer. If the given integer is 0, then raise a ZeroDivisionError. Provide a relevant error message number = input("Enter a integ...
ce71465faf271c4a7c9fecb3bb1030cde12a8dcd
MrVJPman/Teaching
/ICS3U1/Final Assignment Calculator Milestone Solutions/Milestone 2 Solutions.py
8,907
3.71875
4
#Mr Kong's Solution to milestone 2 #Addition def add(number_1, number_2): return number_1 + number_2 assert(add(0, 0)==0) assert(add(1, 2)==3) assert(add(999,-99)==900) #Subtraction def subtract(number_1, number_2): return number_1 - number_2 assert(subtract(0, 0)==0) assert(subtract(2, 1)==1) assert(subtract(0...
f0e0670c6a2e6452047e94becd20dac0f016426e
bsagute/100DaysChallenge
/dict.py
209
3.640625
4
my_dict=dict({"name":"bhagwat",2:25,"ID":253}) print(my_dict["name"]) print(my_dict.get("ID")) dt={} dt={1:11,2:22,3:33} del dt[3] print(dt.get(1)) dt[30]=55 print(dt) dt[30]=66 print(dt.pop(2),dt)
1b8c9fdf7d501275b2010ce309e37e3bb109dc6e
bsagute/100DaysChallenge
/union.py
133
3.578125
4
A={1,4,5} B={4,5,6,7,8,9} print(A|B) print(A.union(B)) print(B.union(A)) #COMMON ELEMENT print(A&B) print(A.intersection(B))
ebefc8193aa0e2049a7b3faadad0d4c7590db0d6
bsagute/100DaysChallenge
/WelCome.py
172
3.921875
4
ip=input("Enter String") print("Upper",ip.upper()) print("Lower ",ip.lower()) # print("Join",ip.join(ip,"T")) print("Replace",ip.replace(ip,"gullu","gulshankumar"))
74f11052c7fef8983a048d437ff5b4047bc9afac
phuongtran8815/PythonDemo
/buoi1/main.py
645
3.84375
4
print('Hello everybody!') def myFuntion(): x = 5 print(x) myFuntion() y = 10 y = 15 y = 'a' def myFuntion2(): print(y) myFuntion2() a, b, c = 'Dog', 'Cat', 'Mouse' print(a, '-', b, '-', c) value = input('Vui long nhap ten nguoi dung: ') name = 'Chao mung ban ' + value + ' den trung tam...
5ed84e22d469eb1d24c435737dd053f74ba1b43b
phuongtran8815/PythonDemo
/Buoi9/Container.py
1,961
3.5
4
from datetime import date class Container(): __number = "" __height = 0.0 __inTerminalDate = "" __outTerminalEstimateDate = "" __kindOfContainer = "" __statusContainer = "" def setContainerNumber(self, id): self.__number = id def getContainerNumber(self): ret...
3d31aaba4cc0488eff6c776bc7881833543d9a3d
kulwants/Python-Practice
/Time Converter.py
2,537
4
4
h = int(input('Enter Hours: ')) if h>12: print ('Enter hours between 0-12') exit() m = int(input('Enter Minutes: ')) if m>59: print ('Enter minutes between 0-59') exit() t = int(input(' Press 1 for AM: \n Press 2 for PM: \n')) if t == 1: if m <= 59: if h <= 12: prin...
cb40d1a57b010ed122c2a8c38e172af3279c28da
YahyaAlaaMassoud/Raisa-Coding-Challenge
/coding_challenge/test/test_string_shortener.py
1,104
3.734375
4
import unittest from string_shortening_package.string_shortener import StringShortener class TestStringShortener(unittest.TestCase): def test_empty_string(self): shortened_string = StringShortener.Instance().shorten("") self.assertEqual(shortened_string, "") def test_invalid_string(self...
f9144b1608bf20e1847c3a386b79f386a92a3156
GabrielNeves18/cifra_cesar
/cifra.py
1,125
3.8125
4
def menu(): print("O que você deseja? \n1) Criptografia \n2) Decriptografia") escolha = input(">>>") if escolha == '1': frase = input("Digite digite a string: ") cifra = int(input("Digite o valor de rotação entre 1 e 9: ")) cripto(frase, cifra) elif escolha == '2': decrip...
2d6e956e1bbd6a96074fd0989a7ff200503a04e3
Alvixeon/zippitydodah
/bored.py
1,328
3.671875
4
#fuck ton of comments #import necessary things import zipfile,os #make a class called what to store this value class what(): #this one, for infinite file name generation in the form of ascending numbers xfuck = 0 #make new zip file name def newfilename(): #declare whatt as what.xfuck value w...
ae180e7e75a7762b0a2b73f8e719eda12690a270
TingFeng/CodingPractice
/HeapSort.py
3,568
4.09375
4
""" HeapSort: https://en.wikipedia.org/wiki/Heapsort Objective: Sort a list of numbers, from small to big Method: 1. build a Heap using fuction BuildHeap - Heap is a binary tree that children nodes are no bigger than parent node, the nodes in the heap is indexed from top to bottom, and from left to right. a....
984baf550f6644350a0e409b85ad17d944eadada
ursstaud/PCC-Basics
/amusement_park.py
327
3.71875
4
age = 12 if age <4: print("Your admission cost is $0") elif age <18: print("Your admission cost is $25") else: print("Your admission cost is $40") age = 98 if age <4: price = 0 elif age <18: price = 25 elif age <65: price = 40 elif age >=65: price = 20 print(f"Your admission cost is ${p...
ef80fb13c5c0a8cf052f994b0c8e23137f98fd91
ursstaud/PCC-Basics
/ice_cream_stand.py
546
3.984375
4
from restaurant import Restaurant class IceCreamStand(Restaurant): """basic example of parent child classes""" def __init__(self, restaurant_name, cuisine_type): super().__init__(restaurant_name,cuisine_type) self.flavors = ['chocolate', 'vanilla','strawberry'] def flavors_in_stock(self): print(f"...
8955783f0fcc05aa991230fe345ad2f41ad1b5ad
ursstaud/PCC-Basics
/person.py
270
3.984375
4
def build_person(first_name, last_name, age = None): """returns a dictionary about a person""" person = {'first': first_name, 'last': last_name} if age: person['age'] = age return person musician = build_person('jimi', 'hendrix', age = 27) print(musician)
f037a3abac94f1c36ee754d991f3464e53dae451
ursstaud/PCC-Basics
/sandwitches.py
323
3.609375
4
def make_sandwitch(bread, meat, cheese, *topping): """printing sandwitch order""" print(f"You have ordered a(n) {meat} and {cheese} sandwitch on {bread} bread with the following toppings:") for toppings in topping: print(f"{toppings}") make_sandwitch('gluten free','turkey','no cheese','oil','pepperoncini','avocad...
e1403afbcd473bc18804e3e28b1fa0b77ef9d204
ursstaud/PCC-Basics
/greeter_1.py
506
4.09375
4
def get_formatted_name(first_name,last_name): """return a full name neatly formatted""" full_name = f"{first_name.title()} {last_name.title()}" return full_name #this is an infinite loop while True: print("\nPlease tell me your name!") print("Enter 'q' at any time to quit.") f_name = input("First name...
593f9c21c8a946b8ec134ff611f74037c1f00697
ursstaud/PCC-Basics
/movie_tickets.py
888
4.03125
4
#movie tickets #prompt = "What is your age so I can determine the correct ticket price? Please type 'quit' to end. " #active = True #while active == True: # age = input(prompt) #this value needs to be inside the while loop to prevent an infinite loop # if age == 'quit': # break # age = int(age) # if age...
d873c597bcdeaa09f6e26e7202c0f3d6da884ebb
ursstaud/PCC-Basics
/album.py
563
4
4
def make_album(artist_name, album_title, track_count = None): """Returns a dictionary describing an album""" album = {'artist name': artist_name.title(), 'title': album_title.title()} if track_count: album['track_count'] = track_count return album beatles_info = make_album('the beatles', 'the white album'...
0a5a7026e4a7b9d0d45f79cef6ac189ad207f19b
ursstaud/PCC-Basics
/test_name_function.py
674
3.875
4
import unittest from name_function import get_formatted_name class NamesTestCase(unittest.TestCase): """Tests for 'name_function.py'""" def test_first_last_name(self): """Do names like 'Janis Joplin' work?""" formatted_name = get_formatted_name('janis', 'joplin') self.assertEqual(formatted_name, 'Jan...
f9e84149a5093c7daf5abff8b96a85d19f399c6e
farrukh482/wumpus_world
/enums/orientation.py
295
3.796875
4
from enum import Enum class Orientation(Enum): EAST, SOUTH, WEST, NORTH = 1, 2, 3, 4 def left(self): return Orientation(self.value - 1) if self.value > 1 else Orientation(4) def right(self): return Orientation(self.value + 1) if self.value < 4 else Orientation(1)
bbc8d698406fece1249837dac06fc587b26d7f2a
juabril/ProjectOne
/guessing_game.py
4,063
4.03125
4
import random #This function finds the minimum value in a list def find_min(any_list): low = any_list[0] i=0 for element in any_list: if element < low: low = any_list[i] i+=1 else: i+=1 return(low) def start_game(): LOWER = 1 UPPER =...
70840f96aef01b3e101848088efbf86d3f103bae
samyak1903/Data-Types-1
/A6.py
1,238
4.125
4
#Q.6-Implement a stack and queue using lists. choice=input("Enter 1 for stack and 2 for queue") #Stack if choice=='1': print("Stack") l=[] ch='y' while ch.lower()=='y': ch1=input("Enter 1 for push and 2 for pop element from the stack") if ch1=='1': element=input("Enter the el...
f28c1765295abc667f864fac70b453b6d2ac99bc
343GuiltySpark-04/-cautious-tribble-
/sub_conv_menu.py
297
3.59375
4
import menu import sub_menu import temp_conv def temp_conv_menu(): print("1) C to F\n2) F to C\n3) Back") user_input = int(input(": ")) if user_input == 1: temp_conv.c_to_f() elif user_input == 2: temp_conv.f_to_c() else: sub_menu.conv_menu()
a56cd10c1d5ce0e38c2672f8c496c9d3c2f0b714
anapaulalg/data-science-training
/mergingdata/ordered-merges.py
825
3.890625
4
import pandas as pd # Creating DataFrames: amsterdam = pd.DataFrame({'date': ['2019-01-01', '2019-02-10', '2019-01-15'], 'ratings': ['Rainy', 'Cloud', 'Sunny']}) london = pd.DataFrame({'date': ['2019-01-05', '2019-01-01', '2019-04-10'], 'ratings': ['Cloud', 'Cloud', 'Sunny']}) print(amsterdam) print(london) # Mergin...
ca0c299bb911d497e49c762c0501625176969d8a
ahlusar1989/various
/zipfiles.py
581
3.609375
4
import zipfile import glob, os # open the zip file for writing, and write stuff to it file = zipfile.ZipFile("C:/Documents and Settings/farringtonni/Desktop/profuel.zip", "w") for name in glob.glob("C:/Documents and Settings/farringtonni/Desktop/profuel/*"): file.write(name, os.path.basename(name), zipfile.ZIP_DE...
12bf4bac1e7d1956d5efefa47b4e863ac76d600d
mpiannucci/AdventOfCode2018
/2.1/python/main.py
781
3.71875
4
two_count = 0 three_count = 0 with open('./../input.txt', 'r') as f: for line in f: chars = {} for char in line: if char in chars: chars[char] += 1 else: chars[char] = 1 two_found = False three_found = False ...
84ed4b2acd6a02b971d1d920619bb5f57a44798b
soccerstar-texa/soccerstar-texa.github.io
/game.py
3,607
3.546875
4
import pygame import random import sys pygame.init() width=800 height=600 red=(255,0,0) blue=(0,0,255) black=(0,0,0) background_color=(0,0,0) player_size=50 player_pos=[width/2,height-2*player_size] enemy_size=50 enemy_pos=[random.randint(0,width-enemy_size),0] enemy_list=[enemy_pos] block=10 speed=10 screen=pygame.dis...
5871e105d658e46b055545accbd984aececae5ff
krucx/Graph-Theory
/prims_mst.py
1,322
3.65625
4
V = int(input('Enter number of vertices : ')) E = int(input('Enter the number of edges : ')) print('Input Specification : U V W') adj_list = [] for i in range(V): adj_list.append([]) for i in range(E): edge = list(map(int,input('Enter edge {} : '.format(i)).strip().split())) adj_list[edge[0]].append((edge...
b119891d5a9ef6b5477ca0df11231f6fd61d41ea
SuerpX/AIProjectPractice
/Towers of Corvallis/tower.py
1,327
3.609375
4
from copy import deepcopy class Tower(object): def __init__(self, a): self.pegs = [] self.parent = None self.numberOfDisks = 0 for i in range(0, 3): self.pegs.append([]) self.pegs[i] = a[i] for j in a[i]: self.numberOfDisks += 1 ...
226c701833155e235b5888e904ffc2bbca889248
Irina-Nazarova-13/SYSA-Lab1
/Lab1.py
2,353
4.5625
5
################################## # # File Name: Lab1_Group1.py # Date: Oct 4, 2021 # Authors: Henry Peng, Irina Nazarova # Description: This application will take the card number, # and using Luhn algorithm will determine if # the card number is valid...
c9a4b9731864961cf647d2bd6e3bf7e612c68926
theopmw/Love-Sandwiches
/run.py
7,218
3.640625
4
import gspread from google.oauth2.service_account import Credentials from pprint import pprint # Set scope # Lists the APIs that the program should access in order to run SCOPE = [ "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth...
077fb65a5a9a091815c60119711025c94f508aa4
rjvz/PrisonersDillema362k
/run_test.py
5,484
4.21875
4
import Prisoner # These are the "Class Variables" that store the appropriate responses for certain values, # to make the code more readable. silent = 0 talk = 1 # These are variables for the options in behavior. random = 0 # complete random behavior flip_flop = 1 # switches every time best_for_self = 2 # cho...
53a01a780b0e6b1f41923ca4d677c2c9478e053a
ultraconformist/sundry-tools
/name-tools.py
3,109
3.8125
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 26 02:22:55 2020 @author: Morgan """ class Name(object): def __init__(self, name): ''' Initializes a Name object. name (string): A name, provided as a string A Name object has two attributes: self.name (str...
cd9c53a4df18dc44ab0340610a4805ffeb890d49
Navdeep-Kalia/ansible
/Notes/python/python-only-python/exercise-2/ex10.py
162
4.21875
4
x= raw_input("please enter 3 digit number: ") number=int(x) if(number%2==0): print "Its an even number" +str(number) else: print "Its an odd number"+str(number)
7081f61db12e06d75a416c840897556cbc4b34a1
Navdeep-Kalia/ansible
/Notes/python/python-only-python/book-1/ex5.py
178
3.78125
4
total=0 def func1(num1,num2): total=num1+num2; return total; print func1(20,30);print total; sum= lambda x,y:x+y; print sum(10,20) func2= lambda p,q:p*q; print func2(23,10)
d6b88e22659a6c23936f0d5a08c8970a52c56b57
Jackson201325/Python
/Python Crash Course/Chapter 9 Classes/9-4 Number Served.py
827
3.875
4
class Restaurant(): def __init__(self, name, cuisine): self.name = name self.cuisine = cuisine self.number_served = 0 def describe_restaurant(self): print("The name of the restuarant is " + self.name.title() + " and the cuisine type is " + self.cuisine.title()) ...
0e797c6f28b8de56665ad3916ec2b182d2c7d825
Jackson201325/Python
/Self-taught Programer/Challenges/Chapter 13 The Four Pillat of Object-Oriented programming/Random/Shapes.py
458
3.84375
4
class Shape(): def __init__(self, w, l): self.width = w self.length = l def print_size(self): print("""{} by {}""".format(self.width, self.length)) class Square(Shape): def area(self): return self.width * self.length def print_area(self): print("""{} by {}""".fo...
f13971d2e6829f94cda619eb9478f207875378e1
Jackson201325/Python
/Python Crash Course/Chapter 10 Files and Exception/10-3 Guest.py
170
3.84375
4
filename = 'guest.txt' answer = input("What is your name? ") with open(filename, 'w') as f_obj: f_obj.write(answer) print("Hello " + answer + ", welcome back")
17bbe7f0e7048ff4e1f5a09b942b6a3755aec351
Jackson201325/Python
/Python Crash Course/Chapter 8 Functions/8-5 Cities.py
238
3.671875
4
def describe_city(country='Paraguay', city='Asuncion'): return "{} is in {}".format(country, city) l = [] a = describe_city() b = describe_city('Mexico', 'Tijuan') c = describe_city('England', 'London') print(a) print(b) print(c)
dd3549278913cbfc6876939cff0f823f45b15d66
Jackson201325/Python
/Python Crash Course/Chapter 10 Files and Exception/random/Is_birthday in pi.py
286
3.75
4
filename = 'pi_million_digit.txt' with open(filename) as f_obj: lines = f_obj.readlines() pi_string = '' for line in lines: pi_string += line b_day = input("Enter the date of your birthday in ddmmyy: ") if b_day in pi_string: print("we found it") else: print("no")
b3e10e6daea6d50f9b0b38c53a855e821b8de70d
Jackson201325/Python
/Self-taught Programer/Challenges/Chapter 13 The Four Pillat of Object-Oriented programming/Challenge/Challenge13.2.py
582
4.09375
4
class Square(): def __init__ (self, s): self.side = s def perimeter_Square(self): return self.side * 4 def change_size(self, ns): self.side += ns #allow us to change the value of self.side def change_size_p(self): return self.side * 4 s1 = Square(10) print("""The side...
0ae9b03ddaee73f4d27166e8eaf695e3cecb1a6a
Jackson201325/Python
/Self-taught Programer/Challenges/Chapter 13 The Four Pillat of Object-Oriented programming/Challenge/Challenge13.1.py
400
3.8125
4
class Rectangle (): def __init__ (self, l, w): self.length = l self.wide = w def perimeter(self): return self.length * 2 + self.wide * 2 class Square(): def __init__ (self, s): self.side = s def perimeter_Square(self): return self.side * 4 r1 = Rectangle(10, 2...
53bb3591705f4f89962f4c365edd07132eccb79b
Jackson201325/Python
/Python Crash Course/Chapter 9 Classes/9-6 Ice Cream Stand.py
756
3.796875
4
class Restaurant(): def __init__(self, name, cuisine): self.name = name self.cuisine = cuisine def describe_restaurant(self): print("The name of the restuarant is " + self.name.title() + " and the cuisine type is " + self.cuisine.title()) def open_restaurant(self): ...
04af852d8f47fc30f9b5bfc6237eadb2620e2b9e
DiegoGonzales11/Leet-Code-Problems
/Reverse Integer/sol.py
331
3.84375
4
def reverse(self, x): x_lst = list(str(x)) signed = False if x_lst[0] == '-': x_lst = x_lst[1:] signed = True x_lst.reverse() if signed == True: x_lst.insert(0,'-') x_str = '' for char in x_lst: x_str += char return i...
85adc459d9abef4dc014dc89e064b2211e2b41fc
kmg1905/algorithms
/computer_science/data_structures/binary_search_tree.py
1,979
3.859375
4
class BSTNode(): def __init__(self, val): self.val = val self.left = None self.right = None class BinarySearchTree(): def __init__(self): self.root = None def findMin(self, root): while root.left: root = root.left return root def search(self...
e31ebb981c3247fee9e853fdd35cb62507a7d4c0
billy1kaplan/advent-of-code-2018
/day5/solution.py
866
3.640625
4
import string def is_reactive(a, b): return (a.upper() == b.upper() and ((a.isupper() and b.islower()) or (a.islower() and b.isupper()))) with open('input.txt', 'r') as f: line = f.readline().strip() # Part 1 result = [''] for c in line: prev = result[-1] if is_reactive(prev,...
cd15aa982f4b916532e9fe6d4cba92ef2f4701ab
arpitdixit445/leetcode
/Easy/Subtree_Of_A_Tree_572.py
1,268
3.890625
4
''' Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node's descendants. The tree s could also be considered as a subtree of itself. Example 1: Given tree s: 3 ...
42577e0c2ed98503366da32049ce45b08e6b0578
iiqof/networklittle
/Learn_Threading/example3.py
656
3.765625
4
# example3.py import threading class myThread (threading.Thread): def __init__(self, name, counter): threading.Thread.__init__(self) self.threadID = counter self.name = name self.counter = counter def run(self): for char in self.name: print(str(char) + ' ...
5a2a845fe6c641b16b400d5f5d7a103dd52de80a
nishujay/SnakeWaterGunGame
/game.py
864
4.03125
4
import random def gameWin(comp,you): if comp == you: return None elif comp == 's': if you == 'w': return False elif you=='g': return True elif comp == 'w': if you == 'g': return False elif you=='s': return True elif...
dbe64889986bf332dbc5227f05f0eaf765ff6617
chrisj63-git/chrisj63-git.github.io
/byuipy/prove02_grp_ChrisJohnson.py
876
3.515625
4
""" File: provegrp_02_ChrisJohnson.py Author: Chris Johnson """ dash = "----------------------------------------" print("Please enter the following information:\n") fname = input('First Name: ') lname = input('Last Name: ') email = input('Email address: ') phone = input('Phone number: ') jtitle = input('Job title: ')...
6536edbbe450c783bdd19857c2aed37a673499b2
YevgeniyaKim/Web
/Desktop/КБТУ/Web/week8/informatics/part4/67.py
263
3.53125
4
n = int(input()) a = [] for i in range(0, n): x = int(input()) a.append(x) for i in range(1, n): while i <= n: if (a[i] > 0 and a[i-1] > 0) or (a[i] < 0 and a[i - 1] < 0): print("YES") exit() i += 1 print("NO")
0af022557cb08455668f5ed4c7ad591cc49414fb
YevgeniyaKim/Web
/Desktop/КБТУ/Web/week8/informatics/part1/2936.py
84
3.640625
4
import math a = float(input()) b = float(input()) print(math.sqrt(a ** 2 + b ** 2))
8b25ddfd44add2e0bed4d295b9d5d28738a7c77a
JoseVictorAmorim/PLP-2020-2
/PLPcodes/REO02/Lista Treino/ex19.py
293
3.921875
4
num = input("Digite algo para ser convertido para float: ") while True: try: #num = input("Digite algo para ser convertido para float: ") num = float(num) print(type(num)) break except: num = input("Impossivel converter. Digite outra coisa: ")
efa3a0b6467e39049bda17deda818f7a92302b27
JoseVictorAmorim/PLP-2020-2
/PLPcodes/REO02/Lista Treino/ex11.py
1,289
4.28125
4
#Utilizando a linguagem Python (3.*), escreva expressões algébricas correspondentes aos ##seguintes comandos: ##(a) A soma dos 5 primeiros inteiros positivos. ##(b) A idade média de Sara (idade 23), Mark (idade 19) e Fátima (idade 31). ##(c) O número de vezes que 73 cabe em 403. ##(d) O resto de quando 403 é dividido p...
baa84c3d21bf74918abc04edb026e66c794698c6
KaluEmeKalu/discrete_math_rosen_with_python
/rosen_ch3/bubble_sort_faster.py
348
3.65625
4
# Python Implementation of Bubble Sort a = [483,329,42,85,372] # a = [1, 2, 4, 6, 8, 10] n = len(a) for i in range(1, n -1): switch_made = False for j in range(n - i): if a[j] > a[j + 1]: a[j], a[j + 1] = a[j+1], a[j] switch_made = True if not switch_made: print("You saved {} iteration".format(str(n - 1 ...
26510ac9a391ba0f6cce86f3602c5b7f855e368d
KaluEmeKalu/discrete_math_rosen_with_python
/rosen_ch3/ch3.1/4.py
460
3.96875
4
# Describe an algorithm that takes as input # a list of n integers and produces as # output the largest difference obtained # by subtracting an integer in the list # from the one following it. def f(integers): max_diff = integers[0] - integers[1] n = len(integers) for i in range(n -1): diff = i...
543b4406ba9d025dc4ea18401cf9517a9321ce58
AbhiniveshP/Stack-1
/DailyTemperatures.py
1,365
3.640625
4
''' Solution: 1. Use a montonic stack for this problem, where from bottom to top of the stack, you have elements in ascending order. 2. Push all elements into the stack one-by-one. But, before pushing an element, pop all elements that are lesser to the current element and save the current element's count fr...