blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
91cc4ff7b8e7e275ba61d799d81c8eecb7587b7c
Shreyasi2002/CODE_IN_PLACE_experience
/CoreComplete/leap.py
930
4.4375
4
""" Example of using the index variable of a for loop """ def main(): pass def is_divisible(a, b): """ >>> is_divisible(20, 4) True >>> is_divisible(12, 7) False >>> is_divisible(10, 10) True """ return a % b == 0 def is_leap_year(year): """ Returns Boolean indicating ...
true
edf4a58d87d2c5cef9a6e06e2ace05ad5096268d
djoo1028/Euler
/euler01.py
1,636
4.3125
4
''' If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ''' def findSum(arg1): a = arg1 # input value will be range for the summation arr3 = [] # multip...
true
f0b39ddce7802ef09e39599f494c3461fc18007f
rati90/mjeraarmjera
/service/trustorNot.py
2,590
4.15625
4
def hands_table_clear(table, said_cards): """ for some decisions clears table and say lists :param tuple player_hands_table_say not cleared table and say :return tuple player_hands_table_say cleared table and say """ table.clear() said_cards.clear() return table, said_cards def do_yo...
true
d999688c971c11599747b52a8f1630c1f56e3542
Ryandalion/Python
/Repetition Structures/Distance Travelled/Distance Travelled/Distance_Travelled.py
777
4.4375
4
# Function that asks the user to input the number of hours they have driven and the speed at which they were driving, the program will then calculate the total distance travelled per hour distanceTravelled = 0; numHours = int(input("Please enter the number of hours you drove: ")); speed = int(input("Please enter the ...
true
3d9f49a20ba365934e8a47255bde04df1db32495
Ryandalion/Python
/Dictionaries and Sets/File Analysis/File Analysis/File_Analysis.py
1,525
4.1875
4
# Program will read the contents of two text files and determine a series of results between the two, such as mutual elements, exclusive elements, etc. def main(): setA = set(open("file1.txt").read().split()); # Load data from file1.txt into setA setB = set(open("file2.txt").read().split()); # Load data from f...
true
564b68912dd8b44e4001a22d92ff18471a55fbe4
Ryandalion/Python
/Decision Structures and Boolean Logic/Age Calculator/Age Calculator/Age_Calculator.py
568
4.4375
4
# Function takes user's age and tells them if they are an infant, child, teen, or adult # 1 year old or less = INFANT # 1 ~ 13 year old = CHILD # 13 ~ 20 = TEEN # 20+ = ADULT userAge = int(input('Please enter your age: ')); if userAge < 0 or userAge > 135: print('Please enter a valid age'); else: if userAge <...
true
8a4d3456f828edb3893db4e6dd836873344b91e9
Ryandalion/Python
/Functions/Future Value/Future Value/Future_Value.py
1,862
4.59375
5
# Program calculates the future value of one's savings account def calculateInterest(principal, interestRate, months): # Function calculates the interest accumulated for the savings account given the arguments from the user interestRate /= 100; # Convert the interest rate into a decimal futureValue = principal...
true
39cd605853421bafc6abaeda2b905e3bf06b6c6e
Ryandalion/Python
/Functions/Rock, Paper, Scissors!/Rock, Paper, Scissors!/Rock__Paper__Scissors_.py
2,151
4.46875
4
# Program is a simple rock paper scissors game versus the computer. The computer's hand will be randomly generated and the user will input theirs. Then the program will determine the winner. If it is a tie, a rematch will execute import random; # Import random module to use randint def generate_random(): # Generate a...
true
c19b84caf9895177da8ccbcbd845ef5f03653e4d
Ryandalion/Python
/Functions/Fat and Carb Calorie Calculator/Fat and Carb Calorie Calculator/Fat_and_Carb_Calorie_Calculator.py
1,465
4.34375
4
# Function that gathers the carbohyrdates and fat the user has consumed and displays the amount of calories gained from each def fatCalorie(fat): # Function calculates the calories gained from fat calFat = fat * 9; print("The total calories from",fat,"grams of fat is", calFat,"calories"); def carbCalorie(car...
true
5d4fa6aaab3cc50ab1b67c9ab5add9ca49d2f25a
Ryandalion/Python
/Decision Structures and Boolean Logic/Roman Numeral Converter/Roman Numeral Converter/Roman_Numeral_Converter.py
1,269
4.21875
4
# Function converts a number to a roman numeral userNum = int(input('Please enter a literal number between 1 ~ 10 you wish to convert to a Roman numeral: ')); if userNum < 0 or userNum > 10: print('Please enter a number between 1 and 10'); else: if userNum == 1: print('I'); else: if userNu...
true
2b7ac8c5047791e80d7078a9f678b27c0c79d997
Ryandalion/Python
/Lists and Tuples/Larger than N/Larger than N/Larger_than_N.py
1,752
4.3125
4
# Program generates a list via random generation and compares it to a user input number n which will determine if the elements within the last are greater than the number import random; # Import the random module to generate a random integer def main(): randNum = [0] * 10; # Intialize list with 10 elements of zer...
true
daee14c84fcbbe19529eae9f874083297fc67493
run-fourest-run/PythonDataStructures-Algos
/Chapter 3 - Python Data Types and Structures/Sets.py
2,216
4.125
4
''' Sets are unordered collection of unique items. Sets are mutable, but the elements inside of them are immutable. * Important distinctions is that the cannot contain duplicate keys * Sets are typically used to perform mathmatical operations such as intersection, union, difference and complement. Unlike sequence ty...
true
90e9a6e867b5601d2ce5fc2ed648d980eb904b17
PWalis/Intro-Python-I
/src/10_functions.py
495
4.28125
4
# Write a function is_even that will return true if the passed-in number is even. # YOUR CODE HERE def is_even(n): if n % 2 == 0: return True else: return False print(is_even(6)) # Read a number from the keyboard num = input("Your number here") num = int(num) # Print out "Even!" if the numbe...
true
ad0017b73937ba9313620bfc23101a2502707321
Sumanthsjoshi/capstone-python-projects
/src/get_prime_number.py
728
4.125
4
# This program prints next prime number until user chooses to stop # Problem statement: Have the program find prime numbers until the user chooses # to stop asking for the next one. # Define a generator function def get_prime(): num = 3 yield 2 while True: is_prime = True for j in range(3,...
true
8c99ba43d3481a6190df22b51b93d2d94358f68c
abhic55555/Python
/Assignments/Assignment2/Assignment2_3.py
440
4.15625
4
def factorial(value1): if value1 > 0: factorial = 1 for i in range(1,value1 + 1): factorial = factorial*i print("The factorial of {} is {}".format(value1,factorial)) elif value1==0: print("The factorial of 0 is 1 ") else:- print("Invalid number") ...
true
6b89934c7911e7f1c24db7c739b46eb26050297c
Tyler668/Code-Challenges
/twoSum.py
1,018
4.1875
4
# # Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. # # (i.e., [0, 1, 2, 4, 5, 6, 7] might become[4, 5, 6, 7, 0, 1, 2]). # # You are given a target value to search. If found in the array return its index, otherwise return -1. # # You may assume no duplicate exists in th...
true
15be302b0b417de9eb462b731ad20a0d78e448d8
SaiJyothiGudibandi/Python_CS5590-490-0001
/ICE/ICE1/2/Reverse.py
328
4.21875
4
num = int(input('Enter the number:')) #Taking nput from the user Reverse = 0 while(num > 0): #loop to check whether the number is > 0 Reminder = num%10 # finding the reminder for number Reverse = (Reverse * 10) + Reminder num = num // 10 print('Reverse for the Entered number is:%d' %Reverse) ...
true
bb0b85fbe5e9fe5c3e05dfb28f35feba48e2d0d7
jarturomora/learningpython
/ex16bis.py
834
4.28125
4
from sys import argv script, filename = argv # Opening the file in "read-write" mode. my_file = open(filename, "rw+") # We show the current contents of the file passed in filename. print "This is the current content of the file %r." % filename print my_file.read() print "Do you want to create new content for this f...
true
8e81b8f7d46c6257d8a6dbabfd677297149148be
jarturomora/learningpython
/ex44e.py
863
4.15625
4
class Other(object): def override(self): print "OTHER override()" def implicit(self): print "OTHER implicit()" def altered(self): print "OTHER altered()" class Child(object): def __init__(self): self.other = Other() # The composition begins here ...
true
01ce27d5d65b55566cccded488d1c99d2fd848b0
dablackwood/my_scripts_project_euler
/specific_solutions/project_euler_019.py
1,079
4.1875
4
""" You are given the following information, but you may prefer to do some research for yourself. * 1 Jan 1900 was a Monday. * Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on le...
true
159b7422dc21ca5c01cec91b1c27ee3a88b08ca1
dablackwood/my_scripts_project_euler
/specific_solutions/project_euler_029a.py
759
4.15625
4
""" Consider all integer combinations of a^(b) for 2<=a<=5 and 2<=b<=5: 2^(2)=4, 2^(3)=8, 2^(4)=16, 2^(5)=32 3^(2)=9, 3^(3)=27, 3^(4)=81, 3^(5)=243 4^(2)=16, 4^(3)=64, 4^(4)=256, 4^(5)=1024 5^(2)=25, 5^(3)=125, 5^(4)=625, 5^(5)=3125 If they are then placed in numerical order, with any repeats removed,...
true
73980da3c813213a81f11db877458ff72c0a47b7
shaziya21/PYTHON
/constructor_in_inheritance.py
732
4.1875
4
class A: # Parent class / Super class def __init__(self): # Constructor of parent class A print("in A init") def feature1(self): print("feature1 is working") def feature2(self): print("feature2 is working") class B(A): def __init__(self): super().__init__() # jum...
true
6ffafcc1da316699df44275889ffab8ba957265f
shaziya21/PYTHON
/MRO.py
1,004
4.4375
4
class A: # Parent class / Super class def __init__(self): # Constructor of parent class A print("in A init") def feature1(self): print("feature 1-A is working") def feature2(self): print("feature2 is working") class B: def __init__(self): # Constructor of class B ...
true
1e870f6429ff8f0b0cde4f40b7d0f3e148242257
JoshiDivya/PythonExam
/Pelindrome.py
354
4.3125
4
def is_pelindrome(word): word=word.lower() word1=word new_str='' while len(word1)>0: new_str=new_str+ word1[-1] word1=word1[:-1] print(new_str) if (new_str== word): return True else: return False if is_pelindrome(input("Enter String >>>")): print("yes,this is pelindrome") else: pri...
true
2dd93300d7ede7b2fd78a925eeea3d912ae55c51
dhaffner/pycon-africa
/example1.py
408
4.53125
5
# Example #1: Currying with inner functions # Given a function, f(x, y)... def f(x, y): return x ** 2 + y ** 2 # ...currying constructs a new function, h(x), that takes an argument # from X and returns a function that maps Y to Z. # # f(x, y) = h(x)(y) # def h(x): def curried(y): return f(x, y) r...
true
a93f8e9ac02ba81adbd2b0ead5aa0a2af11d6011
egill12/pythongrogramming
/P3_question4.py
842
4.625
5
''' Write a program that asks the user for a long string containing multiple words. Echo back to the user the same string, except with the words in backwards order. For example, say we type the string: My name is Michele Then we would expect to see the string: Michele is name My ''' def reverse_str(string): ''' ...
true
fc044bef4295e8e85313366be4a89689938756c2
BjornChrisnach/Basics_of_Computing_and_Programming
/days_traveled.py
233
4.125
4
print("Please enter the number of days you traveled") days_traveled = int(input()) full_weeks = days_traveled // 7 remaining_days = days_traveled % 7 print(days_traveled, "days are", full_weeks, "weeks and",\ remaining_days,"days")
true
386917245b7e7130aa3a96abccf9ca35842e1904
getachew67/UW-Python-AI-Coursework-Projects
/Advanced Data Programming/hw2/hw2_pandas.py
2,159
4.1875
4
""" Khoa Tran CSE 163 AB This program performs analysis on a given Pokemon data file, giving various information like average attack levels for a particular type or number of species and much more. This program immplements the panda library in order to compute the statistics. """ def species_count(data): """ ...
true
5d01d82bfd16634be636cce2cf2e1d31ea7208b1
Razorro/Leetcode
/88. Merge Sorted Array.py
1,353
4.28125
4
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. Example: I...
true
2cd13056f72eaf8f16e342bacde6c9b17bd43d3b
Razorro/Leetcode
/49. Group Anagrams.py
863
4.125
4
""" Description: Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat","tan"], ["bat"] ] Note: All inputs will be in lowercase. The order of your output does not matter. Runtime: 152 ms, faster than 39.32% of Pytho...
true
d2d6f21556955a4b8ec8893b8bf03e7478032b68
Razorro/Leetcode
/7. Reverse Integer.py
817
4.15625
4
""" Description: Given a 32-bit signed integer, reverse digits of an integer. Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overfl...
true
92b2ac96f202ac222ccd4b9572595602abf0a459
jrahman1988/PythonSandbox
/myDataStruct_CreateDictionaryByFilteringOutKeys.py
677
4.34375
4
''' A dictionary is like an address-book where we can find the address or contact details of a person by knowing only his/her name i.e. we associate keys (name) with values Dictionary is represented by dict class. Pair of keys and values are specified in dictionary using the notation d = {key1 : value1, key2 : value2 }...
true
1a4d781b35cfbb98acbc1b8b9fad8aa9a78c51ac
jrahman1988/PythonSandbox
/myPandas_DescriptiveStatistics.py
1,754
4.40625
4
''' A large number of methods collectively compute descriptive statistics and other related operations on DataFrame. Most of these are aggregations like sum(), mean(), but some of them, like sumsum(), produce an object of the same size. Generally speaking, these methods take an axis argument, just like ndarray.{sum, st...
true
f45471a04eef4398d02bbe12151a6b031b394452
jrahman1988/PythonSandbox
/myFunction_printMultipleTimes.py
427
4.3125
4
''' Functions are reusable pieces of programs. They allow us to give a name to a block of statements, allowing us to run that block using the specified name anywhere in your program and any number of times. This is known as calling the function. ''' def printMultipleTimes(message:str, time:int): print(message * tim...
true
b2965c970bce71eee39841548b95ab6edf37d99b
jrahman1988/PythonSandbox
/myLambdaFunction.py
1,212
4.125
4
''' A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression. Syntax lambda arguments : expression ''' #define the lambda function sentence = "I bought a bike, from a bike store, she bought a bike from amazon, they bought a bike from bike sto...
true
76e7dc6bfa340596459f1a535e4e2e191ea483bc
jrahman1988/PythonSandbox
/myOOPclass3.py
2,017
4.46875
4
''' There is way of organizing a software program which is to combine data and functionality and wrap it inside something called an object. This is called the object oriented programming paradigm. In this program we'll explore Class, behaviour and attributes of a class ''' #Declaring a class named Mail and its methods...
true
cf3158ef73377ac7fe644d4637c21ae1501d804b
jrahman1988/PythonSandbox
/myStringFormatPrint.py
551
4.25
4
#Ways to format and print age: int = 20 name: str = "Shelley" #Style 1 where format uses indexed parameters print('{0} was graduated from Wayne State University in Michigan USA when she was {1}'.format(name,age)) #Style 2 where 'f' is used as f-string print(f'{name} was graduated from Wayne State University in Michi...
true
34653fdfffaacb579ad87ee2d590c6ae37c5bb71
mimipeshy/pramp-solutions
/code/drone_flight_planner.py
1,903
4.34375
4
""" Drone Flight Planner You’re an engineer at a disruptive drone delivery startup and your CTO asks you to come up with an efficient algorithm that calculates the minimum amount of energy required for the company’s drone to complete its flight. You know that the drone burns 1 kWh (kilowatt-hour is an energy unit) f...
true
dd9c666ab17a5afeb3e6c0fa1bdd1b27bb7f78ce
CSC1-1101-TTh9-S21/lab-week3
/perimeter.py
594
4.3125
4
# Starter code for week 3 lab, parts 1 and 2 # perimeter.py # Prof. Prud'hommeaux # Get some input from the user. a=int(input("Enter the length of one side of the rectangle: ")) b=int(input("Enter the length of the other side of the rectangle: ")) # Print out the perimeter of the rectangle c = a + a + b + b print("Th...
true
abdff8d3bf6c1e1cc39a24519587e5760294bdc6
arkiz/py
/lab1-4.py
413
4.125
4
studentName = raw_input('Enter student name.') creditsDegree = input('Enter credits required for degree.') creditsTaken = input('Enter credits taken so far.') degreeName = raw_input('Enter degree name.') creditsLeft = (creditsDegree - creditsTaken) print 'The student\'s name is', studentName, ' and the degree name...
true
517f231a66c9d977bc5a34eaa92b6ad986a8e340
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-3/3-1-2-12-Python-loops-else-The-while-loop-and-the-else-branch.py
356
4.15625
4
#!/usr/bin/python3 """ Both loops, while and for, have one interesting (and rarely used) feature. As you may have suspected, loops may have the else branch too, like ifs. The loop's else branch is always executed once, regardless of whether the loop has entered its body or not. """ i = 1 while i < 5: print(i) ...
true
6920b44453655be0855b3977c12f2ed33bdb0bc3
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-4/4-1-3-10-LAB-Converting-fuel-consumption.py
1,432
4.4375
4
#!/usr/bin/python3 """ A car's fuel consumption may be expressed in many different ways. For example, in Europe, it is shown as the amount of fuel consumed per 100 kilometers. In the USA, it is shown as the number of miles traveled by a car using one gallon of fuel. Your task is to write a pair of functions convertin...
true
c9bedff4032b89fbd4054b4f03093af06a3d01d0
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-2/2-1-4-10-LAB-Operators-and-expressions.py
567
4.5625
5
#!/usr/bin/python3 """ Take a look at the code in the editor: it reads a float value, puts it into a variable named x, and prints the value of a variable named y. Your task is to complete the code in order to evaluate the following expression: 3x3 - 2x2 + 3x - 1 The result should be assigned to y. """ x = 0 x = floa...
true
fd86bac9750e54714b1fe65d050d336dba9399ca
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-4/4-1-3-9-LAB-Prime-numbers-how-to-find-them.py
1,302
4.28125
4
#!/usr/bin/python3 """ A natural number is prime if it is greater than 1 and has no divisors other than 1 and itself. Complicated? Not at all. For example, 8 isn't a prime number, as you can divide it by 2 and 4 (we can't use divisors equal to 1 and 8, as the definition prohibits this). On the other hand, 7 is a prim...
true
3e7b84ff790a508534c03cdc878f6abdf2e32a53
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-3/3-1-6-1-Operations-on-lists-The-inner-life-of-lists.py
1,345
4.375
4
#!/usr/bin/python3 """ The inner life of lists Now we want to show you one important, and very surprising, feature of lists, which strongly distinguishes them from ordinary variables. We want you to memorize it - it may affect your future programs, and cause severe problems if forgotten or overlooked. Take a look at...
true
946ec887e106dde979717832e603732ef85a750c
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-4/4-1-2-2-How-functions-communicate-with-their-environment-Parametrized-functions.py
1,358
4.375
4
#!/usr/bin/python3 """ It's legal, and possible, to have a variable named the same as a function's parameter. The snippet illustrates the phenomenon: def message(number): print("Enter a number:", number) number = 1234 message(1) print(number) A situation like this activates a mechanism called shadowing: pa...
true
b6732e8d49b943a0391fe3d6521bdf29d2f840ee
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-3/3-1-1-11-LAB-Comparison-operators-and-conditional-execution.py
1,014
4.46875
4
#!/usr/bin/python3 """ Spathiphyllum, more commonly known as a peace lily or white sail plant, is one of the most popular indoor houseplants that filters out harmful toxins from the air. Some of the toxins that it neutralizes include benzene, formaldehyde, and ammonia. Imagine that your computer program loves these pl...
true
ad07c957de435974775396e4cc0b8a793ffe4141
michellecby/learning_python
/week7/checklist.py
788
4.1875
4
#!/usr/bin/env python3 # Write a program that compares two files of names to find: # Names unique to file 1 # Names unique to file 2 # Names shared in both files import sys import biotools file1 = sys.argv[1] file2 = sys.argv[2] def mkdictionary(filename): names = {} with open(filename) as fp: for name in fp.r...
true
2f8d761707c15cef64f9e8b49aae03c733959d00
leetuckert10/CrashCourse
/chapter_9/exercise_9-6.py
1,668
4.375
4
# Exercise 9-6: Ice Cream Stand # Write a class that inherits the Restaurant class. Add and an attribute # called flavors that stores a list of ice cream flavors. Add a method that # displays the flavors. Call the class IceCreamStand. from restaurant import Restaurant class IceCreamStand(Restaurant): def __ini...
true
df70e46cceaa083c3a0545af8eb83463295b0b40
leetuckert10/CrashCourse
/chapter_11/test_cities.py
1,339
4.3125
4
# Exercise 11-1: City, Country # # Create a file called test_city.py that tests the function you just wrote. # Write a method called test_city_country() in the class you create for testing # the function. Make sure it passes the test. # # Remember to import unittest and the function you are testing. Remember that # the...
true
f4f669c12f07d0320e5d9a01fec7542e249d4962
leetuckert10/CrashCourse
/chapter_4/exercise_4-10.py
539
4.5625
5
# Slices # Use list splicing to print various parts of a list. cubes = [value**3 for value in range(1, 11)] # list comprehension print("The entire list:") for value in cubes: # check out this syntax for suppressing a new line. print(value, " ", end="") print('\n') # display first 3 items print(f"The first three item...
true
1897ec6770bca8f6e0dc72abbcdcd70644e6f182
leetuckert10/CrashCourse
/chapter_8/exercise_8-14.py
764
4.3125
4
# Exercise 8-13: Cars # Define a function that creates a list of key-value pairs for all the # arbitrary arguments. The syntax **user_info tell Python to create a # dictionary out of the arbitrary parameters. def make_car(manufacturer, model, **car): """ Make a car using a couple positional parameters and and a...
true
997df0520551de4bfb67665932840b09fa1a6d5a
leetuckert10/CrashCourse
/chapter_6/exercise_6-9.py
1,229
4.21875
4
# Favorite Places: # Make a dictionary of favorite places with the persons name as the kep. # Create a list as one of the items in the dictionary that contains one or # more favorite places. favorite_places = { 'terry': ['wild cat rock', 'mount mitchell', 'grandfather mountain'], 'carlee': ['blue ridge parkway...
true
ab6b62451de82d2c52b1b994cfabab7893c4f64e
leetuckert10/CrashCourse
/chapter_8/exercise_8-3.py
541
4.125
4
# Exercise 8-3: T-Shirt # Write a function called make_shirt() that accepts a size and a string for # the text to be printed on the shirt. Call the function twice: once with # positional arguments and once with keyword arguments. def make_shirt(text, size): print(f"Making a {size.title()} T-Shirt with the text ...
true
928d97a0023a0a64773fb1df4c1e59bc20f01123
algorithms-21-devs/Interview_problems
/weekly_interview_questions/IQ_4/Q4_emmanuelcodev/Q4Medium_N.py
1,840
4.25
4
import node as n ''' Time complexity: O(n) Algorithm iterates through link list once only. It adds memory location as a key to a dictionary. As it iterates it checks if the current node memory matches any in the dictionary in O(1) time. If it does a cycle must be present. ''' def cycle(head_node): #must be a linke...
true
4374c169c241a96ef6fc26f74a3c514f4cc216ed
algorithms-21-devs/Interview_problems
/weekly_interview_questions/IQ_2/Q2_Emmanuelcodev/Q2Medium_Nsquared.py
2,634
4.1875
4
def unique_pairs(int_list, target_sum): #check for None ''' Time complexity: O(n^2). 1) This is because I have a nested for loop. I search through int_list, and for each element in int_list I search through int_list again. N for the outer and n^2 with the inner. 2) The...
true
f587e8614825a2d013715057bf7cffc0ed0cf287
Earazahc/exam2
/derekeaton_exam2_p2.py
1,032
4.25
4
#!/usr/bin/env python3 """ Python Exam Problem 5 A program that reads in two files and prints out all words that are common to both in sorted order """ from __future__ import print_function def fileset(filename): """ Takes the name of a file and opens it. Read all words and add them to a set. Args: ...
true
b2c24fe1f3d4f3474b70461b608a2c14e9d44e9b
viralsir/python_saket
/if_demo.py
1,045
4.15625
4
''' control structure if syntax : if condition : statement else : statement relational operator operator symbol greater than > less than < equal to == not equal to != gr...
true
0bdb3507ea776a6b421a6e8dfda6c3e47f2c38bd
viralsir/python_saket
/def_demo3.py
354
4.1875
4
def prime(no): is_prime=True for i in range(2,no): if no % i == 0 : is_prime=False return is_prime def factorial(no): fact=1 for i in range(1,no+1): fact=fact*i return fact # no=int(input("enter No:")) # # if prime(no): # print(no," is a prime no") # else : # ...
true
2a0ffb39c845e7827d3a841c9f0475f42e8a5838
kalyan-dev/Python_Projects_01
/demo/oop/except_demo2.py
927
4.25
4
# - Accept numbers from user until zero is given and display SUM of the numbers; handle Invalid Numbers; # program should not crash, but should continue; def is_integer(n): try: return float(n).is_integer() except ValueError: return False def is_integer_num(n): if isinstance(...
true
9b6a117c5d2ae6e591bc31dfd1ba748b84079710
tejaboggula/gocloud
/fact.py
332
4.28125
4
def fact(num): if num == 1: return num else: return num*fact(num-1) num = int(input("enter the number to find the factorial:")) if num<0: print("factorial is not allowed for negative numbers") elif num == 0: print("factorial of the number 0 is 1") else: print("factorial of",num, "is:...
true
0fa7e809c7f4a8c7b0815a855cbc482abf600a77
dimpy-chhabra/Artificial-Intelligence
/Python_Basics/ques1.py
254
4.34375
4
#Write a program that takes three numbers as input from command line and outputs #the largest among them. #Question 02 import sys s = 0 list = [] for arg in sys.argv[1:]: list.append(int(arg)) #arg1 = sys.argv[1] list.sort() print list[len(list)-1]
true
e8e83ac29ce59ebb1051bbe6457e3d5bd8ade162
snail15/AlgorithmPractice
/Udacity/BasicAlgorithm/binarySearch.py
1,127
4.3125
4
def binary_search(array, target): '''Write a function that implements the binary search algorithm using iteration args: array: a sorted array of items of the same type target: the element you're searching for returns: int: the index of the target, if found, in the source -1: ...
true
460d75a61550f0ae818f06ad46a9c210fe0d254e
lyderX05/DS-Graph-Algorithms
/python/BubbleSort/bubble_sort_for.py
911
4.34375
4
# Bubble Sort For Loop # @author: Shubham Heda # Email: hedashubham5@gmail.com def main(): print("**NOTE**: Elements should be less then 25 as alogrithm work best on that only") print("Enter Bubble Sort elements sepreated by (',') Comma: ") input_string = input() array = [int(each) for each in input_st...
true
8674d8f7e11eae360e63b470b7b2310f7170c5cc
zeusumit/JenkinsProject
/hello.py
1,348
4.40625
4
print('Hello') print("Hello") print() print('This is an example of "Single and double"') print("This is an example of 'Single and double'") print("This is an example of \"Single and double\"") seperator='***'*5 fruit="apple" print(fruit) print(fruit[0]) print(fruit[3]) fruit_len=len(fruit) print(fruit_len) ...
true
33553f9506dc46c9c05101074116c5254af7d0e9
EderVs/hacker-rank
/30_days_of_code/day_8.py
311
4.125
4
""" Day 8: Dictionaries and Maps! """ n = input() phones_dict = {} for i in range(n): name = raw_input() phone = raw_input() phones_dict[name] = phone for i in range(n): name = raw_input() phone = phones_dict.get(name, "Not found") if phone != "Not found": print name + "=" + phone else: print phone
true
6784ec88c6088dfcd462a124bc657be9a4c51c3c
asmitaborude/21-Days-Programming-Challenge-ACES
/generator.py
1,177
4.34375
4
# A simple generator function def my_gen(): n = 1 print('This is printed first') # Generator function contains yield statements yield n n += 1 print('This is printed second') yield n n += 1 print('This is printed at last') yield n # Using for loop for item in...
true
46a7b9c9a436f4620dac591ed193a09c9b164478
asmitaborude/21-Days-Programming-Challenge-ACES
/python_set.py
2,244
4.65625
5
# Different types of sets in Python # set of integers my_set = {1, 2, 3} print(my_set) # set of mixed datatypes my_set = {1.0, "Hello", (1, 2, 3)} print(my_set) # set cannot have duplicates # Output: {1, 2, 3, 4} my_set = {1, 2, 3, 4, 3, 2} print(my_set) # we can make set from a list # Output: {1, 2, ...
true
1a87238ebb8b333148d1c2b4b094370f21fd230b
asmitaborude/21-Days-Programming-Challenge-ACES
/listsort.py
677
4.4375
4
#python list sort () #example 1:Sort a given list # vowels list vowels = ['e', 'a', 'u', 'o', 'i'] # sort the vowels vowels.sort() # print vowels print('Sorted list:', vowels) #Example 2: Sort the list in Descending order # vowels list vowels = ['e', 'a', 'u', 'o', 'i'] # sort the vowels vowels.sort...
true
6346a452b77b895e2e686c5846553687459798ca
asmitaborude/21-Days-Programming-Challenge-ACES
/dictionary.py
2,840
4.375
4
#Creating Python Dictionary # empty dictionary my_dict = {} # dictionary with integer keys my_dict = {1: 'apple', 2: 'ball'} # dictionary with mixed keys my_dict = {'name': 'John', 1: [2, 4, 3]} # using dict() my_dict = dict({1:'apple', 2:'ball'}) # from sequence having each item as a pair my_dict = d...
true
f1e73874c9d09a51aa7b9c4a5890fe3cb34f5622
parth-sp02911/My-Projects
/Parth Patel J2 2019 problem.py
1,161
4.125
4
#Parth Patel #797708 #ICS4UOA #J2 problem 2019 - Time to Decompress #Mr.Veera #September 6 2019 num_of_lines = int(input("Enter the number of lines: ")) #asks the user how many lines they want and turns that into an integer output_list = [] #creates a list which will hold the values of the message th...
true
4783c951d8caaf9c5c43fb57694cfb8d60d466b7
marcinosypka/learn-python-the-hard-way
/ex30.py
1,691
4.125
4
#this line assigns int value to people variable people = 30 #this line assigns int value to cars variable cars = 30 #this line assigns int value to trucks variable trucks = 30 #this line starts compound statemet, if statemets executes suite below if satement after if is true if cars > people: #this line belongs to sui...
true
c5d852ead39ef70ee91f26778f4a7874e38466cf
bohdi2/euler
/208/directions.py
792
4.125
4
#!/usr/bin/env python3 import collections import itertools from math import factorial import sys def choose(n, k): return factorial(n) // (factorial(k) * factorial(n-k)) def all_choices(n, step): return sum([choose(n, k) for k in range(0, n+1, step)]) def main(args): f = factorial expected = {'1'...
true
656d28880463fdd9742a9e2c6c33c2c247f01fbf
andylws/SNU_Lecture_Computing-for-Data-Science
/HW3/P3.py
590
4.15625
4
""" #Practical programming Chapter 9 Exercise 3 **Instruction** Write a function that uses for loop to add 1 to all the values from input list and return the new list. The input list shouldn’t be modified. Assume each element of input list is always number. Complete P3 function P3([5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, ...
true
69e6a29d952a0a5faaceed45e30bf78c5120c070
TommyWongww/killingCodes
/Daily Temperatures.py
1,025
4.25
4
# @Time : 2019/4/22 22:54 # @Author : shakespere # @FileName: Daily Temperatures.py ''' 739. Daily Temperatures Medium Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future da...
true
1ae82daf01b528df650bd7e72a69107cdf686a82
TommyWongww/killingCodes
/Invert Binary Tree.py
1,251
4.125
4
# @Time : 2019/4/25 23:51 # @Author : shakespere # @FileName: Invert Binary Tree.py ''' 226. Invert Binary Tree Easy Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was i...
true
202bd0898352102599f6e4addccaec7a60b46a8f
amymhaddad/exercises_for_programmers_2019
/flask_product_search/products.py
1,454
4.15625
4
import json #convert json file into python object def convert_json_data(file): """Read in the data from a json file and convert it to a Python object""" with open (file, mode='r') as json_object: data = json_object.read() return json.loads(data) #set json data that's now a python object to pro...
true
ab06ae955363b0ac7fcdfd22f35e9ea6e698d5c3
LakshayLakhani/my_learnings
/programs/binary_search/bs1.py
484
4.125
4
# given a sorted arrray with repititions, find left most index of an element. arr = [2, 3, 3, 3, 3] l = 0 h = len(arr) search = 3 def binary_search(arr, l, h, search): mid = l+h//2 if search == arr[mid] and (mid == 0 or arr[mid-1] != search): return mid elif search <= arr[mid]: return bina...
true
99f8aed5acd78c31b9885eba4b830807459383be
chenp0088/git
/number.py
288
4.375
4
#!/usr/bin/env python # coding=utf-8 number = input("If you input a number ,I will tell you if the number is multiplier of ten! Please input the number: ") number = int(number) if number%10 == 0: print("It`s the multiplier of ten!") else: print("It`s not the multiplier of ten!")
true
08e48ae76c18320e948ec941e0be4b598720feeb
nkarasovd/Python-projects
/Data Structures and Algorithms Specialization/Algorithms on Strings/week2/4_suffix_array/suffix_array.py
632
4.1875
4
# python3 import sys def build_suffix_array(text): """ Build suffix array of the string text and return a list result of the same length as the text such that the value result[i] is the index (0-based) in text where the i-th lexicographically smallest suffix of text starts. """ ...
true
de7f2d2afcb130e6d5484bdbad0795fbf54bdf2f
Moloch540394/machine-learning-hw
/linear-regression/driver.py
1,398
4.3125
4
"""Computes the linear regression on a homework provided data set.""" __author__="Jesse Lord" __date__="January 8, 2015" import numpy as np import matplotlib.pyplot as plot from computeCost import computeCost from gradientDescent import gradientDescent from featureNormalization import featureNormalization import read...
true
1a3bd1022273e086eeeb742ebace201d1aceceae
tmoraru/python-tasks
/less9.py
434
4.1875
4
#Print out the slice ['b', 'c', 'd'] of the letters list. letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] print(letters[1:4]) #Print out the slice ['a', 'b', 'c'] of the letters list letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] print(letters[0:3]) #Print out the slice ['e', 'f', 'g'] of the letters lis...
true
d4076402594b83189895f19cdc4730f9bd5e9072
liginv/LP3THW
/exercise11-20/ex15.py
547
4.15625
4
# Importing the function/module argv from sys library in python from sys import argv # Assigning the varable script & filename to argv function script, filename = argv # Saving the open function result to a variable txt. # Open function is the file .txt file. txt = open(filename) # Printing the file name. print(f"Here'...
true
7106600daa9540e96be998446e8e199ffd56ec28
rhino9686/DataStructures
/mergesort.py
2,524
4.25
4
def mergesort(arr): start = 0 end = len(arr) - 1 mergesort_inner(arr, start, end) return arr def mergesort_inner(arr, start, end): ## base case if (start >= end): return middle = (start + end)//2 # all recursively on two halves mergesort_inner(arr, middle + 1, end) ...
true
8b54f8006c98b5e88b7dd655e8338bb4fe3ba02c
CyberSamurai/Test-Project-List
/count_words.py
574
4.4375
4
""" -=Mega Project List=- 5. Count Words in a String - Counts the number of individual words in a string. For added complexity read these strings in from a text file and generate a summary. """ import os.path def count_words(string): words = string.split() return len(words) def main(file): filename = os...
true
f5f862e7bc7179f1e9831fe65d20d4513106e764
AhmedMohamedEid/Python_For_Everybody
/Data_Stracture/ex_10.02/ex_10.02.py
1,079
4.125
4
# 10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon. # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008...
true
14fd0afadadb85ccffb9e5cb447fa155874479ea
thienkyo/pycoding
/quick_tut/basic_oop.py
657
4.46875
4
class Animal(object): """ This is the animal class, an abstract one. """ def __init__(self, name): self.name = name def talk(self): print(self.name) a = Animal('What is sound of Animal?') a.talk() # What is sound of Animal? class Cat(Animal): def talk(self): print(...
true
4f330c0fdbe5a6cc49b506011b88c610ef1abc60
Jules-Boogie/controllingProgramFlow
/SearchAStringFunction/func.py
1,087
4.21875
4
""" A function to find all instances of a substring. This function is not unlike a 'find-all' option that you might see in a text editor. Author: Juliet George Date: 8/5/2020 """ import introcs def findall(text,sub): """ Returns the tuple of all positions of substring sub in text. If sub does not appea...
true
b1185e9c9738f772857051ae03af54a4fb20487e
Jules-Boogie/controllingProgramFlow
/FirstVowel-2/func.py
976
4.15625
4
""" A function to search for the first vowel position Author: Juliet George Date: 7/30/2020 """ import introcs def first_vowel(s): """ Returns the position of the first vowel in s; it returns -1 if there are no vowels. We define the vowels to be the letters 'a','e','i','o', and 'u'. The letter 'y' ...
true
b7d990539a50faef24a02f8325342f385f518101
github0282/PythonExercise
/Abhilash/Exercise2.py
1,141
4.34375
4
# replace all occurrences of ‘a’ with $ in a String text1 = str(input("Enter a string: ")) print("The string is:", text1) search = text1.find("a") if(search == -1): print("Character a not present in string") else: text1 = text1.replace("a","$") print(text1) # Take a string and replace every blank space wi...
true
89495c7cb55268122493bb126b1e3ea9a9c19fca
Jamilnineteen91/Sorting-Algorithms
/Merge_sort.py
1,986
4.34375
4
nums = [1,4,5,-12,576,12,83,-5,3,24,46,100,2,4,1] def Merge_sort(nums): if len(nums)<=1: return nums middle=int(len(nums)//2)#int is used to handle a floating point result. left=Merge_sort(nums[:middle])#Divises indices into singular lists. print(left)#Prints list division, lists with singular...
true
b4d3e19be67069f37487506a473ba9bce4def0be
jeffjbilicki/milestone-5-challenge
/milestone5/m5-bfs.py
631
4.1875
4
#!/usr/bin/env python # Given this graph graph = {'A': ['B', 'C', 'E'], 'B': ['A','D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B','D'], 'F': ['C'], 'G': ['C']} # Write a BFS search that will return the shortest path def bfs_shortest_path(graph, start, ...
true
580a215b24366f1e6dcf7d3d5253401667aa1aae
afialydia/Graphs
/projects/ancestor/ancestor.py
2,127
4.125
4
from util import Queue class Graph: """Represent a graph as a dictionary of vertices mapping labels to edges.""" def __init__(self): self.vertices = {} def add_vertex(self, vertex_id): """ Add a vertex to the graph. """ if vertex_id not in self.vertices: ...
true
4e21512a276938c54dc5a26524338584d3d31673
snangunuri/python-examples
/pyramid.py
1,078
4.25
4
#!/usr/bin/python ############################################################################ #####This program takes a string and prints a pyramid by printing first character one time and second character 2 timesetc.. within the number of spaces of length of the given string### ######################################...
true
76c008e9115f338deac839e9e2dafd583377da46
pkongjeen001118/awesome-python
/generator/simple_manual_generator.py
517
4.15625
4
def my_gen(): n = 1 print('This is printed first') yield n n += 1 print('This is printed second') yield n n += 1 print('This is printed at last') yield n if __name__ == '__main__': a = my_gen() # return generator obj. print(a) print(next(a)) # it will resume t...
true
1f291ba8c19a6b242754f14b58e0d229385efe8b
JunyoungJang/Python
/Introduction/01_Introduction_python/10 Python functions/len.py
663
4.1875
4
import numpy as np # If x is a string, len(x) counts characters in x including the space multiple times. fruit = 'banana' fruit_1 = 'I eat bananas' fruit_2 = ' I eat bananas ' print len(fruit) # 6 print len(fruit_1) # 13 print len(fruit_2) # 23 # If x is a (column or row) vector, len(x) reports the length o...
true
571400657495936c96d31a67b1bc2afeeeaa1bf6
ICESDHR/Bear-and-Pig
/Practice/Interview/24.反转链表.py
1,016
4.34375
4
# -*- coding:utf-8 -*- class ListNode: def __init__(self,value): self.value = value self.next = None # 没思路 def ReverseList(root): pNode,parent,pHead = root,None,None while pNode: child = pNode.next if child is None: pHead = pNode pNode.next = parent parent = pNode pNode = child return pHead # 递归...
true
c247ba288604b38dafbb692aa49acf8b74ebd353
izdomi/python
/exercise10.py
482
4.25
4
# Take two lists # and write a program that returns a list that contains only the elements that are common between the lists # Make sure your program works on two lists of different sizes. Write this using at least one list comprehension. # Extra: # Randomly generate two lists to test this import random list1 = random...
true
698212d5376c53e07b4c5410dfd77aac16e97bd2
izdomi/python
/exercise5.py
703
4.21875
4
# Take two lists, # and write a program that returns a list that contains only the elements that are common between the lists. # Make sure your program works on two lists of different sizes. # Extras: # Randomly generate two lists to test this # Write this in one line of Python lst1 = [] lst2 = [] num1 = int(input("l...
true
3a53ab12f8144942fbfcb56bbb56d407c32bdf3e
autumnalfog/computing-class
/Week 2/a21_input_int.py
345
4.21875
4
def input_int(a, b): x = 0 while x != "": x = input() if x.isdigit(): if int(x) >= a and int(x) <= b: return x print("You should input a number between " + str(a) + " and " + str(b) + "!") print("Try once more or input empty line to cancel input check....
true