blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ef3e303e85478829e34ed942487dc188f124777f
jtihomirovs/2021-complete-python-bootcamp
/s12_python_decorators.py
1,510
4.5
4
def hello(name='Jose'): print('This hello() function has been executed!') def greet(): return '\t This is the greet() func inside hello!' def welcome(): return '\t This is welcome() inside hello' # print(greet()) # print(welcome()) # print('This is the end of the hello functio...
true
af64950f12d3c63f6326461769b72c9f5ea75c6a
zcounter/lpthw-exercises
/ex10.py
1,009
4.125
4
tabby_cat = "\tI'm tabbed in." persian_cat = "I'm split\non a line" backslash_cat = "I'm \\ a \\ cat." fat_cat = """ I'll do a list: \t* Cat food \t* Fishies \t* Catnip\n\t* Grass """ print tabby_cat print persian_cat print backslash_cat print fat_cat """ Was asked to enter in the following code: while True: f...
true
f956b58cb7c5cc3cb3106efa1cbd13568e263b33
hivictording/s141
/day2/shopping2.py
2,281
4.125
4
# Author: Victor Ding items = [ ("Apple",5), ("Orange",3), ("Grape", 7), ("Blueberry",10), ("Rasberry", 6), ("Pear",4), ("Watermelon",8), ("Dates",15), ("Lemon",3), ("Avacado",16), ("Brocolli",4), ("Spinach",5), ("Turnip",8), ("Cauliflower",5), ("Pork Belly",...
true
a651825636bed86bf4f505332d98441b8c87334a
adityaswaroop823/randaom-password-generator
/maincode.py
2,714
4.21875
4
# --------------------------RANDOM PASSWORD GENERATOR--------------------------- #..........................................BY- Naman Jawa & Aditya Swarooop..... # It will import tkinter. from tkinter import * # It import pyperclip module # pyyperclip is used it to copy our generated # password to clipboard import py...
true
b18b6e5cbc3697003bf0e93c9f41b8c2ec7713ab
markxueyuan/py_essential
/c1/tuples.py
980
4.125
4
# Why tuple should be viewed as a single object (immutable) # rather than a collection? # Why tuples are needed although we have lists? first_name = "XX" last_name = "YY" phone = '12345678' ## stock = ('GOOG', 100, 490.10) address = ('www.python.org', 8080) person = (first_name, last_name, phone) print(stock) prin...
true
f051d250f295cff4d96e5eb8adfe1c1195a61e95
markxueyuan/py_essential
/oo7/io.py
886
4.15625
4
# open() built-in is used to open a file and return a file object # the bytes will be converted to text using the platform default encoding contents = "some contents" file = open("atext", 'w') # 'w' is called a mode argument file.write(contents) file.close() # 'a' is the mode argument for append # to open a binary...
true
5a5ee0abade2e1802767f8848149307a560c0107
markxueyuan/py_essential
/oo6/queues.py
2,408
4.28125
4
# The queue class is typically used as a sort of communication medium when # one or more objects is producing data and one or more other objects is # consuming the data in some way, probably at a different rate. ############### FIFO from queue import Queue, Empty, Full lineup = Queue(maxsize=3) # The default behavi...
true
4d798dff9ad6692d5bc8a15031edf835b2bc4a20
lily01awasthi/python_assignment
/32_generate_dict.py
336
4.1875
4
"""32. Write a Python script to generate and print a dictionary that contains a number (between 1 and n) in the form (x, x*x). Sample Dictionary ( n = 5) : Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} """ num=int(input("enter a number: ")) expected_dict={} for i in range(1,num+1): expected_dict[i]=i*i prin...
true
525ea4be0964973cb2a5486c72923c056a8065e3
lily01awasthi/python_assignment
/25_empty_dist_in_list.py
400
4.15625
4
"""25. Write a Python program to check whether all dictionaries in a list are empty or not. Sample list : [{},{},{}] Return value : True Sample list : [{1,2},{},{}] Return value : False """ def is_empty(lis): for i in lis: if bool(i): print("False") return 0 else: ...
true
fd89c6aa741b7bf2db5cbcf7680754b8539404c1
lily01awasthi/python_assignment
/63_start_string.py
245
4.1875
4
"""17. Write a Python program to find if a given string starts with a given character""" sample_str=input("enter your string:") check_char=lambda str: str[0] print(f"the start character of given string {sample_str} is:{check_char(sample_str)}")
true
1fbae7930d3555bf5a992c140dc76c21f53a9f8d
phillipj06/Python-ProjectEuler
/problem4.py
1,083
4.25
4
''' A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. Find the largest palindrome made from the product of two 3-digit numbers. ''' def palFinder(maxNum,minNum): ''' palFinder finds the largest palindromic number that is produ...
true
95284c589ef267d185301f82b08e44e168cda051
arguelloj/CFB-study
/CFB- LHEB/Chapter 2/Exercises 2/looping.py
1,469
4.5625
5
#From the Computing for Biologits: Chapter 2 #Section 2.4 Looping Over Lists - looping.py def countLength(DNAlist, length): ''' countLength takes input of a list DNA of strings DNAlist and integer, and returns how many string are of the length of the input integer. ''' count = 0; ...
true
d9fe5f0f0bc2667d4ef98cd28c89e9b277f15840
Sukhrobjon/career-lab
/module_5/first_bad_version.py
1,752
4.34375
4
""" You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versions [1, 2, ..., n] an...
true
32506e5743c9e56f73df563be30f95d3afb6462a
Sukhrobjon/career-lab
/module_4/anagram.py
1,420
4.21875
4
def is_anagram_v1(word1, word2): """Determines if two words are anagram of each other""" # if the strings are not equal length they can't be anagram if len(word1) != len(word2): return False offset = 97 count_s = [0] * 26 count_t = [0] * 26 for i in range(len(word1)): coun...
true
9b7ea54144f4ebf0129822be07f67e2b7349c610
Sukhrobjon/career-lab
/module_4/min_required_chars.py
1,369
4.53125
5
""" Minimum Characters required to make a String Palindromic You are given a string. The only operation allowed is to insert characters in the beginning of the string. Return the number of characters that are needed to be inserted to make the string a palindrome string Examples: Input: ABC Output: 2 Input: AACECAAAA ...
true
6be446620184b80e7ef12270baf2428758756acc
Sukhrobjon/career-lab
/module_2/fizz_buzz.py
532
4.34375
4
def fizzbuzz(n): """Given an input, print all numbers up to and including that input, unless they are divisible by 3, then print "fizz" instead, or if they are divisible by 5, print "buzz". If the number is divisible by both, print "fizzbuzz". """ for num in range(1, n+1): if num % 3 == ...
true
b621bfa9c38b39460750e18588d238c7a1450759
Offliners/Python_Practice
/Project/006.py
909
4.1875
4
def filetextcount(fileinput): linescount = 0 wordscount = 0 charcount = 0 # printing the contents of the file with open(fileinput,"r")as file: content = file.read() print("\nContent of file :\n" + content) with open(fileinput,"r") as file: for line in file: ...
true
b92fce2a8fc7a6bc25e735a453b7e354bba70cc5
Offliners/Python_Practice
/code/147.py
312
4.28125
4
# using "enumerate" data = ["alpha","beta","gamma"] for index,value in enumerate(data): # index = number of the element # in the list # value = the item itself print(f"The element #{index} " f"is {value}") # Output: # The element #0 is alpha # The element #1 is beta # The element #2 is gamma
true
1b0b0f767699411f5d4cad35f363dc689261724e
mjaitly/LeetCode
/Algorithms/Easy/20_Valid_Parentheses.py
1,077
4.125
4
'''' Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid. ...
true
fa793b5457e3d2ad1f5a85844e5965896f829151
okq550/PythonExamples
/PIRPLE/HomeWorks/main8.py
2,637
4.25
4
import os def readFile(fileName): #Print the content of the passed file print('** Operation Read For File', fileName , '**') myFileHandler = open(fileName, 'r') print(myFileHandler.read()) myFileHandler.close() return True def appendToFile(fileName): #Append content to the passed file ...
true
9ce9ecbcb06b0b9cfaeb100d722ca7a3aef94d90
pushpa-ramachandran/Python2
/Classes.py
1,760
4.6875
5
############ Class ################## # Class is a blueprint to create any instances # Almost everything in Python is an object, with its properties and methods # Methods are functions which act on objects ##################### The __init__ method ############# # It is similar to constructors in C++ and Java. ...
true
4229cbcc7c828effe25c0f49e7bde259ad8f58e3
rupampatil/InterviewPractice
/LeetCode/binarySearch.py
857
4.125
4
#iterative def binary_search(elements, target): if not elements or len(elements) <= 0: return -1 left = 0 right = len(elements) - 1 while left <= right: middle = (left + right)/2 if elements[middle] > target: right = middle - 1 elif elements[middle] < target...
true
ebddfe91cb2881676cdb6c618fc0cf129c00f170
jvalansi/word2code
/word2code/res/translations/MicroStrings.py
1,625
4.125
4
from problem_utils import * class MicroStrings: def makeMicroString(self, A, D): input_int0 = A input_int1 = D # John couldn't handle long strings so he came up with the idea of MicroStrings. # You are given two positive ints: A and D . # These determine an infinite decreasing arithmetic progression: A , A...
true
02a5d2b48e41880dba0dab309ff27334bfd1520d
muhammadqasim3/Python-Programming-Exercises
/15_reverse_word_order.py
217
4.21875
4
# There are various solutions to this problem. user_input = input("Enter any sentence: ") def reverse_word(): reversed_input = user_input.split() return " ".join(reversed_input[::-1]) print(reverse_word())
true
5f2083c7649dcb0137caffada014a6fd4adac8d8
thamilarasi43/thamil
/fact.py
285
4.28125
4
num=input("Enter the number") num=int(num) factorial=1 if num<0: print "sorry,factorial does not exist for negative number" elif num==0: print"The factorial of 0 is 1" else: for i in range(1,num+1): factorial=factorial*i print "the factorial of",num,"is",factorial
true
e164e8e078800418560b84a1f7089cb29412c8d5
AdithyaBhat17/Coursera-Python-for-everybody-
/getting_started_with_python/function.py
510
4.3125
4
# Function is some reusable code --> helps to reduce repeat codes # Takes arguments as input # Does computation then returns a result # def to define a function # function_name(argument) to invoke with argument def hello(): print('Hello!') name = input('Who are you? ') print('Welcome ' + name + ...
true
b2d8e3ca3719a7029b8104f64ffdb6399b08db2a
Minu-Chaudhary/Sign-Language-Recognization-for-deaf-mute-people
/Source_file_sl/Python_basics.py
652
4.3125
4
#Python program to declare variables #as this is the testing file i am going to write about pitali mancu print ("pitli mancu") myname="minu" print(myname) mynumber=46 print(mynumber) mynum=0.4 print(mynum) #Python program to illustrate a list #create empty list list =[] #appending data in list list.a...
true
9759843b1aba4e2e7c1a59be640308d377737a0c
chryskrause/bu19
/AFS-200/Week2/EvenOrOdd/evenorodd.py
280
4.15625
4
nums = int(input("Please enter a number: ")) if (nums)%4 == 0 and (nums)%2 == 0: print("You have entered an even number that is also divisible by 4") elif (nums)%2 == 0: print("You have entered an even number") else: print("You have entered an odd number")
true
26a6a2f97a7b8aed0ed32024d04aa6ae0b7368f3
alcarinohta/Ormuco_Python
/questionA/overlap.py
942
4.125
4
#Overlaping Function Ormuco's Technical Python Assessment #Author: Bruna Luisa do Amaral da Silva # Function to verify if two arrays of two numbers overlap # Defining the start and the end of each list def overlaped(v1, v2, v3, v4): # Crating the first array with the numbers that will be stored in variables v1 a...
true
622f8b66e03922f318ad5d1ed45f488e28581ebc
Kushal6070/CaesarCypherEncrypter-Decrypter
/decoder.py
1,715
4.28125
4
#Symbols SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789' #Print game intro print('''Welcome to Caesar Cypher Decoder by Kushal. We help you encode and decode your messages.''') #Ask user mode while True: print() print('''Select mode: E to encrypt. D to decrypt.''')...
true
f21bd80114414fb08cd516f6fe84eaaddc78618b
judgejohn17/Computer-Science-I
/homework/Hexes.py
1,071
4.3125
4
#File: hexes.py #Name: John J. #Description: This program draws 8 hexes from turtle import * def initialize(): """"This function intitalizes the turtle by putting the turtles pen up and turning it to the left""" up() left(90) def drawHexagon(): """This is the function that is responsible for drawing the he...
true
b8e29d70ecab3522a7f253dee52d8a32496efe6f
judgejohn17/Computer-Science-I
/homework/findFast.py
2,222
4.1875
4
#File: findFast.py #Name: John J. #Description: This program uses the fastSelect algarithm with an unsorted list to find the median of the data def getList(): """ This function is responsible for opening the text file thats is used in conjunction with the program. It takes the list and splits each line one by one...
true
0d365a8a96bf561f73e33a14b4f4ab0cb5163652
roshanabey2/python-exercises
/Friday_iteration.py
1,671
4.53125
5
#Take a list, for example my_list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]. #Write a program that prints out all the elements of the list that are less than 5. #Stretch goals: #- Instead of printing the elements one by one, make a new list that has all the # elements less than 5 from this list in it and print out thi...
true
dccf2b8088eb4e1cd25766a25606c64570bb90a4
hardvester/small-coding-challenges
/small_coding_challenges/chapter4_graphs/4_5_validate_bst.py
1,028
4.34375
4
# implement a function to check if a binary treeis a binary search tree from queue_implementation import Queue class TreeNode: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right # checking only if the previous value is smaller than the cur...
true
ae533ed2fbc60c61a84e9a560d37a8a4d716b69b
chinnuz99/luminarpython
/flow controlls/forloop/forloop7.py
242
4.1875
4
#check the given number is prime #9 2to 8 num=int(input("enter the num")) #9 flag=0 for i in range(2,num): #2,9-1=8 ,3 if(num%i==0):#9%2==0 false, 9%3==0 true flag=1 #1 if(flag>0): print("not a prime") else: print("prime")
true
82400e852bc5fd9d4e0be64c53372ab4db632cc4
chinnuz99/luminarpython
/flow controlls/con7.py
307
4.1875
4
#maximum among three number num1=int(input("enter the first number")) num2=int(input("enter the second number")) num3=int(input("enter the third number")) if(num1>num2) &(num1>num3): print(num1,"is maximum") elif(num2>num1) &(num2>num3): print(num2,"is maximum") else: print(num3,"is maximum")
true
92735375876488f98fe2be37e7ea5fc7ce53d27a
chinnuz99/luminarpython
/data collections/set.py
712
4.1875
4
#s={1,9,7,4} #print(s) #print(type(s)) #set does not keep order #a="abs" #print(type(a)) #checking type #curly brases used to identify sets. #empty set #s=set() #print(s) #print(type(s)) #add elements in set #s=set() #print(s) #print(type(s)) #s.add(9) #s.add("hello") #s.add(0.7) #s.add(True) #print(s) # set suppo...
true
207446ef2c864bddfbf6dd083172c225e2663e25
btrowbridge/The-Maxwell-Estate
/Statue.py
2,615
4.34375
4
def statue(): from random import randint from time import sleep #Intro/Instructions print('''You continue through the second level. At the end of a hallway you see moonlight peering through a glass door. you aproach the door and as soon as the moonlight touches the candelabra, it begins to get very hot ...
true
0b460f9ba634fae08f2fe2b57ed6089f8714cac7
prashantxtim/PythonQuestions
/week2.1/question5.py
1,044
4.25
4
#A school decided to replace the desks in three classrooms.Each desks sits two students . #Given the number of students in each class,print the smallest possible number of desks that can be purchesed. #The program should read three integers :the number of students in each of the three classes ,a ,b and c respectively....
true
6d79f5bfdc8772052d4f92f00eb9aefe877a9b9c
DanielBMeeker/Python_2_module_3
/topic_4/NumPy_array_manipulation.py
1,155
4.40625
4
""" Program: NumPy_array_manipulation.py Author: Daniel Meeker Date: 9/17/2020 This program demonstrates using numpy for array manipulations. """ import numpy as np if __name__ == '__main__': array = np.array([[1, 2, 5], [8, 0, -7], [7, 3, 9]]) print(array) # transpose and print to console array = arr...
true
460ceec9df16916ab4545a0681a2000351895447
RaazeshP96/Python_assignment2
/assignment09.py
415
4.125
4
''' Write a binary search function. It should take a sorted sequence and the item it is looking for. It should return the index of the item if found. It should return -1 if the item is not found. ''' def binary_search(n, lis1): for index, item in enumerate(lis1): if item == n: retur...
true
22a753f8f286ccda97d549c41f095e14ba1c5f34
RaazeshP96/Python_assignment2
/assignment06.py
623
4.21875
4
''' Create a list with the names of friends and colleagues. Search for the name ‘John’ using a for a loop. Print ‘not found’ if you didn't find it. ''' # creating the colleagues list colleagues = list() while True: colleague = input("Enter the name of colleague:") colleagues.append(colleague) qns = input(...
true
cbb544a2419fc54555d8e5430843cf99f88c8f3a
RaazeshP96/Python_assignment2
/assignment11.py
422
4.3125
4
''' Create a variable, filename. Assuming that it has a three-letter extension, and using slice operations, find the extension. For README.txt, the extension should be txt. Write code using slice operations that will give the name without the extension. Does your code work on filenames of arbitrary length? ''' filen...
true
e4d0618f78bdc7d28a32a357e5cfd44c15756928
m4hi2/python-junks
/euler/4_euler.py
594
4.21875
4
# palindromic number reads the same both ways. # The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. def is_palindromic(number): str_number = str(number) if str_number == str_number[::-1]: return True ...
true
e014f6a16dc8c31a227bf12f4909c5819dc6bf13
Mshuman8/list_dict_review_teachers
/list_dict_review2.py
2,461
4.5625
5
#List, Dictionary and Iteration Review ################################################################################### LISTS ################################################################################### ##Create a list called group_names which includes the name of every person in our group. ##READ the L...
true
05589b322d9f1c8f75016a8bd478cd33f4d4459c
lfbessegato/Python_Basico_Avancado
/Secao02 - Data Types/Exercicio01_Dicionario.py
314
4.125
4
person = { "name" : "John Green", "gender" : "M", "age" : "35", "address" : "109 Penny Lane", "phone" : "982733633" } key = input("What information do you want to know about the person? ").lower() result = person.get(key, "That information is not available") print(result)
true
d5cd8173ce56f983a55becbb314abc8599937f05
supria68/dailychallenge
/dc25.py
830
4.125
4
""" An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits. For example: 9 is an Armstrong number, because 9 = 9^1 = 9 10 is not an Armstrong number, because 10 != 1^2 + 0^2 = 2 153 is an Armstrong number, because: 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 ...
true
fd720531053192969daf3ba80e9f62781b6ae50f
supria68/dailychallenge
/dc2.py
936
4.4375
4
""" Your task is to return a string that displays a diamond shape on the screen using asterisk (“*”) characters. * *** ***** *** * The shape that the print method will return should resemble a diamond. A number provided as input will represent the number of asterisks printed on the middle line. The line above an...
true
1b9c20b6b8b9ec0cf3d51eaa92108783559f1095
Ankur10gen/DSAinPython3
/Vector.py
1,216
4.15625
4
class Vector: """Vector Operations""" def __init__(self,d): """Initialise a d-dimension vector""" self._coord = [0] * d def __len__(self): """Return: Length of coordinates""" return len(self._coord) def __setitem__(self, key, value): """Set a coordinate to a va...
true
5e5cd23c9fc1792556aa0002b26a7159ff56f147
dlcarterjr/python-functions
/madlib_function.py
552
4.21875
4
## Takes two inputs (name, subject) and outputs a string using those inputs. name = input("\nEnter name: ") subject = input("Enter favorite subject: ") def madlib(name,subject): ## Define a function with two arguments (name, subject). ## Provide default arguments incase inputs are ommitted. if name == ""...
true
e84c11d828b1ee7911fa08851a356f10e02485e4
quinnter/python_sandbox
/python_sandbox_finished/itertools.py
1,009
4.15625
4
# Itertools is a standard library, with useful iterative functions # more functions here https://docs.python.org/3/library/itertools.html from itertools import count # counts up infinitely from a value from itertools import cycle # infinitely iterates though a iterable from itertools import repeat # repeats an object,...
true
70767f412e1701054b36cbf1278d9b4777ca3677
yash73089/MyRepository
/armstrong_no.py
498
4.21875
4
##Armstrong number: ##An Armstrong number is an n-digit number that is ##equal to the sum of the nth powers of its digits x = int(input("enter the number. ")) z = len(str(x)) y = x sum = 0 if x < 100: print(x, "is not an armstrong number") else: while y > 0: i = y % 10 su...
true
b080763634d1832e55acbcc2159ba56dd7fffd87
yash73089/MyRepository
/guess_the_number.py
1,112
4.375
4
# Import random module for this program import random ''' The program will first randomly generate a number unknown to the user. The user needs to guess what that number is. (In other words, the user needs to be able to input information.) If the user’s guess is wrong, the program should return some sort of indica...
true
39659e85a2159309217710338bf096a9c55cd6c1
saikirandulla/HW04
/HW04_ex08_05.py
929
4.3125
4
#!/usr/bin/env python # HW04_ex08_05 # The following program counts the number of times the letter a appears in a # string: # word = 'banana' # count = 0 # for letter in word: # if letter == 'a': # count = count + 1 # print count # Encapsulate this code in a function named "count...
true
074961d3753f1838809dcc8ab88a625cf0f77655
BaiLiping/BLP
/DRL/Code/PyTorch/Learning_PyTorch/decorator.py
1,903
4.46875
4
def outer_function_1(): message="hi from outter function 1" def inner_function(): print(message) return inner_function() def outer_function_2(): message='hi from outter function 2' def inner_function(): print(message) return inner_function #without the parathesis means you retur...
true
f666c74c83483ba3e51e46e07713082abc9e881b
ChrisClear/Coding_Dojo_Coursework
/Python/Python_Fundamentals/Fund_Completed/funwithfunctions.py
2,132
4.40625
4
""" Fun with functions project by: Troy Center troycenter1@gmail.com Assignment: Fun with Functions Create a series of functions based on the below descriptions. Odd/Even: Create a function called odd_even that counts from 1 to 2000. As your loop executes have your program print the number of that iteration and spec...
true
db3e46aa7a4b7ddddc9e13ba632261d75edec6ba
ChrisClear/Coding_Dojo_Coursework
/Python/Python_Fundamentals/Fund_Completed/multiples.py
715
4.5625
5
""" #multiples part 1: write code that prints all the odd numbers from 1 to 1000. #Use the for look and don't use a list to do this exercise. """ for num in range(1, 1000): if num % 2 != 0: print num """ Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000. """ for num i...
true
872918e2e9fa9a20e28c9d4f63bb291f4a752fa0
gengyu1989/Coursera-Algorithms-Specialization
/Course-4:Shortest-Path-Revisited/tsp_heuristic.py
1,801
4.125
4
#!/usr/bin/python3 # Problem Statement {{{ """ In this assignment we will revisit an old friend, the traveling salesman problem (TSP). This week you will implement a heuristic for the TSP, rather than an exact algorithm, and as a result will be able to handle much larger problem sizes. Here is a data file describing a...
true
31581a612a4ad689fe21456cbabee5826a92637e
DevonEJ/university_advanced_programming_labs
/week1/ex3_functions/ex3.py
1,861
4.25
4
import sys def push(structure, data_structure): item = str(input(f"Enter the value to push on to the {structure}: ")).strip() data_structure.append(item) return data_structure def pop(structure, data_structure): if len(data_structure) > 0: if structure == "queue": print(f"This va...
true
8dedd687c41705215547ae915a935e6814c0ce69
DevonEJ/university_advanced_programming_labs
/week1/ex1_stringIO/ex3.py
1,244
4.15625
4
import sys def get_user_input(): try: days = int(input("Please enter how many days in the month: ")) start = int(input("Which day 1-7 (Mon-Sun) does the week start on? ")) except Exception: sys.exit("Oops, try again! Make sure you enter numbers only.") return days, start def gen...
true
d9886cc744c14e96ba7f797ff4d7137633491913
lyndonn03/probability-theory-implementation
/Combinatorics/MultiplicationRule.py
1,183
4.21875
4
import math ''' If E(sub 1) is an experiment with n(sub 1) outcomes and E(sub 2) is an experiment with n(sub 2) outcomes, then the experiment which consists of performing E(sub 1) first and then E(sub 2) consists of n(sub 1) * n(sub 2) possible outcomes. ''' def toss_coin_outcome(numberOfCoins=1): ...
true
99e26e3cb07e81fcd3141edc2985567ae25b5864
caiki/PythonLiebre
/Tomo 1/Chapter 1/Propuesto19.py
511
4.25
4
''' Created on 22/10/2013 @author: CARLOS1 ''' #Write the Scalar Product of 2 vectors in the space #Read the first vector X1 = int(raw_input("Enter the first component(X1): ")) Y1 = int(raw_input("Enter the second component(Y1): ")) #Read the second vector X2 = int(raw_input("Enter the first component(X2): "...
true
a4c7f5cb48651bd8eedd8a6157c3d7db247fbfe3
AjayChhimpa1/Udacity-Intro-to-Computer-Science
/Lesson 2 - How to Repeat/Problem set-Optional 2/Que 2 - Days Old.py
2,252
4.15625
4
# By Websten from forums # # Given your birthday and the current date, calculate your age in days. # Account for leap days. # # Assume that the birthday and current date are correct dates (and no # time travel). # #procedure to check whether year is leap or not def isLeapYear(year): if year % 4 != 0: re...
true
1e0c6f66ec118aee8199a29ee5ecbb5c2ef09fbf
havkokfong/CP1404Practicals
/prac_01/menu_driven.py
552
4.1875
4
MENU = """(E) Show the even numbers from x to y (O) Show the odd numbers from x to y (S) Show the squares from x to y (Q) Exit the program""" print(MENU) choice = input(">>> ").upper() while choice != "Q": if choice == "E": print("Show the even number from x to y") elif choice == "O": print("Sho...
true
c647e2a5e286da13cbec1e67275d7c6a12cf8dd1
jharrilim/Colour-SOFM
/get_user_input.py
1,469
4.28125
4
# Allows for the collection of user input for a variety of types. import sys # Purpose: returns the value inputted by the user as an integer. # Parameters: # @input_name: a string which represents the name of the input value to be collected. # @lower_bound: an integer which represents the lower bound of the ...
true
7ff23685fbe9e00422595353156c6c40ca27216c
codingcampbell/advent-of-python-2019
/src/day_01/part_02.py
1,241
4.125
4
import sys from .part_01 import get_fuel def get_total_fuel(mass): """ A module of mass 14 requires 2 fuel. This fuel requires no further fuel (2 divided by 3 and rounded down is 0, which would call for a negative fuel), so the total fuel required is still just 2. >>> get_total_fuel(14) 2 ...
true
319d3acd3fc2ca7b5479243a60cf98d62e41cf94
tmorris24/Tyler-Morris-Code
/Python/Exercises/countPrimes.py
372
4.1875
4
# Write a function that returns the number of prime numbers that # exist up to and including a given number def count_primes(n): count = 0 prime = 1 for i in range(2, n): for j in range(2, i): if (i % j) == 0: prime = 0 break if prime == 1: ...
true
2a64164ee679cd18ee8fd53d2f8a27d00d348df4
mohamed-tayeh/ABS-Programming-Club
/Hash Christmas Tree.py
731
4.125
4
tree_rows = int(input("Enter tree height: ")) # Tree height input start_space = tree_rows - 1 # Start position of the first hash hashes = 1 # Initial number # Save stumps spaces till later first_spaces = start_space # Make sure the right number of rows are printed while start_space > 0: # Print the space...
true
20fe3792ddc3d12507c471ab1ccc312d5d6ef4da
JudithT/Craking_the_coding_interview
/Linked_lists/partition.py
526
4.125
4
"""" write code to partition a linked list around value x, such that all nodes less than x come before all nodes greater than or equal to x. if x is contained within the list, the value of x only need to be after rge ekements less than x. The Partition element x can appear anywhere in the right partition; it does not n...
true
0e8691182da1193c513700f802f3350503af3fd0
Bassmint123/Python
/py_snips1.py
2,999
4.5625
5
# Appending a string print("This is a string " + "that has been appended") # Using triple quotes for a multi-line string haiku = """The old pond, A frog jumps in: Plop!""" print haiku """ This is an inline comment that can be used anywhere in the code. """ skill_completed = "Python Syntax" exercises_completed = 13...
true
dee4880bafbedb3245538f4874db161a41b5480b
liuluyang/openstack_mogan_study
/myweb/test/checkio/electronic-station/largest-histogram-9-simple.py
850
4.21875
4
#coding:utf8 def largest_histogram(nums): _max = 0 for num in set(nums): r = 0 for n in nums: if n>=num: r += num if r>=_max: _max = r else: r = 0 return _max print largest_histogram([1,2,1,2,2,1]...
true
614679516992ff3a901000c300aa7ee2d0c4207c
Kenkron/SampleCode
/python3/SortFile.py
1,352
4.40625
4
#!/usr/bin/env python3 import sys import traceback #Prompt user for input file InputFileName = input('Input:') #Create an empty list of numbered lines NumberedLines = [] #Open file for reading #You can also use InputFile = open(InputFileName), #but in python, the with-as statement #assures the file is closed with op...
true
6607cf0347e9153d72785d13c61b47d3c24d0fe2
nateDolson/bioinf_git
/python/palindrome.py
875
4.21875
4
# A palindromic number reads the same both ways. The largest palindrome made # from the product of two 2-digit numbers is 9009 = 91 99. # Find the largest palindrome made from the product of two 3-digit numbers. def find_palindrome(number): numList = map(int, str(number)) length = len(numList) i = 1 ...
true
45b642936db8214247bc2800fa9c3d8cf1361b57
zach-hois/BasicSortingAlgorithms
/test/test_algs.py
2,288
4.21875
4
import numpy as np from example import algs def test_pointless_sort(): # generate random vector of length 10 x = np.random.rand(10) # check that pointless_sort always returns [1,2,3] assert np.array_equal(algs.pointless_sort(x), np.array([1,2,3])) # generate a new random vector of length 10 x...
true
81c9079a448d3a551763ff13f5bfbd458f25c590
kunalpohakar/All-about-Python
/Python Basics/Dictionaries Operation/Dictionaries_operation.py
1,550
4.5
4
# Dictionary is a unordered key|value pair. # {} denotes it's a Dictionary # syntax is : Dictionary_name : {kay : value, kay : value} # Dictionary is a mutable # A dictionary keys always has to be an immutable. user = { 'a' : [1, 2, 3], 'b' : 'Hi', 'c' : True } # print(dictionary) # if you wanna ch...
true
6721fa4eb97d0881c3a95daa8421cc68729817fc
Riyagupta008/Cyber-Security
/Assignment 3/riya_1.py
293
4.1875
4
import string inputString = input("Enter the string : ") allAlphabets = 'abcdefghijklmnopqrstuvwxyz' flag = 0 for char in allAlphabets: if char not in inputString.lower(): flag = 1 if flag == 1: print("This is not a pangram string"); else: print("It is a pangram string")
true
b212970cab3d1aa4b3ef547fdd948cd0220f98ff
JuliaDer/100-Days-of-Python
/Intermediate/Day 19: Turtle Race.py
1,382
4.125
4
from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput("Make your bet", "Which turtle will win the race" "(red, orange, yellow, green, blue or purple? Enter a color: ") colors = ["...
true
f2691d9d5fda5488fb363450fc2ff7dd642a92d9
codename-water/WiproPJP
/Data Structures/Tuple/h4.py
239
4.25
4
thisTup=('1', '2.25', 'a', '3', 'b', 'c', '4', 'd', '5', '6', 'e', 'f', '7') print('Tuple...',thisTup) a=input('Enter the element whose index you want to find.') ind=thisTup.index(a) print('Index of the element in the tuple is...',ind)
true
2a06b2c006c6af5b8e1a1576daae1de0f9b8288e
alexkazantsev/code-samples
/node-js/code-executor/tests/mvp/guess_number.py
660
4.21875
4
import random print """1. You have to press run code if you want to play. 2. The player should guess the number between 1-10. 3. You only have three tries. """ answer = random.randint(1, 10) # Using loops to repeat some code tries = 3 # While loop while tries > 0: guess = int(raw_input("What is your guess?\n")...
true
1f4eb6df9f4670feb597105c32062a1476f1b402
damiso15/we_japa_data_science_lab
/Labs/Lab2of1.py
259
4.21875
4
# Write two lines of code below, each assigning a value to a variable # Now write a print statement using .format() to print out a sentence and the # values of both of the variables string = 'my name is ' name = 'dami' print('{}{}'.format(string, name))
true
8b8380db4cc0f1f5a2e6e19b93ea42350ff3892c
farissulaiman92/wdi-february-2019
/06-programming-fundamentals-part-1/instructor/first_python.py
1,018
4.21875
4
# print("Hello world") # print("What's your name?") # # user_name = input() # # print("Hi, {}".format(user_name)) # # print("What year were you born?") # # user_birth_year = int(input()) # # user_age = 2019 - user_birth_year # # print("You are {} years old".format(user_age)) # print("what day is it?") # day_of_week ...
true
9b51d5b9208446b4d8821b13f5181f234380acd4
sherrli/Python-Practice
/Keys_and_values.py
392
4.34375
4
# Looping over a key # Should we return the key or the value? def main(): d = {'math': 'red', 'writing': 'green', 'science': 'blue'} for k in d: print(k) # Keys are the entries before the colon for k in d.keys(): if k.startswith('w'): print(d[k]) # Print the values: after the colon (prin...
true
807309ab4dd4e369b9a5f52f629c6b2ab49b60fd
wvbraun/TheLab
/python/src/data_structures/code/analysis/anagram.py
2,193
4.125
4
#solution to anagram problem by checking off. def anagram1(s1, s2): a_list = list(s2) pos1 = 0 stillOk = True while pos1 < len(s1) and stillOk: pos2 = 0 found = False while pos2 < len(a_list) and not found: if s1[pos1] == a_list[pos2]: found = T...
true
a230e2e37157f370326f26b3549c15e40ba479f6
wvbraun/TheLab
/python/src/data_structures/code/recursion/turtle/tower.py
878
4.15625
4
# Tower of Hanoi # 1. Move a tower of height -1 to an intermediate pole, # using the final pole. # 2. Move the remaining disk to the final pole. # 3. Move the tower of height -1 from the intermediate pole, # to the final pole using the original pole. def moveTower(height, fromPole, toPole, withPole): if he...
true
ad65361691376998e68f9db30b4e4477b1e63445
vinutha-yv/python_Project
/Aug292020/conditionals_demonstration.py
460
4.375
4
# input function always accepts string, if we want to convert string to float use float(input()) num = float(input("Enter value : ")) if num < 35.5: print(f"{num} less than 35.5") elif num <= 99.0: print(f"{num} is greater than 35.5 and {num} less than 100") else: print(f"{num} greater than or equals to 10...
true
a1eff51c7d1f2521532aaea5f6575c6be3d33b77
vinutha-yv/python_Project
/Assignments/Aug292020/divisibility_number.py
725
4.125
4
''' Checking the divisibility of a number from andother number a is dividend b is divisor ''' def div_num(d1, d2): if d1 == d2: if d2 == 0: return "0/0 not possible" else: return True elif d1 > d2: if d2 == 0: return "division by 0 not possible, d2 is...
true
ec6f1d7a2db8fb24ab927e884a34ac90c1b8534f
SaadAhmedSalim/Numerical_Method_using_python
/PNMP_2_03.py
492
4.375
4
''' Method: Newton-Raphson Section: Roots of Higher-Degree Equations Course: Programming Numerical Methods in Python Instructor: Murad Elarbi File Name: PNMP_2_03.py Date: Aug. 6, 2017 ''' x = 0 for iteration in range(1,101): xnew = x - (2*x**2 - 5*x + 3)/(4*x - 5) # the Newton-Raphson's formula if ...
true
1bde98bae498e050552b209dc8e65e32f15d9551
samratkar/PYTHON
/NUMPY/EXERCISES.py
899
4.25
4
#QUESTION 1 #Description #Given m and n, swap the mth and nth rows of the 2-D NumPy array given below. #a = [[4 3 1] # [5 7 0] # [9 9 3] # [8 2 4]] import numpy as np # Given array a = np.array([[4, 3, 1], [5, 7, 0], [9, 9, 3], [8, 2, 4]]) temp=a[0] a[3] # Read the values of m and n m = int(inp...
true
c6a507ab43812ffed9a3d0e977b2569d35d59041
samratkar/PYTHON
/BASICS/MISCS.py
855
4.21875
4
print (int(9.8)) name = input ("Ener your name") print("Hello", name) # input returns always a string. hrs = input("Enter Hours:") rate = input("Enter rate:") print ("Pay:", (float(hrs)*float(rate))) # intendation is important. num = input ('Enter a number') if int(num) > 5 : print ("greater than 5") print (...
true
1b608b52b65ba1a4a7293842f7542d027c652d45
samratkar/PYTHON
/BASICS/MAP.py
1,559
4.125
4
print("hi there") store1 = [10.00, 11.00, 12.00, 2.34] min(store1) store2 = [1.11, 9.22, 10.99, 13] # min will be applied one by one to the elements each taken from the list in the argument. First element of store1 is taken along with the 1st element of store 2 and it goes one. THen second element is taken from each li...
true
73b3d0657f4385f0f6bc4aadafb4666af47888b6
Iamverygood88/Coolrep
/RPSGame.py
2,217
4.25
4
from random import randint player_lives = 3 computer_lives = 3 # available weapons => store this in an array choices = ["Rock", "Paper", "Scissors"] player = False # make the computer pick one item at random computer = choices[randint(0, 2)] # show the computer choice in the terminal_window print("Computer chooses...
true
9c67fa4c6a5e553853dd863fd8440082232698e7
amelendez2/Professional-Portfolio
/PythonGame_D20_early_development/D20.py
879
4.1875
4
import random ''' The game is based on a D20 system so this class allows the game to determine what range of random numbers to search through based on die type. For example if the user rolls a d8 for a weapon damage swing then this class will determine the damage based on a random number between 1 and 8. ''' class ...
true
746d24659745fb3bf66bf3dadcef46a0f086c56f
sivant1361/python
/programs/vowels.py
217
4.125
4
import re def search_vowel(str): pattern=r"[aeiou]" if re.search(pattern,str): print("Vowels are found:)") else: print("Vowels not found:(") str=input("Enter a string:") search_vowel(str)
true
cfc25a4f54f095c598950f8f2e1acd74ee746c51
SilvestrLanik/sudoku
/Logic/board.py
1,305
4.125
4
import math from Sudoku.Logic.constants import * class Board: # size is the maximum value in sudoku. For traditional one it is 9 def __init__(self, size): self.grid = [[EMPTY] * size for i in range(size)] self.size = size self.square_size = int(math.sqrt(self.size)) # size ...
true
370aa310f30374deaa4d7469c82c6e10724c9f7f
rannavakili/todo_list
/todo_list.py
1,764
4.59375
5
"""This is a Terminal-based program that allows a user to create and edit a to-do list. The stub of each function has been provided. Read the docstrings for what each function should do and complete the body of the functions below. You can run the script in your Terminal at any time using the command: >>> pytho...
true
d0da71f41c6ff5c93079cf5ee5784039e464ae1f
devansh-afk/Crash-Course-online
/Files_and_Exceptions/count_words.py
550
4.28125
4
def count_words(filename): """Counts the number of words ini a text file""" try: with open(filename) as f: contents = f.read() except FileNotFoundError: print(f'The file {filename} does not exist') else: words = contents.split() num_words = len(words) ...
true
6763d2ffc63e3b7d85a9765982711b1ba1ca230b
devansh-afk/Crash-Course-online
/Class/Restaurant2.py
846
4.125
4
"""A class that represents a Restaurant""" class Restaurant: """A simple attempt to model a restaurant""" def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self...
true
5250aa9d9bb00a61315335055d06f5616fffd63e
dustinsnoap/Python-I
/code_challenges/reverseCase.py
484
4.34375
4
# Good morning! Write a function that takes in a string, reverses the 'casing' of that string, and returns the "reversed-casing" string. # const string = 'HELLO world!'; # console.log(reverseCase(string)); // <--- hello WORLD! def reverseCase(string): newstr = "" for c in string: if c.isupper(): newst...
true
acbab24ddf836042caba37fd6714311d2cd165c6
Nsonnes/Assignment-1
/pizza.py
399
4.1875
4
toppings = '' topping = '' print('Enter "quit" to exit the program') while topping != 'quit': topping = input('Which topping should be on your pizza? ') if topping.lower() == 'quit': print('Expect your' + toppings + ' pizza to be delivered in 10 minutes') else: toppings = toppings + ' ' + to...
true
afd9982d5e69e1cb21d4de4ce646f5860bd4513e
chengyang00/MCM-USTC
/code/count_word_frequency.py
1,221
4.21875
4
import collections import re def stopwordslist(): #delete stop words stopwords = [line.strip() for line in open('./stopwords.txt').readlines()] return stopwords def count_word(filename): """count filename word frequency :param filename: """ # return value is dict,will count automatically ...
true