blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
959d371a52cb965cecd013cc6915c60dc7578adf
seema1711/My100DaysOfCode
/Day 3/linkedListAtTheEnd.py
1,172
4.3125
4
''' This involves pointing the next pointer of the current last node of the linked list to the new data node. So, the current last node of the linked list becomes the second last data node & the new node becomes the last node of the LL. ''' ### LINKED LIST INSERTION AT THE END ### class Node: def __init__(self,da...
true
ea7b254cac5d2fce96496f8a6fa49d573ef83078
seema1711/My100DaysOfCode
/Day 5/AddEleQueue.py
984
4.21875
4
<<<<<<< HEAD ### ADDING ELEMENTS TO A QUEUE ### class Queue: def __init__(self): self.queue = list() def add(self,dataval): # Insert method to add element if dataval not in self.queue: self.queue.insert(0,dataval) return True return False def size(self): ...
true
44b0f6ad8977686865b8eb3fc78b6215533715d1
KlimentiyFrolov/-pythontutor
/Занятие 8. Функции и рекурсия/задача 2.PY
243
4.1875
4
#http://pythontutor.ru/lessons/functions/problems/negative_power/ def power(a, n): b = 1 for i in range(abs(n)): b *= a if n >= 0: return b else: return 1 / b print(power(float(input()), int(input())))
true
1197b645af240babf6cefa4be8af88f32149ed3e
jthiruveedula/PythonProgramming
/Regex/patternStar.py
512
4.21875
4
#asterisk is used to find patterns based on left or right position from asterisk pattern='swi*g' import re string = '''I am black! I am swinging in the sky, I am wringing worlds awry;''' match =re.match(pattern,string) search =re.search(pattern,string) findall =re.findall(pattern,string) print("Match Method: " ,matc...
true
d2382eb19ffc091fedcc333b0d3c96a010804127
jthiruveedula/PythonProgramming
/DataEngineering/sets.py
1,133
4.25
4
#Branch of Mathematics applied to collection of objects #i.e., sets #Python has built in set datatype with accompanying methods # instersection (all elements that are in both sides) #difference(elements in one set but not in other set) #symmetric_difference(all elements in exactly one set) #union ( all elements that a...
true
df5f166e5011a902893c503e8c9237a309f0e293
HeroRacerNiko/lesson_5_hw
/count_odds_and_evens.py
2,141
4.28125
4
# Function check only WHOLE number # Function doesn't check for digits duplication in the parameter number input # For example 44411 would return 3 even digits and 2 odds # Function does NOT skip count with duplicate digit and will count and add to list of evens or odds def count_odds_and_evens(num): while not num...
true
6c1456aa803cfe446a9b9df5c17d2d4c2e430fe7
OMerkel/Fractals
/Hilbert/Howto/hilbert-howto-3.py
1,632
4.375
4
#!/usr/bin/env python3 """ How to draw a Hilbert Curve - Step 3 In step 2 the turtle drew a hilbert curve in iteration n=0 """ import turtle COLOR = [ 'blue' ] def hilbert( turtle, length, depth ): """ hilbert shall recursively call itself The function holds a parameter depth that is decre...
true
16b21fa84cb8b02f3aa8afd9ce4eafa3156520bf
OtsoValo/UTSC-Works
/CSCA08/ex0.py
1,895
4.21875
4
def multiply(x,y): return x+y def auto_email_address(x,y): return x + "." +y + "@mail.utoronto,ca" x = float(input("please input a number:")) y = float(input("please input another number:")) print(multiply(x,y)) a = input("please enter your first name:") b = input("please enter your last name:") address =...
true
5bf93ada1ebcc70d6243e0a5bf352e6526722ff0
OtsoValo/UTSC-Works
/CSCA08/week9/week9_my_stack2.py
1,690
4.125
4
class Stack(): '''A last-in, first-out (LIFO) stack of items''' def __init__(self): '''(Stack) -> NoneType Create a new, empty Stack. ''' # this time, let's represent our stack with a list such that the top # of the stack is at the 0th element of the list self._c...
true
9ba37e0ec412a97a1341545f89772823bbaa8ded
kalsotra2001/practice
/hackerrank/algorithms/warmups/sherlock-and-the-beast.py
589
4.1875
4
def get_decent(digits): target = digits threes = 0 fives = 0 max = 0 while digits > 0: if digits % 3 == 0: fives = digits break digits -= 5 threes = target - digits if digits < 0 or threes % 5 != 0: return "-1" number = "" while fives >...
true
5b1cb7b7e1e1c695b4a0a703bf647c3ee2da5abf
Sinha123456/Simple_code_python
/factorial_while.py
312
4.46875
4
number = 6 product = 1 current = 1 while current<=number: product*=current current += 1 print(product) #Running same thing using for loop # calculate factorial of number with a for loop for num in range(1, number + 1): product *= num # print the factorial of number print(product)
true
dc7311f672b80ddf847eac14a1ad81bee065cd66
bala4rtraining/python_programming
/python-programming-workshop/test/namedtuple/namedtuplecreationexpone.py
1,449
4.125
4
# the code below shows a simple tuple - 1st part of excercise from math import sqrt pt1 = (1.0, 5.0) pt2 = (2.5, 1.5) line_length = sqrt((pt1[0]-pt2[0])**2 + (pt1[1]-pt2[1])**2) print(line_length) # the code below shows a simple named tuple - 2nd part of our excercise from collections import namedtuple Point = na...
true
1b852fc0dd98132bc8590ca978654de519bca513
bala4rtraining/python_programming
/python-programming-workshop/youtube_python_videos/dictionary/dictionaryfromkeysthree.py
807
4.375
4
# create a dictionary from mutable object list # vowels keys keys = {'a', 'e', 'i', 'o', 'u' } value = [1] vowels = dict.fromkeys(keys, value) print(vowels) # updating the value value.append(2) print(vowels) #If the provided value is a mutable object (whose value can be modified) like list, dictionary, etc., whe...
true
315a09868d5ccdd2c29900f3e5df8148b09f3524
bala4rtraining/python_programming
/python-programming-workshop/string/ljust_and_rjust.py
424
4.5
4
#Ljust, rjust. These pad strings. They accept one or two arguments. The first argument #is the total length of the result string. The second is the padding character. #Tip: If you specify a number that is too small, ljust and rjust do nothing. #They return the original string. #Python that uses ljust, rjust s = "...
true
40f9fbb5bfd6cdcd6c5ab29d2b109f76b3548167
bala4rtraining/python_programming
/python-programming-workshop/interesting_programs/decimal_to_binary_in_bits.py
206
4.25
4
# Python 3 implementation of above approach # Function to convert decimal to # binary number def bin(n): if (n > 1): bin(n >> 1) print(n&1,end=" ") # Driver code bin(131) print() bin(3)
true
6b99a93f0c58c2ab9ac3ded9483a65ad45e69fa6
bala4rtraining/python_programming
/python-programming-workshop/pythondatastructures/class/issubclass.py
758
4.34375
4
#Issubclass. This determines if one class is derived from another. With this #built-in method, we pass two class names (not instances). #Return:If the first class inherits from the second, issubclass returns true. #Otherwise it returns false. #Tip:This is rarely useful to know: a class is considered a subclass o...
true
f06d4ab6301792efe152f6e31b879e8af446677f
bala4rtraining/python_programming
/python-programming-workshop/data_structures/named_tuple/namedtupletwo.py
563
4.53125
5
#namedtuple is a factory function for making a tuple class. With that class #we can create tuples that are callable by name also. import collections #Create a namedtuple class with names "a" "b" "c" Row = collections.namedtuple("Row", ["a", "b", "c"], verbose=False, rename=False) row = Row(a=1,b=2,c=3) #Make a ...
true
59e8e3a092bb160de2b3216f99f3cb7e6cde6709
bala4rtraining/python_programming
/python-programming-workshop/pythondatastructures/regular_expression/search.py
747
4.40625
4
#Search. This method is different from match. Both apply a pattern. But search attempts this #at all possible starting points in the string. Match just tries the first starting point. #So:Search scans through the input string and tries to match at any location. In this #example, search succeeds but match fails. ...
true
1f528a9f016ab29739e09549db415d98b11af0be
bala4rtraining/python_programming
/python-programming-workshop/test/dictionary/listto_dict.py
230
4.15625
4
original = {"box": 1, "cat": 2, "apple": 5} # Create copy of dictionary. modified = original.copy() # Change copy only. modified["cat"] = 200 modified["apple"] = 9 # Original is still the same. print(original) print(modified)
true
13c4357d79ee16af405cb6a745a64e7e6b19318b
bala4rtraining/python_programming
/python-programming-workshop/test/pythondatastructures/built_in_functions/lambda/functionsinsidelist.py
529
4.34375
4
#In the example above, a list of three functions was built up by embedding #lambda expressions inside a list. A def won't work inside a list literal #like this because it is a statement, not an expression. #If we really want to use def for the same result, we need temporary function #names and definitions outside...
true
6e3d3063dee1ed723883124085c093ccee478401
bala4rtraining/python_programming
/python-programming-workshop/test/pythondatastructures/none/none_usage_in_dictionary.py
209
4.1875
4
#Python program that uses dictionary, None items = {"cat" : 1, "dog" : 2, "piranha" : 3} # Get an element that does not exist. v = items.get("giraffe") # Test for it. if v == None: print("Not found")
true
83eee1932f9a1c411deaeed876fd83d788dc31ba
bala4rtraining/python_programming
/python-programming-workshop/test/pythondatastructures/file/parse_csv.py
222
4.125
4
import csv #Open CSV file. with open("input.csv", newline="") as f: # Specify delimiter for reader. r = csv.reader(f, delimiter=",") # Loop over rows and display them. for row in r: print(row)
true
6056539afef034b1d222ac3436e7c2ff6c68e55d
bala4rtraining/python_programming
/python-programming-workshop/test/pythondatastructures/fibonacci/fibonacci_two.py
294
4.40625
4
#Python program that displays Fibonacci sequence def fibonacci2(n): a = 0 b = 1 for i in range(0, n): # Display the current Fibonacci number. print(a) temp = a a = b b = temp + b return a # Directly display the numbers. fibonacci2(15)
true
978adb0fd9c937fc09cd5f5d0594476f9fbab251
bala4rtraining/python_programming
/python-programming-workshop/test/HomeWorkProblems/16.greaterandlesser-than-given-number.py
435
4.3125
4
# Count the number of elements in a list that are greater # than or equal to some minimum number and less that or equal # to some maximum number for example, the list of numbers can # be 12, 5, 23, 79, 63, 11, 7, 6, 115, 129 # minimum is 10 and maximum is 100] newlist = [12, 5, 23, 79, 63, 11, 7, 6, 115, 129] mini...
true
16f0449bfb7dec9a11cb561cfa8cbaf1cabd8b60
bala4rtraining/python_programming
/python-programming-workshop/HomeWorkProblems/8.anagrams-ofeachother.py
464
4.34375
4
## python program to find whether the given words are anagrams of each other ## # find if two strings are anagrams of each other and # report the answer as "yes" or "no" first_string = input(" Give first string : ") second_string = input(" Give second string : ") first_string = sorted(first_string) second_string =...
true
89589bd79a5ee51df2033ce8dc9e7e069688cf0f
bala4rtraining/python_programming
/python-programming-workshop/solutions/new.py
458
4.1875
4
# this is the basic method number = int(input("Give a number")) for val in range(2,number): if number % val == 0: print(val,end=" ") print("\n\n") # this is using list comprehension factors = [val for val in range(2,number) if number % val == 0] print(factors) # this is using a function def find_facto...
true
5ee5ebe06d9c49bff31c0e598f1f44acef452cd1
bala4rtraining/python_programming
/python-programming-workshop/HomeWorkProblems/17.tupletakeinput.py
589
4.625
5
## python program to create a tuple by getting input from the user ## # write a program create a tuple by taking input from the user mylist = [] for count in range(5): name=input(" Give any name : ") mylist.append(name) tupletwo = (mylist[0],mylist[1],mylist[2],mylist[3],mylist[4]) print(" The elements in tu...
true
b589cf5c1d286d01d3986160bb4c8d890791ff6c
bala4rtraining/python_programming
/python-programming-workshop/iterators_and_generators_new/12.newiteratorpattercreation.py
317
4.40625
4
def frange(start, stop, increment): x = start while x < stop: yield x x += increment #To use such a function, you iterate over it using a for loop or use it with some other #function that consumes an iterable (e.g., sum(), list(), etc.). For example: for n in frange(0, 9, 0.5): print(n)
true
dccc689f10f200088286a7f8b33fe67e06afdf66
bala4rtraining/python_programming
/database/secondone.py
1,225
4.3125
4
## Connecting to the database ## importing 'mysql.connector' as mysql for convenient import mysql.connector as mysql ## connecting to the database using 'connect()' method ## it takes 3 required parameters 'host', 'user', 'passwd' db = mysql.connect( host = "localhost", user = "root", passwd = "Superpa@99...
true
2c40f802dbf405ea79d5e792626f74011df1969e
bala4rtraining/python_programming
/python-programming-workshop/builit-in-functions/find/find_one.py
251
4.25
4
#Python program that uses string find value = "cat picture is cat picture" # Find first index of this string. i = value.find("picture") print(i) # Find first index (of this string) after previous index. b = value.find("picture", i + 1) print(b)
true
f261c999b95e455d7c5832ebeb11139aeb5a792c
ishandas387/DbsStuff
/PrgAnalytics/Problem2.py
777
4.15625
4
''' Validates the user input and returns the splitted result. If after split the list doesm't have 2 values, the input doesn't satisfy the domain/username format. ''' def validate_and_return(message): while True: user_name = input(message) #splits with '\' data = str(user_name).split("\\") ...
true
52653ebdcb26a69d87b19f6f2259ca447f1e51fd
oraloni/python-little-games
/which_hand.py
1,371
4.28125
4
'''Which Hand - in Pythom Basic Games Project Or Aloni 13/06/2020 v/1/0''' print(" Which hand?\n") print('''RULES: Pick up a dime in one hand and a penny in the other. I'll guess which hand holds which coin if you answer a couple of questions for me. ...
true
a85bbe7cf2198eb26c99a1f3f60e73c463d26305
thirdcaptain/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-number_of_lines.py
355
4.21875
4
#!/usr/bin/python3 """ module defines number_of_lines function """ def number_of_lines(filename=""): """ returns the number of lines of a text file args: filename (file): file to read """ linenumber = 0 with open(filename, 'r', encoding='utf-8') as f: for line in f: lin...
true
fd5f77e150f73ee65cc191d4f8fdd666470c5394
Hyperx837/Bits2020
/chat bot/chatbot.py
1,342
4.15625
4
ques_ans = { 'What is your name? ': 'Alpha', 'How old are you? ': '7 years', 'What is your School? ': 'I never went to school', 'What is your father\'s name? ': 'I do not have a father but I ' 'was created by Anupama', 'What is your mother\'s name? ': 'I don\'t ...
true
475b3a1300525aac00cca14b41742c99d3612ea7
Ena-Sharma/list-in-python
/newlist.py
216
4.15625
4
list=[1,2,3,4,5,6] print("Initial list:") print(list) slicing=list[3:6] print(slicing) slicing_list=list[:-5] print(slicing_list) list.pop() print(list) for i in range(len(list)): print(i, end=" ") print("\r")
true
62248d30fa1bd73b9d4436e03f0e42cf7e14305f
tilsies/CP1404
/cp1404practicals/prac_02/acsii_table.py
490
4.15625
4
LOWER_LIMIT = 33 UPPER_LIMIT = 127 character = input("Enter a Character: ") print("The ACSII code for {0} is {1}".format(character, ord(character))) number = int(input("Enter a number between {0} and {1}: ".format(LOWER_LIMIT, UPPER_LIMIT))) while number < LOWER_LIMIT or number > UPPER_LIMIT: print("Invalid cho...
true
2c08dac1a7cad63382d69082c608d3fe02a75b6d
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#112 Grasshopper - Debug.py
967
4.46875
4
# Debug celsius converter # Your friend is traveling abroad to the United States so he wrote a program to # convert fahrenheit to celsius. Unfortunately his code has some bugs. # # Find the errors in the code to get the celsius converter working properly. # # To convert fahrenheit to celsius: # # celsius = (fahrenheit ...
true
d4abedb8cc12fb365e1309d49b0d8ef7e8005379
ChengHsinHan/myOwnPrograms
/CodeWars/Python/7 kyu/#04 Sum of odd numbers.py
366
4.15625
4
# Given the triangle of consecutive odd numbers: # # 1 # 3 5 # 7 9 11 # 13 15 17 19 # 21 23 25 27 29 # ... # Calculate the sum of the numbers in the nth row of this triangle (starting at # index 1) e.g.: (Input --> Output) # # 1 --> 1 # 2 --> 3 + 5 = 8 ...
true
97caf558aa471cc7bcfcab2921028f6ffa998e44
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#227 Area of a Square.py
338
4.125
4
# Complete the function that calculates the area of the red square, when the # length of the circular arc A is given as the input. Return the result rounded # to two decimals. # # Note: use the π value provided in your language (Math::PI, M_PI, math.pi, etc) import math def square_area(A): return round((2 * A / m...
true
d087d676cc95399719f79ce1968b9471297b7b9d
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#152 How old will I be in 2099.py
1,442
4.25
4
# Philip's just turned four and he wants to know how old he will be in various # years in the future such as 2090 or 3044. His parents can't keep up # calculating this so they've begged you to help them out by writing a programme # that can answer Philip's endless questions. # # Your task is to write a function that ta...
true
a467834a82132a92cd105ef74bd73ad708a73e4c
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#122 L1 Bartender, drinks!.py
1,206
4.125
4
# Complete the function that receives as input a string, and produces outputs # according to the following table: # # Input Output # "Jabroni" "Patron Tequila" # "School Counselor" "Anything with Alcohol" # "Programmer" "Hipster Craft Beer" # "Bike Gang Member" "Moonshine" # "Politician" "...
true
c7be302d35c6a6ff9f9e2363219c69bc45d4b245
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#054 Add Length.py
573
4.28125
4
# What if we need the length of the words separated by a space to be added at # the end of that same word and have it returned as an array? # # Example(Input --> Output) # # "apple ban" --> ["apple 5", "ban 3"] # "you will win" -->["you 3", "will 4", "win 3"] # Your task is to write a function that takes a String and r...
true
6acbf3dc4f5c25598f811880121a6d2cbcb72b9c
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#157 Are You Playing Banjo.py
470
4.21875
4
# Create a function which answers the question "Are you playing banjo?". # If your name starts with the letter "R" or lower case "r", you are playing # banjo! # # The function takes a name as its only argument, and returns one of the # following strings: # # name + " plays banjo" # name + " does not play banjo" # Names...
true
2575f9bcb23571369a0fa7cf5832fc1399a26008
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#235 Will you make it.py
546
4.125
4
# You were camping with your friends far away from home, but when it's time to # go back, you realize that your fuel is running out and the nearest pump is 50 # miles away! You know that on average, your car runs on about 25 miles per # gallon. There are 2 gallons left. # # Considering these factors, write a function t...
true
9e38100a28ecac4ecb6a6d67e5a600371bb8658a
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#048 Simple Fun #261 Whose Move.py
1,022
4.15625
4
# Task # Two players - "black" and "white" are playing a game. The game consists of # several rounds. If a player wins in a round, he is to move again during the # next round. If a player loses a round, it's the other player who moves on the # next round. Given whose turn it was on the previous round and whether he won...
true
6685082c37a723957d9439431f42bd51a1ef0f4a
cinker/karanProjects
/Classes/Product_Inventory.py
1,242
4.15625
4
#!/usr/bin/python3 # Product Inventory Project - Create an application which manages an inventory # of products. Create a product class which has a price, id, and quantity on # hand. # Then create an inventory class which keeps track of various products and can # sum up the inventory value. class Product: def __...
true
d2cd63e30ab801cfcb2186987d069525340f6f6b
abhishekrd760/BasicPythonPrograms
/quadratic.py
460
4.21875
4
import cmath a = float(input("Enter the value of a in quadratic equation")) b =float(input("Enter the value of b in quadratic equation")) c = float(input("Enter the value of c in quadratic equation")) x1 = (-b + cmath.sqrt((b**2)-(4*a*c)))/(2*a) x2 = (-b - cmath.sqrt((b**2)-(4*a*c)))/(2*a) d = (b**2)-(4*a*c) print("Th...
true
659d1521ecdd0cfd143b222364c0e8889a952263
Mohit1299/Python
/A3Q3.py
481
4.15625
4
input_time = input("Enter the time : ") time = input_time.split(":") minute_angle = int(time[1])*6 print(minute_angle) hour_angle = int(time[0])*30 + (minute_angle/12) print(hour_angle) if(hour_angle > minute_angle): res_angle = hour_angle - minute_angle else: res_angle = minute_angle - hour_angle if(res_angle...
true
d8838575fd3f49c16694f11bf788ad4c7ec1cf39
Mohit1299/Python
/A5Q9.py
472
4.1875
4
def is_prime(no): if(no < 2): print("Prime numbers are always greater than 2") return False count = 0 for i in range(1,no): if(no%i==0): count += 1 else: continue if(count == 1): return True else: return False user_inp...
true
33e073a5a1bf85fc0e4b20d7bfd9bae96adfefeb
calendij9862/CTI110
/P1HW2_BasicMath_CalendineJoseph.py
658
4.25
4
# This program adds and multiplies 2 numbers # 9/13/2020 # CTI-110 P1HW2 - Basic Math # Joseph Calendine # print('Please enter your first number:') Integer1 = int(input()) print( 'Please enter your second number:') Integer2 = int(input()) print( 'First number entered: ' , Integer1 ) print( 'Second number entered: ' , ...
true
e8e7be052d4014a42d2ad8b74ee3eeabc6f89f16
absingh-hub/Python_practise
/iterators2.py
280
4.21875
4
nums = [1, 2, 3] #for num in nums: # print(num) #this for loop is equivalent to following working in background i_num = iter(nums) while True: try: num = next(i_num) print(num) except StopIteration: break #Iterators can only go forward through __next__ method
true
ce00f60549ffd503e99682e1649a94a160a7eb19
arbonap/interview-practice
/LL.py
1,303
4.125
4
class Node(object): def __init__(self): self.value = value self.next = None class Linkedlist(object): def __init__(self): self.head = None def append_node(self, value): new_node = Node(value) if self.head is None: self.head = new_node else: ...
true
82e6e225af956d7b7d6fa0aad4d208a4f4ddb157
arbonap/interview-practice
/remove-odds.py
216
4.28125
4
def remove_odd_nums(array): """ Remove odd numbers from a given array""" for num in array: if num % 2 != 0: array.remove(num) return array print remove_odd_nums([1, 2, 3, 4, 5, 6, 7])
true
39b2468242a054fdd8442ac7d348861dc391704b
arbonap/interview-practice
/pig-latin.py
459
4.1875
4
def pig_latin(text): """Create Pig Latin generator. If a word begins with a vowel, add '-ay' to the end of the word. If a word begins with a consonant, slice the first letter to the end and add '-ay' to the end of the string.""" pyg = '-ay' text = text.lower() if len(text) > 0 and text.isalpha(): if text[0]...
true
30e251b989128d2745451b5f34999f65ee3f1d8b
gkulk007/Hacktoberfest2021
/Programs/Aman_Ahmed_Siddiqui/Evil Number.py
1,539
4.28125
4
''' An Evil number is a positive whole number which has even number of 1's in its binary equivalent. Example: Binary equivalent of 9 is 1001, which contains even number of 1's. A few evil numbers are 3, 5, 6, 9…. Design a program to accept a positive whole number and find the binary equivalent of the number and count t...
true
12a6ad4283868e04e2913c3639fd8e7cbfdea215
gkulk007/Hacktoberfest2021
/Programs/Aman_Ahmed_Siddiqui/Smith Number.py
1,513
4.34375
4
''' A Smith number is a composite number, whose sum of the digits is equal to the sum of its prime factors. For example: 4, 22, 27, 58, 85, 94, 121 ………. are Smith numbers. Write a program in Python to enter a number and check whether it is a Smith number or not. Sample Input: 666 Sum of the digits: 6 + 6 + 6 = 18 Pri...
true
450fff7c3c0e11a77a0601387ad6c73c48a67cb3
vijaynchakole/Python-Code
/MyParallelProgramming.py
886
4.125
4
#below program which uses serial processing approach def square(n): return(n*n) if __name__ == "__main__": #input list arr = [1,2,3,4,5] #empty list to store result result = [] for num in arr : result.append(square(num)) print(result) ####################...
true
ed1200ad70c5924d2b556a263be368679482b7f8
MerhuBerahu/Python3-DnD5e-CharacterCreator-
/Races.py
1,909
4.1875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- """Display race information and select a race """ #TODO stuff import json from Systems import check_input with open("Jsons\\races.json", encoding="utf8") as test: #Open races.json as test race_list = json.load(test) def race_info(): """Pull in race information...
true
e4d83836f27a7cd3d1719661f6a8a963dc3b735f
byui-cs/cs241-course
/week01/ta01-solution.py
1,168
4.28125
4
# Team Activity 01 # Author: Br. Burton # Part 1: Ask the user for their DNA sequence, count the number of A's dna = input("Please enter your DNA sequence: ") # This will keep track of our matches match_count = 0 # Go through the string letter by letter, and count the matches for letter in dna: if letter == 'A'...
true
1bbff88e227879dd98c15b0ffe6a78554378caa1
myfriendprawin/Praveen-Kumar-Vattikunta
/Weekend Day2.py
671
4.34375
4
#!/usr/bin/env python # coding: utf-8 # In[6]: #Data Types: #Numbers: Number data types are immutables. #Integers: A=1 B=3 A+B # In[7]: #Float: Declaring values in decimal is called as float. X=1. Y=2.0 X+Y # In[8]: #Advance assignment of values to variables. K,L,M,N=5,6,9,1 print(M) # In[19]: #List Dat...
true
023a9c620470e17c50842ee0b078960cb3b2d88d
ivyldewitt/python-review
/practice/interactive.py
698
4.53125
5
### PRACTICE ### user_prompt = input("Please enter a whole number (no decimals): ") user_int = int(user_prompt) ## Write a program that requests a number from the user. # Have the program print "Even" or "Odd" depending on whether # they entered an even or odd number. while user_int != 0: if user_int % 2 == ...
true
ae7b0936d7d7a56203adc0d7fc63db4466ab2229
tristan-neateworks/AIArena
/AIArena/AI.py
1,963
4.125
4
class Player: """This forms an interface for a generic game "player." It is extended by the AI class and can be used to represent any kind of entity that makes moves in a given game. :param name: The human-readable reported name for the player (ex. LilBuddy for our Connect 4 playing AI) :param game: Th...
true
0d8908216a9d7ce6f1419118b6f88db5f8fd1672
natasharivers/python-exercises
/python_warmup.py
1,984
4.75
5
##WARM UP EXERCISES #write the code that takes a single string string containing the make and model of a vehicle. #first part of te string before the space is the make #the last part of the string after the space is a model #we can assume that the strings will only have one space #assume the input string is completely ...
true
2920e6e3ec24466f9e284bc5ec0bd200359c037a
jashidsany/Learning-Python
/LCodecademy Lesson 11 Function Arguments/L11.3_Default_Arguments.py
1,015
4.15625
4
# Function arguments are required in Python. So a standard function definition that defines two parameters requires two arguments passed into the function. # Not all function arguments in Python need to be required. If we give a default argument to a Python function that argument won’t be required when we call the fun...
true
956cd4948879564ec6b2d19ade61a1bf5ef76885
jashidsany/Learning-Python
/Codecademy Lesson 8 Dictionaries/LA8.11_Try_And_Except_To_Get_A_Key.py
585
4.34375
4
# We saw that we can avoid KeyErrors by checking if a key is in a dictionary first. Another method we could use is a try/except: # key_to_check = "Landmark 81" # try: # print(building_heights[key_to_check]) # except KeyError: # print("That key doesn't exist!") # When we try to access a key that doesn’t exist, t...
true
6bb3631eed8bdebd296f4054d1c84d272f44ff1f
jashidsany/Learning-Python
/Codecademy Lesson 9 Files/L9.0_Reading_A_File.py
1,191
4.5625
5
# Computers use file systems to store and retrieve data. # Each file is an individual container of related information. # If you’ve ever saved a document, downloaded a song, or even sent an email you’ve created a file on some computer somewhere. # Even script.py, the Python program you’re editing in the learning env...
true
ba45301804c28d062503ca306c6ea393b7da0394
jashidsany/Learning-Python
/Codecademy Lesson 6 Strings/LA6.16_Joining_Strings_1.py
511
4.375
4
# Now that you’ve learned to break strings apart using .split(), let’s learn to put them back together using .join(). .join() is essentially the opposite of .split(), it joins a list of strings together with a given delimiter. The syntax of .join() is: # 'delimiter'.join(list_you_want_to_join) # Delimiters are spaces...
true
022fc7d62f80194c39334f22d8e48e8826f01a07
jashidsany/Learning-Python
/Codecademy Lesson 6 Strings/LA6.28_X_Length.py
560
4.1875
4
# Write your x_length_words function here: def x_length_words(sentence, x): words = sentence.split(" ") # creates a variable words that stores the words split in the string sentence for word in words: # iterates through the words if len(word) < x: # if the length of the word is less than the ...
true
b93ee019f4b0714aec476258771ad849ddb70c95
SSamiKocaaga/python-project
/Assignment 007_003.py
693
4.1875
4
# Variables armvalue = 0 condition = False # Receives input from the user until he/she enters data in the expected format while not condition: number = input('Write a number: ') if number.isdigit(): condition = True else: print(" It is an invalid entry. Don't use non-numeric, float, or negat...
true
e6385076df5131c0df3330896536fb40edbfa250
fuston05/Computer-Architecture
/OLD_ls8/util.py
1,512
4.46875
4
# In general, the `.format` method is considered more modern than the printf `%` # operator. # num = 123 # ​ # # Printing a value as decimal # ​ # print(num) # 123 # print("%d" % num) # 123 # print("{:d}".format(num)) # 123 # ​ # # Printing a value as hex # ​ # print(hex(num)) ...
true
8263cd6c0f37eb66061219be0d314bb12cb2564d
vvdnanilkumargoud/Python
/search.py
548
4.21875
4
#a is list a = [1,2,3,4,5] #It will search entire list whthere value is there or not check = raw_input("Enter which you want to search in a list : ") if check not in a: a.append(check) print "%s is not in the list we are adding into list" %check print "This is the latest list : %s" %a else: print a #b ...
true
54e81046a418fc4c8fbfa60d0ce83bdb15e4f8d3
nvyasir/Python-Assignments
/exception_regform.py
604
4.3125
4
# Registration System # # # You are making a registration form for a website. # The form has a name field, which should be more than 3 characters long. # Any name that has less than 4 characters is invalid. # Complete the code to take the name as input, and raise an exception if the name is invalid, outputting "Invalid...
true
1a1e048c7e1e5c2a367b0c5e75f5f2bef4e38506
nvyasir/Python-Assignments
/tuples.py
714
4.28125
4
# Tuples # # You are given a list of contacts, where each contact is represented by a tuple, with the name and age of the contact. # Complete the program to get a string as input, search for the name in the list of contacts and output the age of the contact in the format presented below: # # Sample Input # John # # Sam...
true
b9f60c435d858ede41449fff6c05f4a0de3e5343
volllyy/python_basic_HW
/HW/HW_3/Task_5.py
1,734
4.1875
4
# HW3 - Task № 5 def sum_func() -> int: """ The program asks the user for a string of numbers separated by a space. When you press Enter, the sum of the numbers should be displayed. The user can continue to enter numbers separated by a space and press Enter again. The sum of the newly entered number...
true
b1314d7f4195ed997d446cb084b59a45f24f8623
volllyy/python_basic_HW
/HW/HW_1/Task_1.py
695
4.1875
4
#HW1 - Task № 1 year = 2020 temperature = 10.5 month = 'April' print(year,'/', temperature,'Cº /', month) name = input('What`s your name?\n') surname = input('What`s your surname?\n') age = input('How old are you?\n') number = input('What is your phone number? (Wright down without + and spaces, ' 'just c...
true
34328ab0d637668b489d976640218293d219691a
developeruche/python_threading_module
/demo_one/app.py
756
4.1875
4
import threading """ Thread is a mean by which a program of app can excectue various function simutanously """ def thread_one_function(test_arg_one, test_arg_two): for i in range(0, 20): print(f'I am Tread one ----- {test_arg_one}, {test_arg_two}') def thread_two_function(test_agr): for i in range(0...
true
3f84c7f6030299449c5513201fedc08b0fb07332
darshanjain033/darshjain
/largest number.py
382
4.40625
4
# Python program to find the largest number among the three input numbers... num_1 = float(input("Enter Number_1 :")) num_2 = float(input("Enter Number_2 :")) num_3 = float(input("Enter Number_3 :")) if (num_1 >= num_2 and num_1 >= num_3): print("Number_1 is large") elif (num_2 >= num_1 and num_2 >= num_3): pri...
true
5c75c95c28a0e6f541d8dce1f38f5e61bf77e91f
RitRa/multi-paradigm-programming-exercises
/Week3_exercises/q8_primenumber.py
424
4.1875
4
# Write a program that prints all prime numbers. (Note: if your programming language does not support arbitrary size numbers, printing all primes up to the largest number you can easily represent is fine too.) number = input("Pick a number") #convert to a number number = int(number) for i in range(number): if (nu...
true
19a4d0579ea77bd0c219ce75c467d6e650b6efae
RitRa/multi-paradigm-programming-exercises
/Week3_exercises/q3_whatisyournamemodified.py
307
4.40625
4
# Write a program that asks the user for their name and greets them with their name. # Modify the previous program such that only the users Alice and Bob are greeted with their names. name = input("what is your name?") vip = ["Alice", "Bob"] for i in vip: if i == name: print("Hello " + name)
true
1677429d9d212b6971af7f1b7408a5aeb08b945a
xzx1kf/football_manager_project
/football_manager/elo/elo.py
1,908
4.3125
4
class Result(object): """ A Result can either be a win, lose or draw. A numerical value is assigned to the result. """ WIN, LOSE, DRAW = 1, 0, 0.5 class EloFootballRating(object): """ A rating system based on the Elo rating system but modified to take various football specific variable...
true
cd8dbf34d866708f6f1953a387bc3519ac4bc05b
jmuguerza/adventofcode
/2017/day17.py
1,976
4.15625
4
#/usr/bin/env python3 # -*- coding: utf-8 -*- """ PART 1 There's a spinlock with the following algorithm: * starts with a circular buffer filled with zeros. * steps forward some number, and inserts a 1 after the number it stopped on. The inserted value becomes the current position. * Idem, but inserts a 2. Rin...
true
fa2f83e4a96be139adcfa59660ebc96dd120a6fe
nihalgaurav/pythonprep
/MixedSeries.py
1,203
4.4375
4
"""Consider the below series: 1, 2, 1, 3, 2, 5, 3, 7, 5, 11, 8, 13, 13, 17, ... This series is a mixture of 2 series - all the odd terms in this series form a Fibonacci series and all the even terms are the prime numbers in ascending order. Write a program to find the Nth term in this series. The value N is a Positive ...
true
c80b92dfa26817fc051fd4609230815fe1cfc8be
Dylandk10/fun_challenges
/python/palindrome_number.py
632
4.25
4
""" Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not. examples Input: x = 121 Output: true Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left,...
true
8b0e54cf78a1a82c8ae92655723fc3b313e18185
DauntlessDev/py-compilation
/Prime or not.py
412
4.21875
4
# Python program to check if the input number is prime or not number = 123 if number > 1: # check for factors for i in range(2,number): if (number % i) == 0: print(number,"is not a prime number") print(i,"times",number//i,"is",number) break else: pri...
true
6b982842a841b71f48d49b9af48e75f4066ca224
juriemaeac/Data-Structure-and-Algorithm
/Lab Exercise 1/DecimalToBinary.py
414
4.3125
4
num = int(input("Enter a decimal number: ")) #Empty string to hold the binary form of the number b = "" while num != 0: if (num % 2) == 1: b += "1" else: b += "0" #this is equivalent to num = num // 2 ----- num/=2 results to decimal #use double slash to result in integer num//=2 ...
true
959d40e7949962c427e5edb64a366133c119faf8
juriemaeac/Data-Structure-and-Algorithm
/Lab Exercise 1/Palindrome.py
556
4.40625
4
''' by Jurie Mae Castronuevo from BSCOE 2-6 [November 22, 2020] ''' import re z = input("Enter a word: ") x = z.lower() #x[::-1] is used to reverse all the elements #source lesson: https://jakevdp.github.io/PythonDataScienceHandbook/02.02-the-basics-of-numpy-arrays.html #library that accepts word with some symbols and...
true
241c25f337622ce86f3c8a246a7384869e025ad6
kg55555/pypractice
/Part 1/Chapter 3/exercise_3.5.py
487
4.125
4
famous = ['steve jobs','bill gates', 'gandhi'] print(f"Hello {famous[0].title()}, I'd like to invite you to dinner with me!") print(f"Hello {famous[1].title()}, I'd like to invite you to dinner with me!") print(f"Hello {famous[2].title()}, I'd like to invite you to dinner with me!") print(f"Oh no! {famous.pop().title()...
true
e80b8a5f48ebca0f07d57f823bb6374c9d6baae3
valemescudero/Python-Practice
/Class 1/04. Primality Test.py
658
4.21875
4
# Write a function that recieves a number and returns True when it's a prime number and False when it's not. # Through a for loop check for the primality of numbers 1 to 20. def is_prime(num): if num == 1: primality = False else: primality = True if num > 2: rang = (num ** 0.5) rang = int(r...
true
1291f99844e533f595854aeeeef5c29e71fd8c8c
mazhewitt/python-training
/Day 3/week2_Lists_2.py
736
4.53125
5
### Excercise 2 ### # 2. Let's plan some shopping. We want to get some fruits, vegies and diary products: fruits = ['Banana', 'Apple', 'Lemon', 'Orange'] vegies = ['Carrot', 'Pumpkin'] diary = ['Milk', 'Cheese', 'Butter'] # 2.1 Check how many product from each category we want to buy # 2.2 Create one shopping...
true
a279637aee7839aa7c13a020144d76a47b92631d
anhnguyendepocen/Mphil
/POPE/func.py
1,690
4.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ func.py Purpose: Playing with functions Version: 1 First start Date: 2019/08/27 Author: Aishameriane Venes Schmidt """ ########################################################### ### Imports import numpy as np # import pandas as pd # import ma...
true
146b1e0937b0b3decc261b8170024c8a9c44525a
JLL32/MBCP
/Python - fundamentals/UNIT 8: Dictionaries and Files/inverse.py
1,012
4.4375
4
##### Create a dictionary where values are lists ##### people = {"names":["noura","amine"],"ages":[22,28],"profession":["Software Engineer", "Red Hat"]} print(people) # From Section 11.5 of: # Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press. def i...
true
2bb0d8834b23146dbb2e204026452cb3e3f380e7
joshua-scott/python
/ch9 Advanced datastructures.py
1,630
4.3125
4
# Task 1 # Basic lists myList = [ "Blue", "Red", "Yellow", "Green" ] print("The first item in the list is:", myList[0]) print("The entire list printed one at a time:") for i in myList: print(i) # Task 2 # Use lists to allow the user to: # (1) add products, (2) remove items and (3) print the list and quit. def main(...
true
9b4d6e1e4a4a67f47fc74397890841fdd4061624
SakibKhan1/most_frequent_word
/most_frequent_word.py
1,301
4.40625
4
def most_frequently_occuring_word(strings): word_counts = {} most_word = "" most_word_count = 0 for s in strings: words = s.split() # We can then iterate over each word in that string. for word in words: # If the word isn't yet in the count dict...
true
3318e928ef6cd5e68563e3fdc20a6fd77204be63
districtem/ProjectEuler
/euler4.py
815
4.375
4
''' def the_function(): get all 3 digit numbers between 900 and 999, store those numbers for numbers in range start with highest number and multiply by each number less than that number test if product is palindrome if palindrome store in something compare all palindromes...
true
38044d199f319874a0611493b8e997bdbe685a97
jRobinson33/Python
/map_filter_reduce.py
2,029
4.4375
4
#examples of mapping filtering and reducing #6/18/2019 import math def area(r): """Area of a circle with radius 'r'.""" return math.pi * (r**2) radii = [2, 5, 7.1, 0.3, 10] # Method 1: Direct method areas = [] for r in radii: a = area(r) areas.append(a) print("Direct method areas: ", areas) # Metho...
true
7d0c5941f30b676d12ebaec45512e9a676649044
vaaishalijain/Leetcode
/May-LeetCode-Challenge-Solutions/29_Course_Schedule.py
2,081
4.125
4
""" Course Schedule Q. There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and...
true
e95bb74e1ee878076d8803977922c595b7d1f4b3
Empow-PAT/fall2020game
/pickle_func.py
1,248
4.15625
4
import os import pickle import platform # Use this to create a pickle file def create_file(filename: str): # Checks if the file doesn't exist if not os.path.isfile(filename): # Creates the file open(filename, 'xb') # Checks whether the person is using Windows or MacOS(Darwin) and accord...
true
744ef4cf2fbd4f37c8bac9e8184bd0a7d21f3716
ccoo/Multiprocessing-and-Multithreading
/Multi-processing and Multi-threading in Python/Multi-threading/Race Condition Demo by Raymond Hettinger/race_condition.py
1,405
4.28125
4
#!usr/bin/env python3 # -*- coding: utf-8 -*- """ Simple demo of race condition, amplified by fuzzing technique. """ import random import time from threading import Thread # Fizzing is a technique for amplifying race condition to make them more # visible. # Basically, define a fuzz() function, which simply sleeps a ...
true
aef7c9805f73bf47454ee4bfa666ab5a0f12a856
M-Jawad-Malik/Python
/Python_Fundamentals/11.if-elif-else.py
214
4.375
4
# This is program of checking a no whether it is even or odd using if and else keywords # x=eval(input('Enter Number')) if x%2==0: print('Entered number is Even') else: print('Entered number is odd')
true
6e16d5f3d0cb07695b68a48025b2ee6090c95100
M-Jawad-Malik/Python
/Python_Fundamentals/16.list_append().py
224
4.21875
4
#this is way of adding single element at the end of list# list=['1',2,'Jawad'] list.append('Muhammad') #this is way of adding one list to other# list2=[3,4,5,] list.append(list2) print('List after modification: ',list)
true