blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
d405d71afd926403cc81f83f5279086202b9d7b9
jonlorusso/projecteuler
/problem00007.py
800
4.1875
4
#!/usr/bin/env # 10001st prime # Problem 7 # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. # What is the 10 001st prime number? import math from itertools import islice def isprime(n): if n == 1: return False for i in xrange(2, int(math.sqrt(n)...
true
24f8941fca82fcc36e85574a14708e38dce6033e
lolNickFox/pythonWorkshop
/demo.py
2,934
4.21875
4
# coding: utf-8 # Live Demo # --------- # # Let's implement a function that returns the $n$th element of a certain series. # # The first two elements of the series are given: # # $$F_0 = 1, F_1 = 1$$ # # The function returns $F_n$ such that: # # $$F_n = F_{n - 2} + F_{n - 1}$$ # In[13]: def fibonacci(n): ...
true
ab78a3d3e88d09367b3783bdf66de31dbcfed698
psm18/16ECA_parksunmyeong
/lab 01 intro/08_streamplot_demo_features.py
1,086
4.21875
4
# -*- coding: utf8 -*- """ Demo of the 'streamplor' function. A streamplot, or streamline plot, is used to display 2D vector fields, This example shows a few features of the stream plot function: *Varying the color along a streamline. *Varying the desity of streamlines. *Varying the line width along a st...
true
032ec8b52b6a31902a63d98f1caba75830101d42
riturajkush/Geeks-for-geeks-DSA-in-python
/hashing/Sorting Elements of an Array by Frequency.py
1,388
4.125
4
#User function Template for python3 ''' Your task is to sort the elements according to the frequency of their occurence in the given array. Function Arguments: array a with size n. Return Type:none, print the sorted array ''' def values(dic): return dic.values def sortByFreq(arr,n): dic ...
true
70475137935f83421aaea43af6b5607ac606837c
www-wy-com/StudyPy01
/180202_input_output.py
1,233
4.21875
4
# -*- coding: utf-8 -*- import pickle # 用户输入内容 def reverse(text): return text[::-1] def is_palindrome(text): return text == reverse(text) something = input('enter text: ') if is_palindrome(something): print('yes, this is palindrome') else: print('no, this is not a palindrome') # 再议input birth=input('...
true
a96ffed047aae4ae9c795c20b13af35f168a9030
bhargavraju/practice-py2
/hashing/copy_list.py
1,248
4.125
4
""" A linked list is given such that each node contains an additional random pointer which could point to any node in the list or NULL. Return a deep copy of the list. Example Given list 1 -> 2 -> 3 with random pointers going from 1 -> 3 2 -> 1 3 -> 1 You should return a deep copy of the list. The returned an...
true
6c605d2e08388d3b94983568b1fd925184e23e55
bhargavraju/practice-py2
/arrays/insert_interval.py
1,252
4.15625
4
""" Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Example 1: Given intervals [1,3],[6,9] insert and merge [2,5] would result in [1,5],[6,9]. Example 2: Given [1,2],[3,5],[...
true
6285c75c7972f537d3a73ad89d2d938ee086be44
zhgmyron/python_ask
/hellworld.py
441
4.15625
4
names=['mama','mike','jim'] def list_all(names): print("--------") for i in names: print (i) list_all(names) absent=names.pop(1) print(absent+"can't present the party") names.append('mao') list_all(names) names.insert(0,'ba') names.insert(2,'di') names.append("chou") list_all(names) a=names.pop() print...
true
7effc9859d4c01502a739f97055913f0312a61ca
kk0174lll/codewars
/Infix to Postfix Converter/main.py
1,413
4.15625
4
''' Construct a function that, when given a string containing an expression in infix notation, will return an identical expression in postfix notation. The operators used will be +, -, *, /, and ^ with standard precedence rules and left-associativity of all operators but ^. The operands will be single-digit integers b...
true
bad8984b8b21df30f8cd186a4efad8ee4e5b8b14
Ntalemarvin/python
/list.py
398
4.3125
4
#LISTS names = ['john','isaac','Marvin','frost','Mary','Benj'] print(names[4]) print(names[2:3]) print(names[:]) names[3]='frosts' print(names) #write a program to find the largest number in a list numbers = [2,3,5,6,17,69,7,9,10,69,200,453,23,45] '''lets assume the largest number is numbers[0]''' max = numbers[0]...
true
c112260af77340ed69565e507527486656cb43da
kidusasfaw/addiscoder_2016
/labs/server_files_without_solutions/lab9/trionacci2/trionacci2_solution.py
337
4.125
4
import sys # the input to this function is an integer n. The output is the nth trionacci number. def trionacci(n): # student should implement this function ########################################### # INPUT OUTPUT CODE. DO NOT EDIT CODE BELOW. n = int(sys.stdin.readline()) ans = trionacci(n) sys.stdout.write(st...
true
769173e701119ce1a7d0f12f310eed2c4adfc291
Ttibsi/AutomateTheBoringStuff
/Ch.07 - Pattern Matching with Regular Expressions/FindPhoneNumberDividedIntoGroups.py
649
4.15625
4
# More Pattern Matching with Regular Expressions import re phoneNumRegex = re.compile(r'(\d\d\d)-(\d\d\d-\d\d\d\d)') phoneNumRegexWithBrackets = re.compile(r'(\(\d\d\d\)) (\d\d\d-\d\d\d\d)') mo = phoneNumRegexWithBrackets.search('my number is (415) 555-4242') #This gets the parenthesis sections of the regex, with it...
true
23970409685018fba3be8c38d9c2fa46a4dd3073
shriya246/Python-internship-Best-Enlist
/Day8.py
2,062
4.28125
4
dict1={"a":1,"b":2} dict2={"c":3,"d":4} dict3=(dict2.update(dict1)) print(dict2) #sorting and convert list into set list1 = [4,3,2,1] list2 =list1[::-1] set1 = set(list2) print(set1) #3) program to list number of items in a dictionary key names = {3:"a",2:"b",1:"c"} list3 = dict.keys(names) print("list of d...
true
57acdcb38d4b52d2878b2ee8ee795af745fcd506
alexguldemond/MA173A_Sample_Code
/python/data_structures/tuples.py
457
4.375
4
#!/usr/bin/python3 # Tuples are like lists, but they are immutable, i.e. cannot be changed tup = (1, 2, "Hello") # We can index them like lists print(tup[1]) # But we cannot change them # tup[0] = 3 # The above will error out # Tuples can also be easily unpacked. This can be useful for getting several values out a...
true
786f227d47997cb4c425bbfb5a86dd5ea4d079bc
alexguldemond/MA173A_Sample_Code
/python/printing/formatted_printing.py
369
4.46875
4
#!/usr/bin/python3 # Sometimes you want to print data without worrying about building strings. # Formatted printing makes this convenient datum1 = 1.1 datum2 = 1.2 datum3 = 1.3 # Note the prefix f, and the use of curly braces inside the string print(f"Here is some data: {datum1}, {datum2}, {datum3}") # Should print ...
true
cdf12952bb23eb100f0087eeecb10d871abe0e5d
LuisMoranDev/Python-Projects
/Python Projects/Change.py
1,192
4.125
4
def changeBack(): cents = {"Quarters: ":.25, "Dimes: ":.10, "Nickels: ":0.05, "Pennies ": 0.01} while True: try: cost = float(input("Enter the cost of the item: ")) except ValueError: print("Cost must be an integer") else: if cost < 0: print("The cost of the item must be greater than 0") else: ...
true
94c8188c7661f1a499d8f80378e1ae3d0722b8f4
coryeleven/learn_python
/input_while.py
2,875
4.1875
4
""" 1.input str、int,求模运算符 2.while 循环 3.break continue结束或跳出循环 """ #存储成一个变量提示信息 int ''' prompt = "If you tell us who are you , we can personalize the message you see." prompt += "\nWhat is your first name?\n" name = input(prompt) print(name) height = input("How tall are you, in inches? ") height = int(height...
true
8a45ef85f2d529e5abfee8b8c2b64b94bd87d202
micmor-m/Hangman
/main.py
1,028
4.125
4
import random from hangman_words import word_list from hangman_art import stages, logo end_of_game = False # word_list = ["aardvark", "baboon", "camel"] chosen_word = random.choice(word_list) lives = 6 print(logo) # print(f'The solution is {chosen_word}.') display = [] for ch in chosen_word: display.append("_") ...
true
018a792e66958a5d8683eb50b0062806417586d2
arcSlayer85/random_python_bits
/inchesToCms.py
876
4.71875
5
#! /usr/bin/python """ program that offers the user the choice of converting cm to inches or inches to centimetres. Use functions for each of the conversion programs. """ # Function for cm's to inches... def calculateCms ( int ): _cm = _height * 2.54; print (_cm); # function for inches to cm'...
true
8690cf0bf9a05db858172dd1e96b87e139e5eb6b
longchushui/How-to-think-like-a-computer-scientist
/exercise_0312.py
646
4.40625
4
#Write a program to draw a face of a clock that looks something like this: import turtle # get the turtle module # set up screen wn = turtle.Screen() wn.bgcolor("lightgreen") # set up turtle tess = turtle.Turtle() tess.color("blue") # make tess blue tess.shape("turtle") # now tess looks like a turt...
true
f27a17b433ae7e6d8149eb9738d0859f4c016ceb
longchushui/How-to-think-like-a-computer-scientist
/exercise_0501.py
733
4.46875
4
# Assume the days of the week are numbered 0,1,2,3,4,5,6 from Sunday to Saturday. # Write a function which is given the day number, and it returns the day name (a string). def day_name(day_number): """ The function day_name() returns the day_name {Sunday-Saturday} given the day_number {0-6}. """ ...
true
c884357afb95680b5ffb0d2b4875305db8eefa9e
longchushui/How-to-think-like-a-computer-scientist
/exercise_0404.py
603
4.28125
4
import turtle def draw_poly(t, n, sz): """ The function draw_poly() makes a turtle t draw a regular polygon with n corners of size sz. """ for i in range(n): t.forward(sz) t.left(360/n) # set up screen wn = turtle.Screen() wn.bgcolor("lightgreen") # make the background gr...
true
7b5bec25ca82e213e87aea54d4db5ca6106b05c9
ctlnwtkns/itc_110
/abs_hw/ch7/regexStriptest.py
1,707
4.5
4
''' Write a function that takes a string and does the same thing as the strip() string method (remove whitespace characters, i.e. space, tab, newline). If no arguments are passed other than the string to strip, then whitespace characters will be removed from the beginning and end of the string. Otherwise, the chara...
true
72c0a270951ee86997d0cc30cccef052e29f4d31
affiong/switch_affiong
/hangman1.py
1,713
4.125
4
import random wordlist = "one two three four five six seven".upper().split() random.shuffle(wordlist) secret_word = wordlist.pop() correct = [] incorrect = [] #print("DEBUG: %s" % secret_word) def display_word(): #display random word for i in secret_word: if i in correct: print(i, end=" "...
true
88addc9e635a001adef7b8a0738130032830ef7d
pdefusco/Python
/app_development/lpth/ex11.py
454
4.21875
4
#working with inputs and printing the text print("How old are you?", end= ' ') age = input() print("How tall are you?", end = ' ') height = input() print(f"The age is {age} and the height is {height}") #now inputting numbers: print("Let's do some math. Multuply value x times value y") print('Assign value for x: ', ...
true
34b2c0dfa65c7f51f4b6ed3ee54b64fd407882a9
ShwetaAkiwate/GitDemo
/pythonTesting/write.py
462
4.28125
4
# read the file and store all the lines in list #reverse the list #write the list back to the file with open('test.txt', 'r') as reader: # with is used for open the file, shortcut of "file = open('test.txt') file.close())" content = reader.readlines() #[abc,bretwer,cere, derre,egrete] reversed(content) #[e...
true
c8ba9f5518d1e54101e500afd2341a5a5ac5827d
ShwetaAkiwate/GitDemo
/pythonTesting/demo2nd.py
885
4.40625
4
values = [1, 2, "Krunal", 4, 5] # list is data type that allows multiple values and can be different data type print(values[0]) print(values[3]) print(values[-1]) # if you want to print last value in the list. this is shortcut print(values[1:3]) values.insert(3, "shweta") print(values) values.append("End") p...
true
9b7adad9b27492dbe0ac4f5f232b9ed02e4c78d9
BrodyCur/oop-inheritance
/class_time.py
679
4.125
4
class Person: def __init__(self, name): self.name = name def greeting(self): print(f"Hi my name is {self.name}.") class Student(Person): def learn(self): print("I get it!") class Instructor(Person): def teach(self): print("An object is an instance of a class.") teacher = Instructor('Na...
true
7b1ed9f05b439119fbba39393cea3e7d5bc3bc27
rtuita23/bicycle
/bicycle.py
1,659
4.40625
4
""" BICYCLE CLASS TODO - A bicycle has a model name TODO - A bicycle has a weight TODO - A bicycle has a cost TODO - Return as dictionary () """ class Bicycle: def __init__(self, modelName, weight, cost): self.modelName = modelName self.weight = weight self.cost = cost ...
true
2a3186ce3f5f0c3c5bcae47810b04285541eac56
gaolingshan/LeetcodePython
/500KeyboardRow.py
1,239
4.15625
4
''' 500. Keyboard Row Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. Example 1: Input: ["Hello", "Alaska", "Dad", "Peace"] Output: ["Alaska", "Dad"] Note: You may use one character in the keyboard more than once. You may ...
true
23a076b0d68ae363d2226119184ea976d5a6b1d7
gaolingshan/LeetcodePython
/414ThirdMaximumNumber.py
1,199
4.15625
4
''' 414. Third Maximum Number Difficulty: Easy Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). Example 1: Input: [3, 2, 1] Output: 1 Explanation: The third maximum is 1. Example 2: Input: [1, 2...
true
bb63af901b9acacc65d119ab5444da3bb25d20c6
hyc121110/LeetCodeProblems
/String/isValidParentheses.py
629
4.15625
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
ae871173fa6e77f1423dda6dcecfc0407e7d8239
hyc121110/LeetCodeProblems
/Others/maxProduct.py
864
4.28125
4
''' Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. ''' def maxProduct(nums): # initialize max product r = nums[0] # imax/imin stores the max/min product of subarray that ends with the current number A[i] imax = imin = r...
true
d215f6192e52fcfb423810ed9d3cef7bf453ddbb
hyc121110/LeetCodeProblems
/String/letterCombinations.py
980
4.21875
4
''' Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. ''' def letterCombinations(digits): map_ = { '2' : '...
true
e2df8c6429a4423480779f58e94c207b78bf500e
hyc121110/LeetCodeProblems
/Array/subsets2.py
721
4.21875
4
''' Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. ''' def subsetsWithDup(nums): # similar to subset.py but with sorting and checking # if subset in result list or not res = list()...
true
2e4cd6eccf5231c205e6b8846224721b9516dd74
chanhosuh/algorithms
/sorting/quicksort/utils.py
1,383
4.125
4
from random import randrange def position_pivot(a, lo, hi, pivot=None): """ various possibilities, but here we select a reasonably robust pivot selection methodology: median of three After possibly several swaps, a[hi] is the "median" value of a[lo], a[hi-1], a[hi]. Note: - it's assumed ...
true
1fc0c94d2dd509c2d8becbba0ed16b67fe3d02ef
misohan/Jmk
/dict_test.py
789
4.34375
4
# Create a dict directory which stores telephone numbers (as string values), # and populate it with these key-value pairs: directory = { 'Jane Doe': '+27 555 5367', 'John Smith': '+27 555 6254', 'Bob Stone': '+27 555 5689' } # Change Jane’s number to +27 555 1024 directory['Jane Doe'] = '+27 555 1024' #...
true
0471166b0d6f9d6252987d7ed81d8cc61e767c0f
ashrafm97/pycharm_oop_project
/dogs_class.py
1,597
4.46875
4
# abstract and create the class dog # class Dog(): # pass #initializing a Dog object # dog_instance1 = Dog() #print the Dog object # print(dog_instance1) # print(type(dog_instance1)) # you want to define classes on one side and run them on the other... you need to chop this code and place it in the run file...
true
cd9cbd6cbe29ed79ee8775368599218fe0e0a151
duqcyxwd/python-practice-
/MaxProductOfThree.py
1,884
4.28125
4
#!/usr/bin/env python # For example, array A such that: # A[0] = -3 # A[1] = 1 # A[2] = 2 # A[3] = -2 # A[4] = 5 # A[5] = 6 # contains the following example triplets: # (1, 2, 4), product is 1 * 2 * 5 = 10 # (2, 4, 5), product is 2 * 5 * 6 = 60 # Your goal is to find the maximal product of any triplet. ...
true
2a10483d5ba863777c8bc3411ba5fa91e476df16
ashish6194/pythonbasics
/chapter_04/01_comp_op.py
351
4.3125
4
name = input("What's your name? ") if name == "Jessica": print("Hello, nice to see you {}".format(name)) elif name == "Danielle": print("Hello, you are a great person!") elif name != "Mariah": print("You're not Mariah!") elif name == "Kingston": print("Hi, {}, let's have lunch soon!".format(name)) else:...
true
b9c455b5b293307355cea6d4a5239a4b86a2f9d5
JeffreyAsuncion/CSPT15_Graphs_I_GP
/src/demos/demo1.py
780
4.125
4
""" You are given an undirected graph with its maximum degree (the degree of a node is the number of edges connected to the node). You need to write a function that can take an undirected graph as its argument and color the graph legally (a legal graph coloring is when no adjacent nodes have the same color). The number...
true
14bb42f59d4bdbc07ac76c43936e4cb347d63e10
muigaipeter/Python_class
/workingfolder/classes/demo1.py
1,505
4.21875
4
#is a blue print in oop #an object/instance #syntax #class name_of_the_class(): #the blue print attributes class Person(): name = 'Developer' d1 = Person() d2 = Person() print(d1.name) print(d2.name) #all classes has a function called _init_() # which is always executed when the class is being ...
true
ea021e6da43d11fa8ce3f4d40bb000bcf3a078a8
RodrigoPenedo/UsefulPython
/Algorithms/InsertionSort.py
409
4.15625
4
def InsertionSort(array): for i in range(1, len(array)): current = array[i] number = i-1 while number >=0 and current < array[number] : array[number+1] = array[number] number -= 1 array[number+1] = current #print(ar...
true
a1f47e5f59e85a5ff88cffd7fea0fe9a8ee18d50
niteshkrsingh51/hackerRank_Python_Practice
/basic_data_types/nested_lists.py
668
4.21875
4
#Print the name(s) of any student(s) having the second lowest grade in. If there are multiple students, #order their names alphabetically and print each one on a new line. if __name__ == '__main__': my_list = [] scores = set() second_lowest_names = [] for _ in range(int(input())): name = input(...
true
3e2ca2e8dd2ffeeb15ba524f58b96de1a367ea99
mohan-sharan/python-programming
/Loop/loops_4.py
340
4.125
4
#What is a break statement? #It stops the execution of the statement in the current/innermost loop and #starts executing the next line of code after the block. x = 20 while x > 10: print("x =", x) x -= 1 if x == 15: break print("BREAK") ''' OUTPUT: x = 20 x = 19 x = 18 x = 17 ...
true
5383d421e4fc403d9149aa1a96c3c307e8b0ff44
mohan-sharan/python-programming
/Misc/factorial_1.py
765
4.4375
4
#FACTORIAL #Denoted by n! #where n = non-negative integer #is the product of all positive integers less than or equal to n. #For example: 4! = 4*3*2*1 = 24 n = int(input("Enter a number to find its factorial: ")) fact = 1 if (n == 0): print("The Factorial of 0 is 1.") elif (n < 0): print("INVA...
true
41edeab8831e9eede53ecbd21576e9e6b8fa4171
mohan-sharan/python-programming
/Tuple/tuples_1.py
801
4.34375
4
#Tuples myTuple1 = ("07-06-1969", "01-23-1996") print(myTuple1[0]) print(myTuple1[1]) ''' OUTPUT: 07-06-1969 01-23-1996 ''' #del doesn't work on a tuple. The output below shows what happens when del is called. del(myTuple1[0]) ''' OUTPUT: File "C:/Users/PycharmProjects/tutorial/basics.py", line 5...
true
8d356b8ca92e70413f209bdced8a1c57d8d86315
mohan-sharan/python-programming
/Misc/division_by_zero.py
893
4.1875
4
#a simple program to demonstrate the handling of exceptions. #try-except block. a = int(input("Enter a number:\n")) b = int(input("Enter another number:\n")) c = a/b print("\na/b = ", c) ''' OUTPUT 1: Enter a number: 5 Enter another number: 2 a/b = 2.5 Process finished with exit code 0 OUTPUT...
true
c5d167db5dea9485a6091a04c40fa3ed9df7eff7
AGagliano/HW02
/HW02_ex03_05.py
2,631
4.375
4
#!/usr/bin/env python # HW02_ex03_05 # This exercise can be done using only the statements and other features we # have learned so far. # (1) Write a function that draws a grid like the following: # + - - - - + - - - - + # | | | # | | | # | | | # | | | ...
true
7559888242932f2ccb97df79a8a585b7885dba88
Olga20011/Django-ToDoList
/API/STACKS/stacks.py
580
4.15625
4
#creating a stack def create_stack(): stack=[] return stack #creating an empty stack def create_empty(stack): return len(stack) #adding an item toa stack def push(stack,item): stack.append(item) print("pushed item: "+ item) #Removing an element def pop(stack): if (create_empty(stack))...
true
c5da8483fc03d98e0272c42bdc2fbe5bbd78502f
informatik-mannheim/PyTorchMedical-Workshop
/basic_templates/pythonBasics/loops.py
897
4.625
5
def whileLoop(): i = 0 while i < 3: print(i) i = i+1 whileLoop() def forLoop_OverElements(elements): for element in elements: print(element) x = ["a", "b", "c"] forLoop_OverElements(x) def forLoop_usingLength(elements): for i in range(len(elements)): print("elemen...
true
cc001ba5beda435c8f915efc1cfb43d75ab55b04
ShamSaleem/Natural-Language-Processing-Zero-to-Hero
/Filtering text.py
493
4.28125
4
#Filtering a text: This program computes the vocabulary of a text, then removes all items #that occur in an existing wordlist, leaving just the uncommon or misspelled words import nltk def unusual_words(text): text_vocab = set(w.lower() for w in text if w.isalpha()) english_vocab = set(w.lower() for w in n...
true
5acfeceb07de8e7b6c1bc0edf360ab45c0a1cef8
Jessica-A-S/Practicals-ProgrammingI
/PartBTask3.py
438
4.125
4
def main(): age = int(input("Enter your age: ")) enrolled = input("Are you enrolled to vote(Y/N)? ").upper() if age >= 18: age = True if enrolled == "Y": enrolled = True else: enrolled = False else: enrolled = False if age and enroll...
true
25d1b68218f4b6d078380cfcf61b8e52b35970dc
nicolemhfarley/short-challenges
/common_array_elements.py
1,930
4.21875
4
""" Given two arrays a1 and a2 of positive integers find the common elements between them and return a set of the elements that have a sum or difference equal to either array length. All elements will be positive integers greater than 0 If there are no results an empty set should be returned Each operation should only...
true
94f38973ce467e5a357b5d8b2c28c3091dfe91c5
sanjipmehta/Enumerate
/enumerate.py
390
4.15625
4
#First i want to print position and and its value without using enumerate pos=0 name=['google','amazon','Dell','nasa'] for x in name: print(pos,'is the index of:',name[pos]) pos+=1 pos=0 for x in name: print(f" {pos}-------->{name[pos]}") pos+=1 #Now by using enumerate function name=['google','amazon','Dell','n...
true
020c8ab5b314eebea1aed3cfd0548f744d76aad3
seowteckkueh/Python-Crash-Course
/10.7_addition_calculator.py
378
4.15625
4
while True: try: num1=input("please enter the first number: ") break except ValueError: print("That's not a number, please try again") while True: try: num2=int(input("please enter the second number: ")) break except ValueError: print("That's not ...
true
6dd0731adde536a8be2b900a6e0cb0ece6fb15b0
seowteckkueh/Python-Crash-Course
/5.9_no_users.py
683
4.15625
4
usernames=['admin','ben','poppy','alice','emily','jane'] if usernames: for username in usernames: if username=='admin': print("Hello admin, would ou like to see a status report?") else: print("Hello "+username.title()+" thank you for logging in again.") else: print("We ne...
true
98dd378fe9ed51cd810bba3e019d0ab5502a5694
TylerPrak/Learning-Python-The-Hard-Way
/ex7.py
843
4.40625
4
#Prints out a string print "Mary had a little lamb." #Prints out a string containg the string(%s) format character. The string is followed by a '%' and a string instead of a variable. print "Its fleece was white as %s." % 'snow' #Prints out a string print "And everywhere that Mary went." #Prints out '.' 10 times bec...
true
22543f81b1b52ab248d11f39b6d4003a438a1d68
d3r3k6/PyPraxy
/listProjectRefactor.py
355
4.28125
4
# The task is to Write a function that takes a list value as an argument and return #a string with all the items separated by a comma and a space, with and inserted before the last items newList = ['apples', 'bananas', 'tofu', 'cats'] def convert(list): list = newList list[-1] = 'and ' + str(list[-1]) +'.' print('...
true
4fed83ae1ef25bef17f187b6402c3b43d8435a25
Krishna219/Fundamentals-of-computing
/Principles of Computing (Part 1)/Week 1/2048 (Merge).py
1,731
4.375
4
""" Merge function for 2048 game. """ def shift_to_front(lst): """ Function that shifts all the non-zero entries of the list 'line' to the front Exactly shifts all the zeros to the end """ for index in range(0, len(lst) - 1): #if an element is zero just swap it with the number next...
true
15694511a5cd2ff336f3a84102882be85cae8f04
zhuyoujun/DSUP
/nextGreater.py
1,268
4.21875
4
##http://www.geeksforgeeks.org/next-greater-element/ ##Given an array, print the Next Greater Element (NGE) for every element. ##The Next greater Element for an element x is the first greater element on the right side of x in array. ##Elements for which no greater element exist, consider next greater element as -1. ## ...
true
38b7b604deeff14c459663458ffdef9ab238b5f2
zhuyoujun/DSUP
/priorityq.py
1,973
4.21875
4
#------------------------------------------ #Book:Data Structures and Algorithms Using Python #Author:zhuyoujun #Date:20150118 #Chapter8: Queue Structure #------------------------------------------ #Implements the PriorityQueue ADT using Python list #using the tial of list as Queue back #the head of list as Queue front...
true
2cacb006786cff997765ba342ccd065f34646e81
zhuyoujun/DSUP
/vector_test.py
776
4.125
4
#------------------------------------------ #Book:Data Structures and Algorithms Using Python #Author:zhuyoujun #Date:20150101 #Chapter2: Programing Projects2.1, Vector ADT using Array class. #Test module #------------------------------------------ from vector import Vector Vect = Vector() print Vect ##for i in range(...
true
86c537414652905b52bb7310264d6e9aaf38f3be
rifqirianputra/RandomPractice
/Day 2.py
1,766
4.5
4
# exercise source: https://www.w3resource.com/python-exercises/python-basic-exercises.php # circle calculator with math.pi function import math loopcontrol = 0 while loopcontrol != 1: menuinput = input('please enter the unit to calculate the circle \n [1] Radius || [2] Diameter || [0] to exit program\n your input...
true
0e3d2dab80931668d9f27e42039ae83ca9cddd84
AdamSierzan/Learn-to-code-in-Python-3-basics
/Exercises/names_if_dict.py
713
4.34375
4
names = { "Adam" : "male", "Tom" : "male", "Jack" : "male", "Tim" : "male", "Jenny" : "female", "Mary" : "female", "Tina" : "female", "Juliet" : "female" } name = input("Type your name: ") if (name) in (names.keys()): print("Seems like we have your name on the list.") print("And its a: ", names[name], "n...
true
dd900dc5664677077bc37a0528d4163f7aa0d662
AdamSierzan/Learn-to-code-in-Python-3-basics
/Exercises/If_ex.py
232
4.1875
4
age = int(input("Enter your age:")) if age < 18: print("User is under 18, he will be 18 in:", 18- age, "year") elif age >= 18 and age < 100: print("User is 18 or over 18") elif age > 100: print("I wish you 200 years!")
true
b022e908ed5af3394d37eec7fb5b6cd453aef941
AdamSierzan/Learn-to-code-in-Python-3-basics
/2. Python_data_types/9.1.2 Data_types_Boleans.py
986
4.1875
4
#let's put to variables num1 = float(input("type the first number:")) num2 = float(input("type the second number:")) #now we can use the if statement, we do it like this # if (num1 > num2) #in the parentesis it is expecting the true or false valuable, in most programming languages we use curly braces, # and everythin...
true
984eaa43e73488048b7d64f0a311850d7c2f2968
AdamSierzan/Learn-to-code-in-Python-3-basics
/Exercises/tv_series_recommendation.py
678
4.28125
4
print("Hi, whis programe will let you know what rate (0-10)," "has the tv series you want to watch:") series = { "Friends": 9, "How I met your mother": 8, "Big Bang Theory": 5, "IT:Crowd": 7, "The Office": 7 } print(list(series.keys())) print('-------------------------') name...
true
bcaa979906f3f191865511d4d376adb57a2f552b
AdamSierzan/Learn-to-code-in-Python-3-basics
/2. Python_data_types/7.1.1 Data_types_lists_tupels ex1.py
550
4.34375
4
print("Hi this programme will generate your birth month when you eneter it") months = ("January", "February", "March", "April", "June" , "July", "August", "September", "October", "November", "December") birthday = input("Type your date of birth in the formay: DD-MM-YYYY: ") print(birthday) month = birthday[3:5] print(...
true
454dfc773bae0babd4a0dbaeea39201aeb0f22d0
brendanwelzien/data-structures-and-algorithms
/python/code_challenges/insertion-sort/insertion_sort.py
658
4.15625
4
def insert_sort(list): for index in range(1, len(list)): index_position = index temporary_position = list[index] while index_position > 0 and temporary_position < list[index_position - 1]: # comparing 8 and 4 for example list[index_position] = list[index_position - 1] ...
true
dc3c3ffbf7cc974b0ae38f962a9ed6558ad5b737
myronschippers/training-track-python
/sequences/groceries.py
1,122
4.625
5
# All sequences are iterable they can be looped over sequences are no exception # For in Loop - a way to perform an action on every item in a sequence my_name = 'Myron' for letter in my_name: print(letter) print('\n==========\n') # groceries list was provided groceries = ['roast beef', 'cucumbers', 'lettuce', 'pe...
true
40718d2720654b50421a64233f0d18586e1c1c0e
myronschippers/training-track-python
/sequences/ranges.py
666
4.25
4
# testing out a range what if we wanted something that would loop 10 times #for i in 10: # print(i) # getting an error because an int is not iterable # start - the index the range starts at # stop - the index the range stops at # step - how much the index increases as iterated through # Range[ start, stop, step ] f...
true
d7f8216f8516f963aa7fcd797e2ae89c2a4e7d0f
taraj-shah/search_engine
/test.py
1,274
4.5
4
from tkinter import * #*********************************** #Creates an instance of the class tkinter.Tk. #This creates what is called the "root" window. By conventon, #the root window in Tkinter is usually called "root", #but you are free to call it by any other name. root = Tk() root.title('how to get text from tex...
true
cc0b1afd1e25acf5dafab63df5eec04009c0f6a5
subsid/sandbox
/algos/sliding_window/length_of_longest_substring.py
1,062
4.15625
4
# Given a string with lowercase letters only, if you are allowed to replace no more than ‘k’ letters with any letter, find the length of the longest substring having the same letters after replacement. def length_of_longest_substring(input_str, k): max_length = 0 start = 0 freq_map = {} max_repeat = 0...
true
c709f0e7f1bc08922bd4000fb3074b02be085a59
Acidcreature/05-Python-Programming
/homeclasswork/cool things/mapdemo.py
585
4.34375
4
# Map() function # calls the spcified function and applies it to each item of an iterable def square(x): return x*x numbers = [1, 2, 3, 4, 5] #sqrList = map(square, numbers) #print(next(sqrList)) #print(next(sqrList)) #print(next(sqrList)) #print(next(sqrList)) #print(next(sqrList)) #print(next(sqrList)) sqrList...
true
943dbe1b3380ef4f2ab81fcf6f42598716ac9680
Acidcreature/05-Python-Programming
/homeclasswork/liststupes/listtup_lottonums.py
464
4.15625
4
""" 2. Lottery Number Generator Design a program that generates a seven-digit lottery number. The program should generate seven random numbers, each in the range of 0 through 9, and assign each number to a list element. Then write another loop that displays the contents of the list.""" import random def lotto(): ...
true
8b7699247d59c50d1edf6ae82a9a53301c2672da
Acidcreature/05-Python-Programming
/homeclasswork/classes/gcd.py
533
4.15625
4
# This program uses recursion to find the GCD of two numbers # if x can be evenly divded by y, then gcd(x, y) = y # otherwise, gcd(x, y) = gcd(y, remainder of x/y) def main(): # get two numbers num1 = int(input("Enter a number: ")) num2 = int(input("Enter another number: ")) # Display GCD print(...
true
09dbe5ba46289d391aa26da317deff7195c05e3b
vadvag/ExercisesEmpireOfCode
/006.TwoMonkeys.py
555
4.125
4
""" Two Monkeys We have two monkeys, a and b, and the parameters asmile and bsmile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return True if we are in trouble. Input: Two arguments as numbers. Output: Maximum of two. Example: two_monkeys(True, True) ==...
true
e36c46ded18f40dbe940089f78e4cd608afe7b3e
vadvag/ExercisesEmpireOfCode
/003.IndexPower.py
1,165
4.46875
4
""" Index Power Each level of the mine requires energy in exponential quantities for each device. Hmm, how to calculate this? You are given an array with positive numbers and a number N. You should find the N-th power of the element in the array with the index N. If N is outside of the array, then return -1. Don't fo...
true
4f25e52640eb346576c425032996b0210d791b99
achinthagunasekara/sorting_algorithms
/selection_sort/sort.py
1,751
4.34375
4
""" Implementation of selection sort algorithm """ def selection_sort_same_list(list_to_sort): """ Sort a list using selection sort algorithm (using the same list). Args: list_to_sort (list): Unsorted list to sort. Returns: list: Sorted list. """ for outter_index, outter_element...
true
23b3786f6577a88d872e32f63670d28c68d4db8c
debasis-pattanaik-au16/Python
/Hackerrank/pangrams.py
1,214
4.25
4
# Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence # “The quick brown fox jumps over the lazy dog” repeatedly, because it is a pangram. # (Pangrams are sentences constructed by using every letter of the alphabet at least once.) # After typing the sent...
true
151b5af60bca9ea7c60b154e49ed077cd552f989
debasis-pattanaik-au16/Python
/Hackerrank/Mod Divmod.py
524
4.125
4
# Read in two integers, and , and print three lines. # The first line is the integer division (While using Python2 remember to import division from __future__). # The second line is the result of the modulo operator: . # The third line prints the divmod of and # . # Input Format # The first line contains the first ...
true
7299e28fbf3cc036c84670036241455f45605a2b
ravigupta19/Algorithm
/RecurisveFactorial.py
241
4.25
4
fact_num = input("Enter the num for which you want calculate the factorial") def factorial(n): if n == 1: return 1 else: return n * factorial(n-1) res = factorial(int(fact_num)) print("Your Results is :" +str(res))
true
bb26a151b8f6f68371a86735dacf74aca87cfda4
resullar-vince/fsr
/python/py-quiz-refactor-1.py
1,212
4.375
4
# Task: # - Create a feature that can display and calculate volumes of 3D shapes (cube, sphere, etc.) # # As a Final Reviewer, you should be able to: # Comment, review and/or refactor the code below. import math class Cube: def __init__(self, side): self.side = side self.name = "Cube" class Spher...
true
1cfc0783013a88df0bdd29d6def431a38728b8ea
wfoody/LearningPython
/day4_Largest-Element.py
432
4.3125
4
# Finding the largest element numbers = [384, 84, 489, 2347, 47, 94] numbers.sort() print(numbers[-1]) #alternative arg1 = max(numbers) print(arg1) print(max(numbers)) #2nd_alternative def find_largest(numbers): largestSeen = numbers[0] for x in numbers: if x > largestSeen: ...
true
3d3d4582c2af150e87583374eca95da34f353165
wfoody/LearningPython
/WeekendAssignment/todo_list.py
1,275
4.59375
5
""" TODO: Functions: - Present user with menu - take in input - add task - take additional input - actually add the task to the todo list - delete task - take additional input - show all tasks """ tasks = [] choice = input("Press 1 to add task.\nPress 2 to delete task.\nPr...
true
de733d1e71fbb6b34a2b130274ea49825b435747
NiteshPidiparars/python-practice
/HCFORGCDOfTwoNumbers.py
730
4.15625
4
''' Calculation of HCF Using Python: In this video, we will learn to find the GCD of two numbers using Python. Python Program to Find HCF or GCD is asked very often in the exams and we will take this up in todays video! Highest Common Factor or Greatest Common Divisor of two or more integers when at least one of them ...
true
36eb39d005f9a1fa4edd4f1ad38644c9eed42e1c
jicuss/learning_examples
/fibonacci/fibonacci.py
990
4.34375
4
# First, calculate the fibonacci sequence by using a loop def fibonacci_loop(number): ''' all fibonacci elements where element is <= n ''' results = [] first_element = 0 second_element = 0 # for element in range(0,number + 1): while True: sum = (first_element + second_element) ...
true
46cad0caed62396f91d5cdb32103c2083cbfc5c4
jicuss/learning_examples
/string_manipulation/string_rotation.py
1,089
4.28125
4
''' Original Source: Cracking the Coding Interview Question: Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call eg. waterbottle is a rotation of erbottlewat ''' import unittest import ...
true
10aff88a25874189ecc11da916a2f7ae505ef00f
Devinwon/master
/computer-science-and-python-programing-edX/week6/code_ProblemSet6/test.py
1,422
4.6875
5
def buildCoder(shift): """ Returns a dict that can apply a Caesar cipher to a letter. The cipher is defined by the shift value. Ignores non-letter characters like punctuation, numbers and spaces. shift: 0 <= int < 26 returns: dict """ ### TODO. # return "Not yet implemented." # Remo...
true
50c63296729e3177fa2042237ec1a28c41d05e6b
Devinwon/master
/coding-exercise/hankerRank/algorithm/warmup/simply-array-sum.py
1,126
4.40625
4
""" Given an array of integers, find the sum of its elements. Function Description Complete the function which is described by the below function signature. integer simpleArraySum(integer n, integer_array ar) { # Return the sum of all array elements } n: Integer denoting number of array elements ar: Integer a...
true
19c1f863c8589b384decbc7af986d0795856346f
Devinwon/master
/python-language-programing-BIT/Pythonlan06/W6_dict.py
1,071
4.1875
4
dict={'name':'abc','pwd':'123'} #define dict print('print the dict:',dict,sep='') print('search the name key:'+dict['name']) #visit key-'name' print('Now append status-off to dict') dict['status']='off' #append key-value print('Newer dict:',end='') print(dict) #list operation in dict ...
true
3457ee16db0574eb3046500464a45197f40ffc0c
shobhadoiphode42/python-essentials
/day4Assignment.py
460
4.59375
5
#!/usr/bin/env python # coding: utf-8 # In[2]: str1 = "What we think we become; we are a python programmer" sub = "we" print("The original string is : " + str1) print("The substring to find : " + sub) res = [i for i in range(len(str1)) if str1.startswith(sub, i)] print("The start indices of the substrings ar...
true
c583cd8c5cd420858133243bda87eb1186e133da
BChris98/AdvancedPython2BA-Labo1
/utils.py
1,522
4.375
4
# utils.py # Math library # Author: Sébastien Combéfis # Version: February 8, 2018 from math import sqrt def fact(n): """Computes the factorial of a natural number. Pre: - Post: Returns the factorial of 'n'. Throws: ValueError if n < 0 """ result = 1 for x in range (1,n+1): ...
true
e41f57732472cb40248e2a2e573a9ddac4574c27
zurgis/codewars
/python/7kyu/7kyu - List of all Rationals.py
1,707
4.40625
4
# Here's a way to construct a list containing every positive rational number: # Build a binary tree where each node is a rational and the root is 1/1, with the following rules for creating the nodes below: # The value of the left-hand node below a/b is a/a+b # The value of the right-hand node below a/b is a+b/b # So ...
true
752f757361c65f5c37ee549bb2cd50fe0b5b637c
zurgis/codewars
/python/7kyu/7kyu - Integer Difference.py
645
4.125
4
# Write a function that accepts two arguments: an array/list of integers and another integer (n). # Determine the number of times where two integers in the array have a difference of n. # For example: # [1, 1, 5, 6, 9, 16, 27], n=4 --> 3 # (1,5), (1,5), (5,9) # [1, 1, 3, 3], n=2 --> 4 # (1,3), (1,3)...
true
e846b57528f0bf301274935b7465dba6098478b5
adamhowe/variables
/Revision exercise 3.py
396
4.1875
4
#Adam Howe #16/09/2014 #Revision Exercise 3 first_number = int(input("Enter your first number: ")) second_number = int(input("Enter your second number: ")) answer_one = first_number / second_number answer_two = first_number % second_number # the % symbol will give the remainder of the two number divided toge...
true
2b4a979722711ce0c8813687baae135f77719c87
nerbertb/learning_python
/open-weather.py
1,273
4.28125
4
import requests open_api_key = "<Enter the provided key here from Open Weather>" city = input("Enter the city you like to check the forecast: ") #Ask the user what city he like to check the forecast url = "http://api.openweathermap.org/data/2.5/weather?q="+city+"&appid="+open_api_key+"&units=imperial" #will call th...
true
53c71e55746207c5be76bb6a67d01e08e59e7b5b
emGit/python100
/p19/race.py
977
4.21875
4
import random from turtle import Screen, Turtle screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(title="Make your bet", prompt="Which turtle will win the race? Enter a color: ") colors = ["red", "orange", "yellow", "green", "blue", "purple"] y_positions = [-70, -40, -10, 20, 50, 80] al...
true
eecab9761bd76ad15c4856b960dc8bcbf9618759
2caser/CapstoneSoHo
/Capstone_SoHo/script.py
2,842
4.1875
4
from trie import Trie from data import * from welcome import * from hashmap import HashMap from linkedlist import LinkedList ### Printing the Welcome Message print_welcome() ### Write code to insert food types into a data structure here. The data is in data.py t = Trie() for word in types: t.insert(word) ### Wri...
true