blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ce6f6114512ae2682c8902999118c08474da92fd
alanamckenzie/advent-of-code
/advent2017/code/utils.py
403
4.15625
4
def read_file(filename, line_delimiter='\n'): """Read the contents of a file :param str filename: full path to the text file to open :param line_delimiter: line delimiter used in the file :return: contents of the file, with one list item per line :rtype: list """ with open(filename, 'r...
true
36ac8905679118a796c0ea1e073b8f4c035f3246
campbellerickson/CollatzConjecture
/Collatz.py
540
4.25
4
print "Type '123' to start the program::", check = input() if check == 123: print "To what number would you like to prove the Collatz Conejecture?::" limit = input() int(limit) for x in xrange(1,limit+1): num=x original=x iterations=0 while num > 1: if (num % 2 == 0): num = num/2 iteration...
true
a3ce178e270557e7711aa92a860f2d6820531dcc
KSSwimmy/python-problems
/csSumOfPostitive/main.py
776
4.125
4
# Given an array of integers, return the sum of all positive integers in an array def csSumOfPositive(input_arr): # Solution 1 sum = 0 for key, value in enumerate(input_arr): if value <= 0: continue else: sum += value return sum # Solution 2 ''' ...
true
8c99e5d3a112f865f0d8c90f98be43ce6c1e7e01
moorea4870/CTI110
/P5HW2_GuessingGame_AvaMoore.py
817
4.28125
4
# Using random to create simple computer guessing game # July 5, 2018 # CTI-110 P5HW2 - Random Number Guessing Game # Ava Moore # use random module import random # set minimum and maximum values (1-100) MIN = 1 MAX = 100 def main(): #variable to control loop again = 'y' #until the user i...
true
c565083b6d11e6bb8403b0e4c3083ea695a4f5fa
Hanjyy/python_practice
/conditional2.py
1,677
4.1875
4
''' purchase_price = int(input("What is the purchase price: ")) discount_price_10 = (10 /100 )* (purchase_price) final_price_10 = purchase_price - discount_price_10 discount_price_20 = (20/100) * (purchase_price) final_price_20 = purchase_price - discount_price_20 if purchase_price < 10: print("10%", final_price_...
true
20a497f0e1df4edff5d710df5b8fa4839998ca18
hihasan/Design-Patterns
/Python In these Days/practice_windows/com/hihasan/ListPractice.py
786
4.25
4
number=[1,2,3,4] #print list print(number) #Accessing Elements In A List print(number[0]) print(number[-1]) print(number[-2]) print(number[0]+number[2]) #changing, adding & removing elements names=["Hasan","Mamun","Al","Nadim"] names.append("Tasmiah") #When we append an item in the list, it will store in last prin...
true
fe0a64036e5a1317c0dcaaded3a332a6d33594a7
axecopfire/Pthw
/Exercises/Ex15_Reading_FIles/Reading_Files.py
1,392
4.5625
5
# Importing argv from the system module from sys import argv # argv takes two variables named filename and script script, filename = argv # The variable txt opens filename, which is an argv variable txt = open(filename) # filename is entered after this prompt, which is then assigned to the variable txt. At the same ...
true
aa82cfb605e7cec0fff586fa9e24b9e8bf0df80e
NataliiaBidak/py-training-hw
/decorators.py
1,667
4.1875
4
"""Write a Decorator named after5 that will ignore the decorated function in the first 5 times it is called. Example Usage: @after5 def doit(): print("Yo!") # ignore the first 5 calls doit() doit() doit() doit() doit() # so only print yo once doit() please make a similar one, but that acceps times to skip as param (...
true
b309163a54cb56b9f9c3b21795388a74658910fb
99zraymond/Daily-Lesson-Exercises
/Daily Exercise 02082018.py
770
4.34375
4
#Your Name - Python Daily Exercise - date of learning # Instructions - create a file for each of the daily exercises, answer each question seperately # 1. Write a statement that concatenates at least two variables (you can have more than 2 for this practice). # 2. Create a program that asks the user to enter t...
true
505c59d5b7161eab01c637f144f7f3bf790f2bfb
manjunath2019/Python_7am_May_2019
/Operators/Membership.py
452
4.15625
4
""" in and not in are the membership operators in python Are used to test whether a value or variable is found in a sequence (String, List, Tuple, & Dictrionary) """ x_value = 'Guido Van Rossum' y_value = {1:'a',2:'b'} print(x_value) print(y_value) #a = input('Enter a Value : ') #print(a in x_value.lower()) pr...
true
ba05240853d5865e4a57d9593bd3bcdf97696bb7
run-fourest-run/IteratorProtocol
/realpythonitertools/itertoolsintro.py
539
4.1875
4
'''itertools is a module that implements a number of iterator building blocks. Functions in itertools operate on iterators to produce more complex iterators''' test_list_0 = [95000,95000,95000,95000] test_list_1 = [117000,117000,121000,120000] test_list_2 = ['alex','joe','anthony','david'] '''zip example''' def see_...
true
e0d48e5df6768de714b9928cc4853cb92b121535
run-fourest-run/IteratorProtocol
/itertoolsdocs/chain.py
720
4.1875
4
import itertools ''' Make an iterator that returns elements from the first iterable until its exhausted. Then proceed to the next iterable, until all the iterables are exhausted. Used for treating consecutive sequences as a single sequence ''' def chain(*iterables): for it in iterables: for element in ...
true
ec7199c351470743b5ead5d6639229d283ecfca7
bc-uw/IntroPython2016
/students/bc-uw/session04/trigram.py
949
4.125
4
""" Trigram lab attempt. Version0.I don't understand what this is supposed to do """ import sys import string import random def sourceFile_to_list(input_file): """ list comprehension to iterate through source file lines and add them to textlist """ with open(input_file) as f: textlist = [...
true
8f995f5ec8b53e07ea81997683fb7acd957a5acc
naymajahan/Object-Oriented-programming1
/python-regular-method.py
979
4.34375
4
#### object oriented programming in python class StoryBook: def __init__(self, name, price, authorName, authorBorne, no_of_pages): # setting the instance variables here self.name = name self.price = price self.authorName = authorName self.authorBorne = authorBorne s...
true
752cd493edac4ad35a04b1ce29c7b9449fe6d797
tarabrosnan/hearmecode
/lesson04/lesson04_events_deduplicate.py
986
4.125
4
# Challenge level: Beginner # Scenario: You have two files containing a list of email addresses of people who attended your events. # File 1: People who attended your Film Screening event # https://github.com/shannonturner/python-lessons/blob/master/section_09_(functions)/film_screening_attendees.txt # # ...
true
5cdfa102cff1c3210258e57c45eb8ba103e90481
RodiMd/Python
/RomanNumeralsRange.py
1,937
4.125
4
#Roman Numerals #prompt user to enter a value between 1 and 10. number = input('Enter a number between 1 and 10 ') number = float(number) def main(): if number == 1: print('The value entered ', number, 'has a roman equivalent of I') else: if number == 2: print('The val...
true
19d948529b4da0ca728c55653e413629487b606f
RodiMd/Python
/MonthlyCarCost.py
690
4.1875
4
#Automobile Costs #ask user to input automobile costs including: loan payment #insurance, gas, oil, tires, maintenance. loanPayment = input('Enter auto monthly payment ') insurance = input('Enter insurance cost ') gas = input('Enter monthly gas cost ') oil = input('Enter monthly oil cost ') tires = input('Ente...
true
19be8d9e73b668b2039865214c3bb7b1937c1924
RodiMd/Python
/convertKmToMiles.py
383
4.4375
4
#Kilometer Converter #write a program that converts km to mi #ask the user to enter a distance in km distanceKilometers = input('Enter a distance in km ') distanceKilometers = float(distanceKilometers) def conversionTokilometers(): miles = distanceKilometers * 0.6214 print ('The distance entered in kil...
true
66079189a84d8cd1c08a3b9eee964f6a116395d4
h8rsha/tip-calculator
/main.py
441
4.125
4
if __name__ == '__main__': print("Welcome to the tip calculator.") total_bill = input("What was the total bill? ") tip_percentage = input("What percentage tip would you like to give? 10, 12 or 15? ") people_count = input("How many people to split the bill? ") total_amount = (float(total_bill) / int(...
true
b5e6f4348b9445639f2696caac83c9a761200cc0
zchiam002/vecmc_codes_zhonglin
/nsga_ii/nsga_ii_para_imple_evaluate_objective.py
2,310
4.15625
4
##Function to evaluate the objective functions for the given input vector x. x is an array of decision variables ##and f(1), f(2), etc are the objective functions. The algorithm always minimizes the objective function hence if ##you would like to maximize the function then multiply the function by negative one. def ...
true
5e4e2fdc4c1037667821e5f23ad88ccc62f7de18
Salcazul/ComputerElective
/Quiz2.py
622
4.21875
4
#Name name = raw_input("What is your name?") #Last Name last = raw_input("What is your last name?") #Class classname = raw_input("What class are you in?") #Year of birth year = input("What is your year of birth?") #Calculate current age age = 2015 - year print "You are", age, "years of age." #Computer grade 1S s1 =...
true
ed218f5025544474394bed9e161c987edd884a3e
yk2684/Codewars
/7kyu/Highest-and-Lowest.py
410
4.125
4
#In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number. #Example: #high_and_low("1 2 3 4 5") # return "5 1" #high_and_low("1 2 -3 4 5") # return "5 -3" #high_and_low("1 9 3 4 -5") # return "9 -5" def high_and_low(numbers): num_list = sorted(...
true
89074f4afad000944e11ed9fcc508ecc69e42233
yk2684/Codewars
/8kyu/Return-negative.py
435
4.65625
5
#In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative? #Example: #make_negative(1); # return -1 #make_negative(-5); # return -5 #make_negative(0); # return 0 #Notes: #The number can be negative already, in which case no change is required. #Zero (0)...
true
c4d957205efb049acc46b4cc892ef0fb32b8607f
Abdulkadir78/Python-basics
/q16.py
690
4.34375
4
''' Use a list comprehension to square each odd number in a list. The list is input by a sequence of comma-separated numbers. Suppose the following input is supplied to the program: 1, 2, 3, 4, 5, 6, 7, 8, 9 Then, the output should be: 1, 9, 25, 49, 81 ''' numbers = input('Enter comma separated sequence of numbers: '...
true
278c75115f7d16cbb3b881b0ea0ec90d22eca62a
Abdulkadir78/Python-basics
/q7.py
565
4.21875
4
''' Write a program which takes 2 digits, X, Y as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. Example Suppose the following inputs are given to the program: 3, 5 Then, the output of the program should be: [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0,...
true
f28b75916667124438f2c9e661078cf25ac70277
Abdulkadir78/Python-basics
/q35.py
663
4.15625
4
''' Please write a program which counts and prints the numbers of each character in a string input by console. Example: If the following string is given as input to the program: abcdefgabc Then, the output of the program should be: a, 2 b, 2 c, 2 d, 1 e, 1 f, 1 g, 1 ''' string = input('Enter a string: ') l = [] for c...
true
911f65f6917f1b17ebc6cb8c325e650549fe2bc3
sapphacs13/python_basics
/syntax/functions.py
722
4.125
4
# Python uses white space. Everything you define or use has # to have the correct indentation. def adder(a, b): return a + b print adder(1, 2) # runs adder(1,2) and prints it (should print 3) def subtracter(a, b): return a - b print subtracter(3, 2) # runs the subtracter and prints (should print 1) # lets ...
true
5e99a7b51a52f5301a2cb3bc65f019d52051982e
bigcat2014/Cloud_Computing
/Assignment 2/step2.py
615
4.21875
4
#!/usr/bin/python3 # # Logan Thomas # Cloud Computing Lab # Assignment 2 # # Capitalize the first letter of each word in the string and # take the sum of all numbers, not contained in a word, and # print the new string and the sum. def main(): total = 0.0 user_input = input("Please enter a string\n>> ") user_in...
true
1d92d87875f37503b14413d484e8656e426ac5d1
JoelBrice/PythonForEveryone
/ex3_03.py
439
4.21875
4
"""Check that the score is between the range and display the score level according to the score""" score = input("Enter Score: ") s = 0.0 try: s = float(score) except: print("Error out of range!") if s >=0 and s<=1: if s>= 0.9: print("A") elif s >=0.8: print("B") elif s>=0.7: ...
true
bcc25fa4698e6c2e3d8bdef4290d8cdbc90bc7bc
alberico04/Test
/main.py
2,845
4.25
4
#### Describe each datatype below:(4 marks) ## 4 = integer ## 5.7 = float ## True = boolean ## Good Luck = string #### Which datatype would be useful for storing someone's height? (1 mark) ## Answer: FLOAT #### Which datatype would be useful for storing someone's hair colour?(1 mark) ## Answer: ST...
true
4cb82d079ffac6a7d07d598ab27ebb14d840f9b7
abhilash1392/pythonBasicExercisesPart1
/exercise_5.py
292
4.25
4
"""5. Write a Python program which accepts the user's first and last name and print them in reverse order with a space between them.""" first_name=input('Please enter your first name: ') last_name=input('Please enter your last name: ') print('Hello {} {}'.format(last_name,first_name))
true
e4975175bb97edd715411f62c8a168dfe32570eb
nbrahman/HackerRank
/03 10 Days of Statistics/Day08-01-Least-Square-Regression-Line.py
1,450
4.21875
4
''' Objective In this challenge, we practice using linear regression techniques. Check out the Tutorial tab for learning materials! Task A group of five students enrolls in Statistics immediately after taking a Math aptitude test. Each student's Math aptitude test score, x, and Statistics course grade, y, can be expre...
true
7d1e10a0303d71f3ff95a22bf44e2963b3745f22
nbrahman/HackerRank
/01 Algorithms/01 Warmup/TimeConversion.py
969
4.25
4
''' Given a time in 12-hour AM/PM format, convert it to military (24-hour) time. Note: Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock, and 12:00:00 on a 24-hour clock. Input Format A single string containing a time in 12-hour clock format (i.e.: hh:m...
true
fd4be7ead12bb78ac455902f0721c2655643d7f4
nbrahman/HackerRank
/01 Algorithms/02 Implementation/Utopian-Tree.py
1,421
4.21875
4
''' The Utopian Tree goes through 2 cycles of growth every year. Each spring, it doubles in height. Each summer, its height increases by 1 meter. Laura plants a Utopian Tree sapling with a height of 1 meter at the onset of spring. How tall will her tree be after N growth cycles? Input Format The first line contains ...
true
13c10b8411890edb52c47de0543427793125cd55
nbrahman/HackerRank
/01 Algorithms/02 Implementation/Circular-Array-Rotation.py
1,807
4.28125
4
''' John Watson performs an operation called a right circular rotation on an array of integers, [a0, a1, a2, an-1]. After performing one right circular rotation operation, the array is transformed from [a0, a1, a2, an-1] to [an-1, a0, a1, a2, an-2]. Watson performs this operation k times. To test Sherlock's ability to...
true
5d0df4565c0a9c8ddd4442a609050631ae3310f9
kumarchandan/Data-Structures-Python
/3-linked_lists/c6_detect_loop_in_linked_list/main-floyd-algo.py
1,201
4.125
4
''' This is perhaps the fastest algorithm for detecting a linked list loop. We keep track of two iterators, onestep and twostep. onestep moves forward one node at a time, while twostep iterates over two nodes. In this way, twostep is the faster iterator. By principle, if a loop exists, the two iterators will meet. ...
true
9985b32d8d79fb4bfde8d0ffbec712e5b88ac8d4
gomanish/Python
/Linked_List/add_and_delete_last_node.py
910
4.25
4
# Add and Delete Last Node in a linked list class Node: def __init__(self,val): self.value = val self.next = None class LinkedList: def __init__(self): self.head = None self.tail = None def printallnodeval(llist): temp=llist.head while temp: print temp.value temp=temp.next return de...
true
eae27424746c9423d92b345429cf1acb5d5656e9
gomanish/Python
/basic/threesquares.py
348
4.1875
4
'''Write a Python function threesquares(m) that takes an integer m as input and returns True. if m can be expressed as the sum of three squares and False otherwise. (If m is not positive, your function should return False.)''' def threesquares(n): if n<0: return False while(n%4==0): n=n/4 n=n-7 if(n%8==0): ...
true
39bcbe9d664219f56608744cc6e2b0e88261fa2a
carriehe7/bootcamp
/IfStatementBasics.py
1,118
4.125
4
# if statements basics part 1 salary = 8000 if salary < 5000: print('my salary is too low, need to change my job') else: print('salary is above 5000, okay for now') age = 30 if age > 50: print('you are above 50. you are a senior developer for sure') elif age > 40: print('your age is bigger than 40. you...
true
e180350b63cc478a403a3df45cc5e781d70c5d5f
carriehe7/bootcamp
/TupleCollectionHW.py
1,642
4.5625
5
# 1. Create a ‘technological_terms’ tuple that will contain the following items: # a. python # b. pycharm IDE # c. tuple # d. collections # e. string technological_terms = ('python', 'pycharm IDE', 'tuple', 'collections', 'string') print('technological terms tuple collection : ' +str(technological_terms)) # 2. Print t...
true
572eb584fb562b811de2b73c517ed4fffbf5c8e2
mbonnemaison/Learning-Python
/First_programs/boolean_1.py
730
4.15625
4
""" def list_all(booleans): Return True if every item in the list is True; otherwise return False list_all([]) = True list_all([True]) = True list_all([False]) = False list_all([True, False, True]) = False raise Exception("TODO") """ def list_all(booleans): for bools in booleans: if not isinstance(bools, b...
true
2205eee999f0175dbb14cc40d239bd819fc83baa
KarenAByrne/Python-ProblemsSets
/fib.py
1,159
4.21875
4
# Karen Byrne # A program that displays Fibonacci numbers. def fib(n): """This function returns the nth Fibonacci number.""" i = 0 j = 1 n = n - 1 while n >= 0: i, j = j, i + j n = n - 1 return i # Test the function with the following value. My name is Karen , so the first and l...
true
c8cd572bde563d3cebd748dde843402cd1fb2077
camaral82/Python_Self_Study_MOSH
/Dictionary.py
506
4.28125
4
"""24/09/2020 - Thursday Dictionary Exercise Type a sequence of numbers and at the end transcript each element. In case of typing a character, show ! """ digits_mapping = {"1": "One", "2": "Two", "3": "Three", "4": "Four", "5": "Five", "6": "Six", "7": "Seven", "8": "Eight", "9"...
true
72663f0656ad734acee538dc6aa8f8d67256d49a
saileshkhadka/SearchingAlgorithm-in-Python
/LargestElementfromlistinLinearTime.py
2,475
4.1875
4
# Problem Description # The program takes a list and i as input and prints the ith largest element in the list. # Problem Solution # 1. Create a function select which takes a list and variables start, end, i as arguments. # 2. The function will return the ith largest element in the range alist[start… end – 1]. # 3. Th...
true
3f07333fe11b65981a4d530cc59ff45e42fe8225
ssaroonsavath/python-workplace
/conversion/conversion.py
977
4.25
4
''' Created on Jan 20, 2021 The objective is to make a program that can complete different conversions ''' #Use input() to get the number of miles from the user. ANd store #that int in a variable called miles. miles = input("How many miles would you like to convert?") #Convert miles to yards, using the following:...
true
7686831590125c15617128a0115e1a23b084d528
mayanderson/python-selenium-automation
/hw3_algorithms/algorithm_2.py
298
4.15625
4
def longestWord(): sentence = input('Please enter a sentence with words separated by spaces:') words = sentence.split() if len(words) == 0: return "" if len(words) == 1: return words[0] longest = "" for word in words: if len(word) > len (longest): longest = word return longest
true
658408212c2953a13931535581cbd34f9f446d83
chokrihamza/opp-with-python
/try_except.py
496
4.125
4
try: print(x) except: print("there is no value of x") try: print("Hello") except: print("Something went wrong") else: print("Nothing went wrong") try: print(x) except: print("Something went wrong") finally: print("The 'try except' is finished") try: f = open("demofile.txt", 'w') f.write("Hello th...
true
7ddab1a480e5e4ab6d33ce0bec4039a590547973
Rohankrishna/Python_Scripting_Practice
/even_odd.py
383
4.15625
4
from math import sqrt n = int(input("enter a number ")) check = int(input("Enter the number with which we want to check ")) if n % 4 == 0: print("It is an even number and also a multiple of 4") elif n%2==0: print("It is an even number") else: print("It is an odd number") if(n%check==0): print(n, " is evenly divis...
true
980b7a7e9e0eb54fdb5e45109285da68ca5dafec
brownd0g/Financial-Independence-Calculator
/Financial Independence Calculator.py
2,070
4.375
4
# This function is used to make sure user inputs a valid number for each question def validInput(question): UI = input(question) # The following will run until a positive real number is entered while True: try: num = float(UI) while num < 0: num = float(input(...
true
2c7883d2c464936c5fb2bfc6d6e62ccab313b6ce
ggsbv/pyWork
/compareDNA/AminoAlign.py
1,526
4.21875
4
#findLargest function finds and returns the largest DNA string def findLargest(AA1, AA2): largest = "" if len(AA1) >= len(AA2): largest = AA1 else: largest = AA2 return largest #align function compares two amino acid sequences and prints any differences (mutations) def...
true
e7c0faf8127f813db4bd4599198c8f6eda8ff552
alexjohnlyman/Python-Exercises
/Inheritance.py
1,003
4.21875
4
# Inheritance # Is an "is a" relationship # Implicit Inheritance class Parent(object): def implicit(self): print "PARENT implicit()" def explicit(self): print "PARENT explicit()" def altered(self): print "PARENT altered()" class Child(Parent): def implicit(self): pri...
true
298ab47829b2875bca88208e9d87d2d1ceb8a96f
LinuxLibrary/Python
/Py-4/py4sa-LA/programs/04-Classes.py
864
4.28125
4
#!/usr/bin/python # Author : Arjun Shrinivas # Date : 03.05.2017 # Purpose : Classes in Python class Car(): def __init__(self): print "Car started" def color(self,color): print "Your %s car is looking awesome" % color def accel(self,speed): print "Speeding upto %s mph" % speed def turn(self,direction): pri...
true
97b7f50d9511e5acd7a86947b8bc5a367f4b589d
brookstawil/LearningPython
/Notes/7-16-14 ex1 Problem Square root calculator.py
935
4.3125
4
#7/16/14 #Problem: See how many odd integers can be subtracted from a given number #Believe it or not this actually gives the square root, the amount of integers need is the square root!! #number input num = int(input("Give me a number to square root! ")) num_begin = num #Loops through the subtractions #defines the s...
true
2af694a25d9f9174581cd14f3eafad232b278f83
brookstawil/LearningPython
/Notes/7-14-14 ex6 Letter grades.py
525
4.125
4
#7-14-14 #Letter grades #Input the grade grade = input("What is the grade? ") grade = grade.upper() #Long way #if grade == "A": # print ("A - Excellent") #else: # if grade == "B": # print("B - good!") # else: # if grade == "C": # print("C - average") # else: # pri...
true
ec1f9eb074b9429219c410c902a440cea069377e
brookstawil/LearningPython
/Notes/7-31-14 ex1 Determine whether a number (N) is prime.py
958
4.1875
4
#7/31/14 #Determine whether a number (N) is prime or not #We only have to check numbers up to the integer square root of N. import math #This determines whether n is prime #INPUT - a number to check #OUTPUT - Ture if it is prime or False if is is not def is_prime(n): is_it_prime = True #We start with an assumpt...
true
d85e661fcc6f61c320b8502dde6c185d5a50f78a
Struth-Rourke/cs-module-project-algorithms
/moving_zeroes/moving_zeroes.py
787
4.34375
4
''' Input: a List of integers Returns: a List of integers ''' def moving_zeroes(arr): # instantiating an empty, new_arr new_arr = [] # loop over items in the array for i in arr: # if the value of the item in the array is not zero if i != 0: # append the value to the list ...
true
3a9aaa5e252c042a99972e7a7146e17a9ddae7e4
parandkar/Python_Practice
/brick_game.py
933
4.15625
4
""" This is a solution to the problem given at https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/bricks-game-5140869d/ Patlu and Motu works in a building construction, they have to put some number of bricks N from one place to another, and starte...
true
efccbfe53442920f68dba5e07a6de8f05ded48a4
parandkar/Python_Practice
/seat.py
733
4.1875
4
""" This is a solution to the problem given at https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/seating-arrangement-1/ """ # Using dictionaries to deduce the front seats and seat type facing_seats = {1:11, 2:9, 3:7, 4:5, 5:3, 6:1, 7:-1, 8:-3, 9...
true
625c2fb420c9fb2670a4bf01db08aaa52ccc5080
parandkar/Python_Practice
/count-divisors.py
694
4.1875
4
""" This is a solution to the problem given at https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/count-divisors/ You have been given 3 integers - l, r and k. Find how many numbers between l and r (both inclusive) are divisible by k. You do not need ...
true
a4cfcbfcad47b05b4257e2251ba015f2226761ae
chuene-99/Python_projects
/mostwords.py
410
4.25
4
#program that counts the most common words in a text file. file=open(input('enter file name: ')) list_words=list() dict_words=dict() for line in file: line=line.rstrip() line=line.split() for word in line: dict_words[word]=dict_words.get(word,0)+1 for k,v in dict_words.items(): list_wo...
true
a6c81c911cda7b995456e893b71b400713a8c34d
ry-blank/Module-7
/basic_list.py
878
4.53125
5
""" Program: basic_list_assignment Author: Ryan Blankenship Last Date Modified: 10/6/2019 The purpose of this program is to take user input then display it in a list. """ def make_list(): """ function to return list of user input from function get_input() :return: returns list of user input ...
true
8d022903c89a5f24d5b99aba8e273ecdce4c2bb2
Hail91/Algorithms
/recipe_batches/recipe_batches.py
1,683
4.125
4
#!/usr/bin/python import math test_recipe = { 'milk': 100, 'butter': 50, 'flour': 5 } # Test for PT test_ingredients = { 'milk': 132, 'butter': 48, 'flour': 51 } # Test for PT def recipe_batches(recipe, ingredients): batches = 0 # Initalize a batches variable to zero while True: # Using a while loop to keep...
true
e1fbb0394458201d27b22d8df48b5df97b5e31c1
ShabnamSaidova/basics
/dogs.py
2,438
4.46875
4
class Dog(): """A simple attempt to model a dog""" def __init__(self, name, age): """Initialize name and age attributes.""" self.name = name self.age = age def sit(self): """Simulate a dog sitting in response to a command.""" print(self.name.title() + " is...
true
cb5b3c72a8482ce9be3b8b4991527eeada7c27fd
Marcus-Mosley/ICS3U-Unit4-03-Python
/squares.py
1,024
4.40625
4
#!/usr/bin/env python3 # Created by Marcus A. Mosley # Created on October 2020 # This program finds the squares of all natural numbers preceding the # number inputted by the user def main(): # This function finds the squares of all natural numbers preceding the # number inputted by the user # In...
true
b18eda77ffe0121752bb93beb291eab3184f0df2
Udayin/Flood-warning-system
/floodsystem/flood.py
1,586
4.25
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 24 18:01:03 2017 @author: Rose Humphry """ from floodsystem.utils import sorted_by_key def stations_level_over_threshold(stations, tol): ''' a function that returns a list of tuples, where each tuple holds (1) a station at which the latest relat...
true
fd5982d54adcca536876f48003c814f73ea227f6
G3Code-CS/Algorithms
/making_change/making_change.py
2,643
4.375
4
#!/usr/bin/python import sys def making_change(amount, denominations): # we can initialize a cache as a list (a dictionary # would work fine as well) of 0s with a length equal to the amount we're # looking to make change for. cache = [0] * (amount + 1) # Since we know there is one way to ...
true
8bbdb6e9157642e89e718d51a76f674d5fa177be
ethirajmanoj/Python-14-6-exercise
/14-quiz.py
1,062
4.1875
4
# Create a question class # Read the file `data/quiz.csv` to create a list of questions # Randomly choose 10 question # For each question display it in the following format followed by a prompt for answer """ <Question text> 1. Option 1 2. Option 2 3. Option 3 4. Option 4 Answer :: """ import csv score = 0 scor...
true
b9c7eee17e69a1836d0cbf817509a874ebe5514f
nsvir/todo
/src/model/list_todo.py
1,158
4.125
4
class ListTodo: """ List Todo contains name Initialize an empty list lst = ListTodo() To get list >>> lst.list() [] To add element in list lst.add_list(TaskList()) To check if element is contained in list lst.contains_list(TaskList()) True """ def __init__(s...
true
d306f43d54d0a2713bc23a714a949af59714e9f4
Yosolita1978/Google-Basic-Python-Exercises
/basic/wordcount.py
2,898
4.34375
4
"""Wordcount exercise Google's Python class 1. For the --count flag, implement a print_words(filename) function that counts how often each word appears in the text and prints: word1 count1 word2 count2 ... Print the above list in order sorted by word (python will sort punctuation to come before letters -- that's fi...
true
9368e573f0bd816c214165e71571bccfed73076d
ThomasP1234/DofE
/Week 2/GlobalVariables.py
527
4.125
4
# Global Variables and Scope # ref: https://www.w3schools.com/python/ # Author: Thomas Preston x = "awesome" # When this is commented out there is an error because the final print doesn't know what x is def myfunc(): x = "fantastic" # Where as when this is commented out, the global x is printed print("Python is "...
true
95f146d5bd21e8f40343ea95c4f7e8f7ea0da0f8
ThomasP1234/DofE
/Week 5/WhileLoops.py
410
4.21875
4
# One of the primary loops in python # ref: https://www.w3schools.com/python/ # Author: Thomas Preston a = 1 while a < 10: print(a) a = a + 1 # Adds 1 to a each loop b = 1 while b < 6: print(b) if b == 3: break b += 1 c = 0 while c < 6: c += 1 if c == 3: continue print(c) # skips this ste...
true
9fba4c0eb7046f9b22e1f3a83e0752c961fedcd4
Yfaye/AlgorithmPractice
/python/InsertInterval.py
1,756
4.25
4
# Insert Interval # Description # Given a non-overlapping interval list which is sorted by start point. # Insert a new interval into it, make sure the list is still in order and non-overlapping (merge intervals if necessary). # Example # Insert [2, 5] into [[1,2], [5,9]], we get [[1,9]]. # Insert [3, 4] into [[1,2]...
true
bb711f3653e9dd1ae3f3a88d75a2fd038df612dc
vanctate/Computer-Science-Coursework
/CSCI-3800-Advanced-Programming/HW03/Problem1_Python/piece.py
1,365
4.1875
4
# Patrick Tate # CSCI 3800 HW03 | Problem 1 # class to represent a black or white piece to be inserted into an Othello gameboard # piece has a color(B/w), and a row and column in array notation, to be used with the Grid class class Piece: # subtract 1 from row and column for array notation def __init__(self, ...
true
89a568f79f10a3bf0370d01f195813475979832a
akeeton/leetcode-python
/0283-move-zeroes.py
1,676
4.1875
4
""" Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] Note: You must do this in-place without making a copy of the array. Minimize the total number of operations. """ class Solution...
true
2319f0735e3516b43da4890f2682fc9d9055868f
harekrushnas/python_practice
/guess_the_number.py
1,513
4.21875
4
#The program will first randomly generate a number unknown to the user. The user needs to guess what that number is. # Reference link : https://knightlab.northwestern.edu/2014/06/05/five-mini-programming-projects-for-the-python-beginner/ import random #from colorama import* ran = random.randint(0,1000) #len1=len(str(...
true
de3da113c7e0bbc9f73c2f2182539b2b0bb266c6
frankPairs/head-first-python-exercises
/chapter_4_functions_modules/vsearch_set.py
235
4.1875
4
def search_for_vowels(word: str) -> set: """Returns any vowels found in a supplied word""" vowels = set('aeiou') return vowels.intersection(set(word)) print(search_for_vowels("francisco")) print(search_for_vowels("sky"))
true
65268b86a2ed7ddfbf5f59db5e5b86577d3b9363
jeffkwiat/minesweeper
/app.py
2,961
4.125
4
import random class Minesweeper(object): """ Implementing a simple Minesweeper board. """ def __init__(self, width, height, number_of_mines): self.width = width self.height = height self.number_of_mines = number_of_mines self.board = self.generate_board() self...
true
53e9e59370cad6cfcf69c3219783070f35df4f81
GauravR31/Solutions
/Classes/Flower_shop.py
1,883
4.15625
4
class Flower(object): """docstring for ClassName""" def __init__(self, f_type, rate, quantity): self.type = f_type self.rate = rate self.quantity = quantity class Bouquet(object): """docstring for ClassName""" def __init__(self, name): self.name = name self.flowers = [] def add_flower(self): f_type =...
true
ce97aff7408d5808d33756c8bb72e2910bbe77a4
ngrq123/learn-python-3-the-hard-way
/pythonhardway/ex30.py
732
4.34375
4
# Initialise people to 30 people = 30 # Initialise cars to 40 cars = 40 # Initialise buses to 15 buses = 15 # If there are more cars then people if cars > people: print("We should take the cars.") # Else if there are less cars then people elif cars < people: print("We should not take the cars.") else: prin...
true
d61c6db3c3889e24794719d0d8e7c9a4c6a3732e
dkahuna/basicPython
/Projects/calcProgram.py
241
4.5
4
# Calculating the area of a circle radius = input('Enter the radius of your circle (m): ') area = 3.142 * int(radius)**2 # int() function is used to convert the user's input from string to integer print('The area of your circle is:', area)
true
5dbf3b63d6bb744d4a02aba9f41acd9ad64372c2
dkahuna/basicPython
/FCC/ex_09/ex_09.py
714
4.15625
4
fname = input('Enter file name: ') if len(fname) < 1 : fname = 'clown.txt' hand = open(fname) di = dict() #making an empty dictionary for line in hand : line = line.rstrip() #this line strips the white space on the right side per line of the file words = line.split() #this line splits the text file into an arr...
true
ecfe7da8cee6b57ab65108992a3c333f2e0dc283
RustingSword/adventofcode
/2020/01/sol2.py
315
4.125
4
#!/usr/bin/env python3 def find_triple(nums, target=2020): for first in nums: for second in nums: if (third := target - first - second) in nums: return first * second * third if __name__ == "__main__": nums = set(map(int, open("input"))) print(find_triple(nums))
true
7f5f33b40f1a8d3acc72c889bef1accf9432abb7
rubenvdham/Project-Euler
/euler009/__main__.py
833
4.4375
4
""" A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ def find_triplet_with_sum_of(number): sum = number number = int(number/2)...
true
156ce2abce7f089a563208dd1947eb0276c00a20
romeoalpharomeo/Python
/fundamentals/fundamentals/rock_paper_scissors.py
1,670
4.5
4
""" Build and application when both a user and computer can select either Rock, Paper or Scissors, determine the winner, and display the results For reference: Rock beats Scissors Scissors beats Paper Paper beats Rock Part I Compare user input agains computer choice and determine a winner Part II Compare user input ...
true
0e792822cb1faeda92a0c0fec8bb86901c40aa09
anmolrajaroraa/CorePythonBatch
/largest-among-three.py
1,385
4.46875
4
# num1, num2, num3 = 12, 34, 45 # if (num1 > num2) and (num1 > num3): # print("The largest between {0}, {1}, {2} is {0}".format(num1, num2, num3)) # elif (num2 > num1) and (num2 > num3): # print("The largest between {0}, {1}, {2} is {1}".format(num1, num2, num3)) # else: # print("The largest between {1}, {...
true
5a38d95fe9db58447d65605ddfef48559e6ae689
angjerden/kattis
/pizza_crust/pizza_crust.py
845
4.1875
4
''' George has bought a pizza. George loves cheese. George thinks the pizza does not have enough cheese. George gets angry. George’s pizza is round, and has a radius of R cm. The outermost C cm is crust, and does not have cheese. What percent of George’s pizza has cheese? Input Each test case consists of a single li...
true
1e0e9f789c65d252092168bbf9d90f89092f0c17
maryade/Personal-Learning-Python
/Udemy Python Practice programming Module 3.py
918
4.46875
4
# # Addition # print(5+3) # # # Subtraction # print(11-4) # # # multiplication # print(22*5) # # # division # print(6/3) # # # modulo # print(9%5) # # # exponents # print(2^4) # print(6**2) # # # return integer instead of floating number # print(11//5) # print(451//5) # assignment operation x = 18 # print(x) # to i...
true
d064c635389f767606f56ae246d695d7b1af6ecf
kevindsteeleii/HackerRank_InterviewPreparationKit
/00_WarmUpChallenges/jumpingOnClouds_2019_02_20.py
1,712
4.28125
4
""" Emma is playing a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. She can jump on any cumulus cloud having a number that is equal to the number of the current cloud plus 1 or 2. She must avoid the thunderheads. Determine the minimum number...
true
0915df88be07251462464e301bec6535ac91626d
tarjantamas/Virtual-Controller-CNN
/src/common/util.py
1,590
4.5625
5
def getArgumentParameterMap(argv): ''' Maps arguments to their list of parameters. :param argv: list of arguments from the command line :return: a map which maps argument names to their parameters. If the program is run in the following way: python main.py --capturedata param1 param2 param3 --othercommand p...
true
0cb1eb4245d4d82b15e885ab5b7374b0c419e6e0
epc0037/URI-CS
/CSC110/Python Lists/HW3/problem1.py
878
4.40625
4
# Evan Carnevale # CSC 110 - Survey of Computer Science # Professor Albluwi # Homework 3 - Problem 1 # This program will generate a list containing # all the odd numbers between 100 and 500 except 227 and 355. # create an empty number list & set the values we wish to remove from the list numList = [] a = 227 b = 355 ...
true
2869a4a804531ff82b8957a250082d0eaecfdd07
epc0037/URI-CS
/CSC110/Python Functions/HW4/stocks.py
2,179
4.25
4
# Evan Carnevale # CSC 110 - Survey of Computer Science # Professor Albluwi # Homework 4 - Problem 1 # This program will get create two lists for stock names and prices, # which will be entered by the user using a loop. I will utilize 3 functions: # the main function, the searchStock function and the printStock functio...
true
1f97e7a5f66552f012f3c95e05152ac9f9747640
epc0037/URI-CS
/CSC110/Python Basics/HW2/problem3.py
404
4.375
4
#Evan Carnevale #CSC 110 - Survey of Computer Science #Professor Albluwi #Homework 2 - Problem 3 TOTAL_BUGS = 0 DAYS = 1 while DAYS <= 7: print("Day", DAYS, ": Did you collect a lot of bugs today?") today_bug = int(input("Enter the number of bugs collected today")) TOTAL_BUGS += today_bug DAYS +=1 ...
true
db0c5a43933e5f1a257eaca2e3003a3a3cd7a40d
Nathansbud/Wyzdom
/Students/Suraj/quiz.py
513
4.125
4
students = ["Jim", "John", "Jack", "Jacob", "Joseph"] grades = [] for student in students: passed = False while not passed: try: grade = float(input(f"Input a quiz grade for {student} (0-100): ")) if not 0 <= grade <= 100: raise ValueError() grades.append(grade) ...
true
49f9fe9f6f2e695223c8c73ed60d7dc01a41d0ff
rajdharmkar/Python2.7
/sortwordsinalbetorder1.py
527
4.53125
5
my_str = input("Enter a string: ") # breakdown the string into a list of words words = my_str.split()# here separator is a space between words print words # sort the list words.sort() # display the sorted words for word in words: print(word) my_str = input("Enter a string with words separated ...
true
17e86708d5b2a0476756c63ab8d0cd12a77eba92
rajdharmkar/Python2.7
/initmethd1.py
1,676
4.625
5
class Human: # def __init__(self): pass # init method initializing instance variables # # def __str__(): pass # ?? # # def __del__(self): pass # ??...these three def statements commented out using code>> comment with line comment..toggles def __init__(self, name, age, gender): # self m...
true
53ebcd324577f722da9407c61ea2adf9dc66bed1
rajdharmkar/Python2.7
/math/fibo.py
1,296
4.28125
4
# Fibonacci numbers module def fib(n): # write Fibonacci series up to n a, b = 0, 1 while b < n: print b, # comma in print statement acts like NOT newline , all numbers are printed in one line..a row of numbers # without comma or anything everytime there is a new line; we get a colu...
true
16c0d9db5c7237b6f7dace39bdaf2b949d0b070e
rajdharmkar/Python2.7
/assertXpl2.py
2,214
4.40625
4
class B: # class declaration with keyword class, class object B created # class object; instance object; function object; method object x = 10 # this is a class attribute def __init__(self, name): # this is a __init__ method, also called a constructor that initializes default values of instance ...
true
b20e8e5fc85924d740d9c0ea38f22e43fecf3147
rajdharmkar/Python2.7
/continueeX.py
486
4.34375
4
for val in "string": if val == "i": continue print(val), print("The end") #The continue statement is used to skip the rest of the code inside a loop for #the current iteration only. Loop does not terminate but continues on with the #next iteration. #Syntax of Continue #continue #We co...
true
13bcc351d18826e483b62b4a7eb9e94f85cdb0c6
rajdharmkar/Python2.7
/Exception handling/NameError3.py
684
4.5
4
s = raw_input('Enter a string:') # raw_input always returns a string whether 'foo'/foo/78/'78' # n =int(raw_input(prompt))); this converts the input to an integer n = input("Enter a number/'string':")# this takes only numbers and 'strings'; srings throw errors ..it also evaluates if any numeric expression is given p...
true
d3db4014449d6b02a3c6a99d7101ffc793e87048
rajdharmkar/Python2.7
/usinganyorendswith1.py
583
4.4375
4
#program to check if input string endswith ly, ed, ing or ers needle = raw_input('Enter a string: ') #if needle.endswith('ly') or needle.endswith('ed') or needle.endswith('ing') or needle.endswith('ers'): # print('Is valid') #else: # print('Invalid') if needle in ('ly', 'ed', 'ing', 'ers'):#improper code ...
true