blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
fe1bc619dccda578cd13132e8fd25f36e98a106e
loosla/test_tasks
/test_tasks/search_insert_position_sorted_arr.py
983
4.1875
4
# Given a sorted array of distinct integers and a target value, # return the index if the target is found. # If not, return the index where it would be if it were inserted in order. # Code to check in main.py # nums = [1,3,5] # print(search_insert_position_sorted_arr(nums, 4)) def search_insert_position_sorted_arr(nu...
true
6f30a37168be382f6f8fe541ab1dc9d86d130448
lilnop/pythonguess
/Guesser 2.0.py
616
4.15625
4
import random n = random.randint(1, 30) count = 10 print("Guess a random number from 1 to 30, you have 10 tries.") while count > 0: guess = int(input("\nEnter an integer from 1 to 30: ")) if (guess == n): print("You guessed the number correctly!") break elif (guess > n): ...
true
c85269ae77a9e9a97a925c894531661addcd1623
1996hitesh/Pyhton-Problems
/Data Structures/List/program_4.py
346
4.15625
4
# Write a program to print the number of occurrences of a specified element in a list. def countX(lst, x): return lst.count(x) lst = [10,15,2,1,2,3,10,5,9,8,8] #defining the list x = int(input("Enter the element to check the occurenece : ")) result = countX(lst,x) print("Element {} occured in list {} ...
true
fd583e82077bf22717b8a70766639ec63d2de8d4
1996hitesh/Pyhton-Problems
/Data Structures/Tuple/problem_1.py
250
4.15625
4
# Write a program to print the 4th element from first #and 4th element from last in a tuple. t_1 = (1,2,3,4,5,6,7,8,9,10) #initializing a tuple print("4th element from the front = ",t_1[3]) print("4th element from the back = ",t_1[-4])
true
543d2750ed615de9d5c296925efd8d180b25ae63
1996hitesh/Pyhton-Problems
/Function/program_3.py
237
4.28125
4
#Write a function to calculate and return the factorial of a number #(a non-negative integer). def fact(n): if n == 1: return 1 f = n*fact(n-1) return f n = int(input("Enter number: ")) res = fact(n) print(res)
true
3fcaf8d563c66c0a4038e8ace50cb5e71aaac780
shiva-marupakula/Student-Management-System
/src/main/webapp/python/unit1/palindrome.py
252
4.25
4
#to check whether given number is or palindrome not. n=int(input("enter any number")) s=0 temp=n while(n!=0): r=n%10 s=(s*10)+r n=n//10 print(s,'is reverse of num') if(temp==s): print('number is palindrome') else: print('number is not palindrom')
true
bf47d0e783970d89a5afcb14aeaa9ed36fd8e083
shiva-marupakula/Student-Management-System
/src/main/webapp/python/unit2/B171081/tupleass15.py
224
4.25
4
#Python program to count the elements in a list until an element is a tuple. mytuple=(11,12,23,34,(1,2,3,45),4) c=0 for i in mytuple: if(type(i)==tuple): print('sum is ',sum(i)) break else: c=c+1 print('count is',c)
true
a2089fa6465cba82302ebd5cb1a8eb4d3e0df124
shiva-marupakula/Student-Management-System
/src/main/webapp/python/unit2/B171081/tupleass6.py
288
4.4375
4
#a Python program to find the repeated items of a tuple mytuple=(1,2,3,4,5,6,7,8,9,0,11,111,111,1111,1111) new_tuple=[] for i in mytuple: if i not in new_tuple: if(mytuple.count(i)>1): new_tuple.append(i) duplicate_tuple=tuple(new_tuple) print("repeated items are",duplicate_tuple)
true
b6e5fb0255b58c6c6303b5003aa5b171469318cb
shiva-marupakula/Student-Management-System
/src/main/webapp/python/unit1/factorial.py
265
4.34375
4
#to print factorial of given number n=int(input('enter any number')) fact=1 if(n<0): print('please enter positive values only') elif(n==0): print('factorial of 0 is 1') else: for i in range(1,n+1): fact=fact*i print('factorial of {} is {}'.format(n,fact))
true
b1453285fd2613919ae320a09f44672d1d648a57
2727-ask/LinkCode-Projects
/secondmaximuminarray.py
355
4.125
4
print("Hello World") arr = [] n = int(input("Enter Number of Elements in array")) for i in range(n): no = int(input("Enter Number")) arr.append(no) first = 0 second = 0 for x in arr: if(first<x): second = first first = x elif(second<x and x!=first): second = x print('Second Lar...
true
a58e6f56ce415e844e76d9dd3d0732a92ef89298
jmurraymcguirk17/5th-year-work
/emailchallenge.py
238
4.15625
4
firstname = input("Enter your first name") surname = input ("What is your surname") year = int(input("What year is it")) if year > 2000: print(firstname,surname,year-2000) elif year < 2000 >1900: print(firstname,surname,year-1900)
true
68382aefca50ef21e0ae0f06c9cf1b7a8361ff27
jasminenoack/learning-python
/merge.py
756
4.1875
4
def merge_sort(array): if len(array) == 1: return array middle_index = len(array)/2 left = array[0:middle_index] right = array[middle_index:] sorted_left = merge_sort(left) sorted_right = merge_sort(right) return merge(sorted_left, sorted_right) def merge(array1, array2): so...
true
173f34c3cfcc5a29a21e0ffbd6def363aaed77fd
symonsajib/PracticePython_P
/Exercise25_Guessing Game Two.py
238
4.15625
4
Number = float(input("What's your number: ")) Modulus = Number%2 Modulus_four = Number%4 if Modulus == 0: print("Even Number.") if Modulus_four == 0: print("It's also multiple of 4 !!") else: print("Odd")
true
bcaf20607f98fe03bfcb2cf8b3d90fc26a2783bd
symonsajib/PracticePython_P
/Exercise11_PrimeNumber.py
445
4.25
4
def get_the_interger(): return int(input("Enter the number: ")) Number = get_the_interger() list_divisors = [] for elements in range(1,Number+1): if Number % elements == 0: list_divisors.append(elements) else: pass print("Divisors of the numbers are " + str(list_divisors) + ...
true
4f3ca1a47bf783d1e68fcd57710500a62285bd40
vaibhavpalve1234/hackerrank
/type.py
985
4.125
4
#Write the calculator program which will take input from users two numbers #And will ask them to type #0 for addition #1 for subtraction #2 for multiplication #3 for division #And will print the result a=int(input('enter a nu.')) b=int(input('enter 2nd nu.')) print(a+b) print(a-b) print(a*b) print(a/b) print(a//b) ...
true
cdfb7239ccd0755aee27e5228150a948f45f0424
jyanar/Projects
/numbers/numbernames.py
2,337
4.28125
4
""" Number Names Show how to spell out a number in English. You can use a preexisting implementation or roll your own, but you should support inputs up to at least one million (or the maximum value of your language's default bounded integer type, if that's less). To implement this, we split the given number n into...
true
ced554a51c935cbef183f59a720b7ecc898ac58a
icculp/holbertonschool-machine_learning
/math/0x05-advanced_linear_algebra/1-minor.py
2,532
4.3125
4
#!/usr/bin/env python3 """ Advanced Linear Algebra not allowed to im-port any module must be done by hand! """ def determinant(matrix): """ Calculates the determinant of a matrix matrix is a square list of lists whose determinant should be calculated Returns: the determinant of matrix...
true
a075f1a2eca8e525028e2cb5b300e25a55b38af2
PacktPublishing/Python-Object-Oriented-Programming-Cookbook
/Chapter05/C05R01_SimpleStacks.py
2,670
4.34375
4
#!/usr/bin/env python """ The complete code of Ch. 5, Recipe 1 -- Implementing a simple stack """ from random import randint def print_line( leader:str, line:(str,None)=None, indent:int=0, body_start:int=28 ) -> str: """ Prints a formatted line of text, with a dot-leader between the lead and the line s...
true
38842b4b522c256d5f230772204f9c8250047b45
Ivaylo2017/hello-world
/ceasar_cypher.py
2,251
4.125
4
''' The program encrypts messages using Ceasar cypher with key length specified by the user When the same key with opposite sign is used it can decrypt messages as well. Ceaser cypher is the simplest and oldest known transpositional cypher. It adds the key to the numerical representation of each character in the origi...
true
9fd7f6f332033e08d34422b92397fa5cd23a9a89
saxena-rishabh/Python-OOP
/Level 1 - Exercise 3.py
642
4.59375
5
''' Exercise 3: Write a Python program to implement the class chosen with its attributes. Also, represent Jack and Jill as objects of the class chosen initialize their attributes and display their details Create a parameterless constructor in which create the attributes with None Note: Verification is done only for cla...
true
f801399f7fdd5176190ff14168a874b1ea62e34d
realThinhIT/python-bootcamp
/chapter-3/exercise-calculator.py
595
4.125
4
""" CALCULATOR PROGRAM """ print("CALCULATOR PROGRAM") firstNumber = int(input("Input a = ")); operator = input("Please choose your operator (+, -, *, /): "); secondNumber = int(input("Input b = ")); result = None if operator == '+': result = firstNumber + secondNumber elif operator == '-': result = firstNum...
true
90f1a5864f55bd21a75bb4532a23937add253431
hschoi1/TIL
/misc/unittest_example.py
1,897
4.15625
4
# examples from https://docs.python.org/3/library/unittest.html import unittest """ TestCase class provides assert methods to check for and report failures some include: assertEqual(a,b) assertNotEqual(a,b) assertTrue(x) assertFalse(x) assertIs(a,b) assertIsNot(a,b) assertIsNone(x) assertIsNotNone(x) assertIn(a,b) as...
true
86d935c563bf8d580847d647efe02cc5a5a01a57
felix-ogutu/PYTHON-PROJECTS
/Hostel Management System/menu.py
552
4.15625
4
def menu(): print("[1] Option 1") print("[2] Option 2") print("[0] Exit the program") menu() option = int(input("Enter the option:")) while option != 0: if option == 1: print("Option 1 has been selected") elif option == 2: print("Option 2 has been sele...
true
eb46cac051f275833b757b020dca6d78bbdde959
AmitCodes/PythonProgramming
/5_4_Son_Father_Grandfather.py
1,738
4.375
4
# Here we need to store name of son's father and grandfather. # Using tha name of the son, one should be able to access father and grafather #Notify the user for the options available print("Enter one of the below choices to proceed further") print("1 - Insert new data" , "2 - Get the data" , "3 - Delete the data...
true
66b475b2d036cf23e329b107a534a3296ee73792
sean-blessing/100-doc-python
/sec-018/day-18-167-turtle-draw-shapes/main.py
748
4.40625
4
from turtle import Turtle, Screen import random timmy_the_turtle = Turtle() timmy_the_turtle.shape("turtle") colors = ["blue", "red", "black", "green", "orange", "pink", "purple", "indigo", "yellow", "cyan"] #draw some shapes # 360 degrees / # of sides # 3 sided shape to 10 sided shape # each side is 100 length #-tri...
true
f8a9f7ec2b6b30d19619c57cf411c578d4035fb1
floryken/Ch.04_Conditionals
/4.1_Number_Analysis.py
853
4.46875
4
''' NUMBER ANALYSIS PROGRAM ----------------------- Create a program that asks the user for a number and then analyzes it to determine if it is: 1.) odd or even 2.) positive, negative or zero 3.) inclusively between -100 and +100 A small report will then be printed. Use the following to test your program: In: 32 Ou...
true
805024ff3e4b9263f9c6b6ca24695450a7cf40b2
KenlyBerkowitz/casino
/Bank.py
2,913
4.125
4
################## ### Bank Class ### ################## class Bank: def __init__(self): self.balance = 0 # private variable self.fundsAdded = 0 # used to determine how much you made # adds money to the account def addFunds(self): if self.balance == 0: prin...
true
80fe136af56238956d99e1dabaa903601ae813ec
mgstabrani/code-test-eduka
/no1.py
513
4.1875
4
#Function to decide whether a number is palindrom def isPalindrom(number): #Set a variable palindrom True palindrom = True #Convert integer to string strNumber = str(number) #Check palindrom for i in range(len(strNumber)): palindrom = palindrom and (strNumber[i] == strNumber[len(strNum...
true
cf045d1e702e00c99a257621ce6ec7e10a7b31ba
CodingDojoDallas/python_aug_2018
/Sujata Singhal/FLASK/Hello Flask/sujata.py
1,668
4.15625
4
from flask import Flask # Import Flask to allow us to create our app. app = Flask(__name__) # Global variable __name__ tells Flask whether or not we are running the file # directly, or importing it as a module. print(__name__) # Just for fun, print __name__ to see what it is @app.r...
true
98f6598f62bdacb9f120ce2c5c280718bd6615dd
pauloALuis/LP
/SeriesDeProblemas2/pb1.py
1,873
4.4375
4
#!/usr/bin/env python3 """ Avaliação 1 pb1.py 18/08/2021 """ import random #1.a) def l1(n: int = 10, l: list = []): """ method that creates a list with random numbers "n" times @param n: number of the length of the list @param l: list to append @return list with "n" random integer numbers between...
true
1f9dedc88f9c292126d67103e60ed74c422874a7
pauloALuis/LP
/SeriesDeProblemas1/questaoteste.py
1,721
4.28125
4
""" questão teste 18/08/2021 """ import math #1) def string_vocals(s: str): """ calculates the index of first and last vocal in a string @param s : the string given @return the tuple with indexes of first and last vocals in the string s """ first_checked = False vocals = ["a", "e", "i", "o...
true
640ca6298b2fc5da9d2259017c0ec2ab06555370
prerakpatelca/related-arrays-numpy
/Assignment1A.py
2,809
4.15625
4
"""This assignment uses Python lists and sets along with related arrays in numpy. This program gets the input from the user for 5 player names and then stores it in a Python sets from which it randomly selects the users name asks that player to enter 10 times quickly, where program stores the time difference between th...
true
a497d60feb752d5e367244971f7177d4f3598609
wwtang/code02
/in.py
578
4.34375
4
""" Inheritance with class and instance variable""" class P: """ base class""" #class variable z = "hello" def set_p(self): self.x = "class P" def print_p(self): print(self.x) class C(P): def set_c(self): self.x = "class C" def print_c(self): print(self.x) ...
true
d0718ae9939fd63b10d1d2707d5d6acd5f15a418
wwtang/code02
/greatheapsort.py
1,495
4.5
4
"""great heap sort functions used in heap sort: max_heapfy build a heap heap is a array, the essential algorithm here is the realtion between different elements """ def max_heapfy(array, k, last):#heapfy works among three elenment left = 2*k +1 right = 2*k +2 # find the largest element in the unit heap ...
true
11a9d0967867991f1693902b588629022b633a99
wwtang/code02
/sortAlgorithm/insertsort.py
675
4.1875
4
def insert_sort(list2):#compare the current element with its prior element, if smaller, insert it at the left of them for i in range(1,len(list2)):#begin from the second element save = list2[i] # save the current elem, use to compare with its prior elements j = i# j here used as helper index ...
true
c5c18b8138ca983cb10130d8cd6945e99ff1310e
wwtang/code02
/craking/106.py
1,559
4.125
4
""" write a method to find a given number in double sorted matrix arr = [[15, 20, 40,85],[20,35,80,95],[30,55,95,105],[40,80,100,120]] find 55 method 1: apply binary search to each row """ def binarySearch(arr, target, first ,last): if last < first or len(arr) <0 or target == None: return None mid = (first + l...
true
de78d0235a44e0733bd4c7ff50fd71cbc09a75fc
wwtang/code02
/insert_sort.py
985
4.21875
4
#used for heap sort def max_heapfy(array, k, last): left = 2*k +1 right = 2*k +2 if left<= last and array[left] > array[k]: largest = left else: largest = k if right <=last and array[right] > array[largest]: largest = right if largest != k: max_heapfy(array, largest, la...
true
91f6f93546e8240aff32445f1e68c11ccfe19d83
wwtang/code02
/tem.py
214
4.25
4
color = raw_input('please select the color: ') if color == "white" or color == "black": print "the color was black or white" elif color > "k" : print "the color start with letter after the 'K' in alphabet"
true
74bcfc187e93a5400fc008128e2ada59e97a3c83
wwtang/code02
/fibcache.py
872
4.125
4
"""fibonacci numbers: cache the intermediate result""" import time #Cached method def fib1(n): cache_dict = {0:0,1:1} if n == 0: return 0 if n == 1: return 1 if n in cache_dict: return cache_dict[n] cache_dict[n] = fib1(n-1) + fib1(n-2) return cache_dict[n] #Non Cached method def fib...
true
b00ca8a133d0893365e9f5a26683e0475ea0d508
wwtang/code02
/findparentheses.py
2,691
4.21875
4
"""find all the valid parentheses input: number of pairs of parentheses output : a list of valid parenthese, left and right are separated. each function implement the most basic functionality The first algorithm takes o(n!) n' factorial, which is the b """ # i is the index of the open parentthese # string is a list...
true
435e27045634d138b3a888b727cc4687c0209327
wwtang/code02
/spellchecker.py
1,093
4.15625
4
""" Exercise problem: "given a word list and a text file, spell check the contents of the text file and print all (unique) words which aren't found in the word list." """ #function to generate a dict according the words from the dict file def dict_list(filename): dict_list = [] f = open(filename) data = f.readline...
true
794f77df1b28dcac4af885f980e99619f0bec303
choidslab/PY4E
/ex_08/ex_08_02.py
312
4.125
4
filename = input("Enter a filename:") fhand = open(filename, 'rt') count = 0 words = list() for line in fhand: if line.startswith("From: "): count += 1 words.append(line.split()[1]) for word in words: print(word) print("There were", 27, "lines in the file with From as the first word")
true
17e59f50c4e02267a9347366ea0ca9e597cf01e1
13re/Python3_Assignments
/numberedlist.py
562
4.28125
4
# write a function that takes a list as an argument # and prints out all the values in the list along with the index # # Example: [apple, banana, organge] # #1 is apple # #2 is banana # # then try: # 1st element in the list is apple # 2nd element in the list is banana meals = ["breakfast", "lunch", "dinner", "dessert...
true
f389c062cc7cd2b7d391118158543ef2be6c6cce
ultranaut/mathematics
/arithmetic/addition.py
829
4.125
4
"""Addition These will only work for the natural numbers. """ from utils import * def naive_r(augend, addend): """A recursive definition of addition. (http://en.wikipedia.org/wiki/Addition#Natural_numbers) """ if addend == 0: return augend return inc(naive_r(augend, dec(addend))) # in...
true
c85ee6d80f2ef97c2e4dacd2455b1e225c1f980b
BrianBalayon/projecteuler
/problem1.py
713
4.5
4
''' Problem 1: Multiples of 3 and 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ''' def main(): threes = 0 fives = 0 for i in range(1, 1000): ''' ...
true
0423067280842795937912f7b95c98d7b162c217
becclest/206-repo
/lecture/Homework/ttt.py
2,962
4.3125
4
python ttt.py def generateBoard(board) #Generates 3 x 3 matrix of board that is passed # Uses a list of 9 strings print (' | | ') print ('' +board[6]+ ' | ' +board[7]+ ' | ' +board[8] ) print (' | | ') print ('-----------') print (' | | ') print ('' +board[3]+ ' | ...
true
73094afa611c90d92a0d9b4d4b99fd2f36b6dff0
DanielW1987/python-basics
/python_007_oop/Interfaces.py
1,501
4.25
4
from abc import abstractmethod, ABC # In Python, an interface is a class that has only abstract methods class Drivable(ABC): @abstractmethod def drive(self) -> None: pass class BMW(ABC, Drivable): def __int__(self, maker: str, model: str, year: int): self.__maker = maker self._...
true
7bd30bc15e44a0c2cb7bdf9d91d9e562e1553f1a
DanielW1987/python-basics
/python_exercises/GradingApplication.py
602
4.28125
4
mathsPoints: int = int(input("Enter the math points: ")) physicsPoints: int = int(input("Enter the physics points: ")) chemistryPoints: int = int(input("Enter the chemistry points: ")) if mathsPoints >= 35 and physicsPoints >= 35 and chemistryPoints >= 35: averageGrade: float = (mathsPoints + physicsPoints + chemi...
true
466c10fdd9a0e3a3cabf20b555ae91c5ae2f5589
Panda3D-public-projects-archive/pandacamp
/Handouts 2012/src/2-1 Reactive Programing/03-reactions.py
1,547
4.1875
4
from Panda import * # You attach a reaction to a model by giving the triggering event and the name of the reaction function. # exitScene is a built in reaction function # This tells the panda to exit the scene when the right mouse button is pressed (lbp). p = panda() p.react(rbp, exitScene) # This reaction func...
true
75f34c99889810056721f0c316918dcdc306a99a
Panda3D-public-projects-archive/pandacamp
/Handouts/src/3-1 Interpolation and Collections/03-interpolation.py
567
4.21875
4
# Vectors and interpolation/03-interpolation.py from Panda import * # How do you interpolate between two points? # If the panda is at p0 at t = 0 and p1 at t = 1, # what equation would make it move from p0 to p1 smoothly? # what happens when t is not between 0 and 1? # What if you want to make it arrive at p1 when t =...
true
2cb6f9a96a248fcce02372ea48612a112b8ee2c4
sean-attewell/Learn-Python-3-The-Hard-Way
/lpthw/ex14.py
1,174
4.4375
4
from sys import argv script, user_name, size = argv # Now if we want to make the prompt something else, we just change it in # this one spot and rerun the script. # We've used f-string to make the prompt to type tell you what the script # You're in is called and your username in brackets. Kind of like # Powersh...
true
fdbc64dde1460d7f79a084e65a74ab9f065b4394
sean-attewell/Learn-Python-3-The-Hard-Way
/lpthw/ex40_modules.py
1,683
4.59375
5
# Modules, Classes, and Objects # Dictionaries map one thing to another: mystuff = {'apple': "I AM APPLES!"} print(mystuff['apple']) # Keep this idea of get X from Y in your head, and now think about modules. # You import a Python file with some functions or variables in it # And you can access the function...
true
00bee0baa2e4c5cdca2eebeb157fd2b49bab4092
sean-attewell/Learn-Python-3-The-Hard-Way
/lpthw/ex9.py
1,224
4.40625
4
# Here's some strange stuff, remember to type it exactly days = "Mon Tue Wed Thu Fri Sat Sun" # So here \n makes the next bit start on a new line months = "Jan\nFeb\nMar\nApr\nMay\nJune\nJul\nAug" # It's an escape sequence. It's a way to add formatting in a way that # doesn't break python's processing of the...
true
e78e69c91f5758be66de6103a0c0fab40d55b386
sean-attewell/Learn-Python-3-The-Hard-Way
/lpthw/ex34.py
1,245
4.5
4
# 1st second third are ”ordinal” numbers, # because they indicate an ordering of things # A cardinal number is a number such as 1, 3, or 10 that tells you # how many things there are in a group but not what order they are in # Programmers, however, can’t think this way because they can pick any # element ou...
true
59506061fc7df6ca4e69329078ebb835bac30e49
Nishadansh47/LetsUpgrade-AI-ML
/Assignment_Day_7.py
1,004
4.15625
4
# --------------------------------------------Assignment Day 7 | 8th September 2020------------------------------------------------------- '''Question 1: Write a program to copy the contents of one file to another using a for loop.Do not use built-in copy function''' # Answer 1 ------------------ with open("in...
true
48da242ee3defd120775dd065626bcbbac7a0df6
rockyshc/Python
/simples/basic/the_Set.py
864
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # set like dict, it a group of key # But not store value # Since every key should be unique # There should be no duplicated key in set # need to provide a list for set generation s = set([1, 2, 3]) print('The set named s should be:', s) # auto filter duplicate key s = s...
true
5f2f3e9203e267ba40e8e21e3ebec6f228c91024
rockyshc/Python
/simples/function/keyW_Args.py
1,397
4.4375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Keyword argument can extend the function of argument def person(name, age, **keyWord): print('Name:', name, 'Age:', age, 'Other:', keyWord) person('Tom', 4) person('Jack', 7, gender = 'M', job = 'Engineer') # Define a dict first # Then change the dict to keyword e...
true
43b5c80a00fc4c799a2a7f621248d63ee3b63557
kamanazan/dailyprogrammer
/ch_137_e.py
1,641
4.3125
4
#challange 137 easy ''' http://www.reddit.com/r/dailyprogrammer/comments/1m1jam/081313_challenge_137_easy_string_transposition/ it can be helpful sometimes to rotate a string 90-degrees, like a big vertical "SALES" poster or your business name on vertical neon lights, like this image from Las Vegas. Your goal is to wri...
true
18a712e0599f6c7b83372330cc581a57cd011dfa
RainingWish/Python-Learning
/Day4/if.py
893
4.5
4
#input a birth year decide u are a adult, teenager or a kid #let user input theire birth year birth = input('Your birth year is:') #input function will save the number in string #in this case, we need change the string to intiger for comparing birth = int(birth) #calculate your age age = 2019-birth print ('your age is...
true
325ce962d7f6e3834c22b96693639673a1874adb
ukirderohit/2017Challenges
/challenge_13/python/ning/challenge_13.py
1,373
4.15625
4
def get_int_len(_int): '''Find the number of digits of an int Given an integer, finds the number of digits in that integer in base 10 ''' power = 1 while True: if _int == 0: return 0 elif _int < 10**power: return power power += 1 def check_palind...
true
326a09c5067545f2b79dbf9174057e243fe18e4c
amirlevis/varonis_interview_questions
/diagonal_square.py
1,246
4.625
5
# Python3 program to change value of # diagonal elements of a matrix to 0. # method to replace the diagonal # matrix with zeros def diagonalMat(row, col, m): # l is the left iterator which is # iterationg from 0 to col-1[4] here # k is the right iterator which is # iterating from col-1 to 0 i, l...
true
9a32d06c0a41912fffff2192c80ee11355249dc4
pushoo-sharma/Python_File
/Median.py
790
4.3125
4
def median(numbers): """" median, returns the median value of an input list. """ numbers.sort() #The sort method sorts a list directly, rather than returning a new sorted list if (len(numbers) % 2 == 0): middle_index = int(len(numbers)/2) - 1 next_middle_index = middle_i...
true
529f8e15895df08270a9d7ec4e46e8a713d57c6e
hrawson79/Algorithms
/LinkedLists/queue.py
1,266
4.21875
4
# Queue Class from LinkedLists.list_node import ListNode class Queue(object): # Constructor def __init__(self): self.front = None self.end = None self.size = 0 # Method to return the size of the queue def __len__(self): return self.size # Method to add item to the ...
true
10528e6cfd77dc9ca73a14d4dd782cd14c5e84d4
makshev1/Labs_IFMO
/1st_course/Informatics/2nd_Lab/src/lab_02_01.py
2,688
4.125
4
""" Условия """ # if..else num = int(input("How many times have you been to the Hermitage? ")) if num > 0: print("Wonderful!") print("I hope you liked this museum!") else: print("You should definitely visit the Hermitage!") # if..elif..else course = int(input("What is your course number?")) if ...
true
e38e2ea0882bfad0cee87d37bee63d4ab5d31225
srsagehorn/codeWars100Days
/1-10/day10.py
1,030
4.28125
4
# Removing Elements # 8kyu # https://www.codewars.com/kata/5769b3802ae6f8e4890009d2/train/python # Take an array and remove every second element out of that array. Always keep the first element and start removing with the next element. # Example: # my_list = ['Keep', 'Remove', 'Keep', 'Remove', 'Keep', ...] # None...
true
5f869ff770ba02b93d104ec7ba73d34f796a77cc
srsagehorn/codeWars100Days
/21-30/day24.py
1,474
4.1875
4
# Tip Calculator # 8kyu # https://www.codewars.com/kata/56598d8076ee7a0759000087/train/python # Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service. # You need to consider the following ratings: # Terrible: tip 0% # Poor: tip 5% # Good: tip 10% # Gre...
true
3a21182c743199db0d23d66bbeda1cdc20ed3d79
srsagehorn/codeWars100Days
/additional/squareEveryDigit.py
679
4.15625
4
# 7kyu # Square Every Digit # https://www.codewars.com/kata/546e2562b03326a88e000020/train/python # Welcome. In this kata, you are asked to square every digit of a number. # For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1. # Note: The function accepts an integer a...
true
86d7e77637626e81f6c65a704bc2dfa58c1a65f5
lukegriffith/CodeExamples
/Python/CBT Tutorials/ErrorHandling.py
667
4.1875
4
while True: try: print("Let us solve the equation (x/2) / (x-y) ") print("Please enter 0 to Exit") x = int(input("Please enter x: ")) y = int(input("Please enter y: ")) if x==0 or y==0: break z = (x/2) / (x-y) except ZeroDivisionError as e: print("There was an error with the code") print("Yo...
true
f1be1475fb0a88ae435b3c7d2db492fda162a2c6
lukegriffith/CodeExamples
/Python/CBT Tutorials/Dictionaries.py
509
4.59375
5
ages = {"Luke":23,"Jess":20,"Mark":47,"Caroline":47} print(ages) for age in ages: print('The age of',age,'is',ages[age]) ###This has to be done with dictionaries, as it doesn't have an order. You can get the value by specifying ages - the collection and [age] the key to get the value #.keys() is a function to get ...
true
30fd0bf10de116fc4b01eef59d24ff7936f454d0
KKosukeee/AlgorithmsMediumSeries
/classes/queue.py
1,290
4.5625
5
""" Implement a queue class here using LinkedList class """ from classes import LinkedList class Queue: """ Queue class implementation """ def __init__(self, node=None): """ Initialization method for a queue object Args: node: Node object as the first element in the ...
true
0422617d86c175c1e43463a5373bf367a27e804f
KKosukeee/AlgorithmsMediumSeries
/part7/quick_sort.py
2,575
4.25
4
""" This file contains a content for the part 7 of the data structures and algorithms series """ import numpy as np from classes import BigO from classes import Plotter def main(): """ Main function of this file. It runs a quick sort several times Returns: None: """ # Initialize quick sor...
true
d7e3706f50b7cdbca5875983c93577403065d79f
KKosukeee/AlgorithmsMediumSeries
/tests/classes_queue.py
2,255
4.25
4
""" Unit-test file for Queue object """ from unittest import TestCase from classes import Queue from classes import Node class TestQueue(TestCase): """ TestQueue object implementation """ def setUp(self): """ Setup method for unit-testing. This method will be called for each test case ...
true
ba5ed9d2618cad3f6e6a0f70578f9bab6521dfeb
abhishekthukaram/Course-python
/Practice-Problems/firstnonrepeatingcharacter.py
1,622
4.3125
4
""" Create a function that accepts a string as an argument and returns the first non-repeated character. Examples first_non_repeated_character("it was then the frothy word met the round night") "a" first_non_repeated_character("the quick brown fox jumps then quickly blows air") "f" first_non_repeated_character("g") "...
true
79f263ead3f75922dab8b43ed1dff388efa29105
abhishekthukaram/Course-python
/Practice-Set1/permutation-palindrome.py
1,156
4.1875
4
""" Write an efficient function that checks whether any permutation ↴ of an input string is a palindrome. ↴ """ def has_palindrome_permutation(the_string): result = {} count = 0 final_result = 0 if (len(the_string) == 0): return True for key in the_string: if key in result: ...
true
279b97085dbd7235566c62bde9c4761ef6e87e0e
abhishekthukaram/Course-python
/Strings/longestpalindromesubstring.py
612
4.21875
4
""" Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. """ def longestPalindrome(s): result = "" if len(s) ==1: result+=s elif len(s) ==2: if s == s[...
true
d162088f28ae906eac9636790590bf971e5ad407
rileytaylor/csc110
/4/ex1.py
1,737
4.3125
4
# Allison Obourn and Janalee O'Bagy # CSc 110, Spring 2017 # Lecture 9 # This program prompts two people for their CS1 and CS2 grades # computes their CS GPA and whether or not that GPA is # high enough (so far) to be a CS major. def main(): intro() gpa1 = get_person_info() gpa2 = get_person_info() ...
true
2dc1750c44de3d1d1f90d02bc706d7f72e81d9d4
drbubbles40-school/cse210-tc04
/hilo/game/dealer.py
2,645
4.15625
4
from game.player import Player class Dealer: """A class for the bot who directs the game. The responsibility of this class of objects is to keep track of the score and control the sequence of play. Attributes: keep_playing (boolean): Whether or not the player wants to keep playing. ...
true
2518577f4aaf1f00d75367b7b9f0f703e8a91d2a
shaheen19/dsp
/python/q8_parsing.py
1,137
4.34375
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program t...
true
372f0404e35f6394e2b72618a423a20ef74b92ef
wayne676/Python_Concurrency_Notes
/page55_thread_modulepy.py
1,441
4.125
4
import _thread as thread from math import sqrt def is_prime(x): if x < 2: print('%i is not a prime number.' % x) elif x == 2: print('%i is a prime number.' % x) elif x % 2 == 0: print('%i is not a prime number.' % x) else: limit = int(sqrt(x)) + 1 for i in range(3...
true
86002343dff37e4b3165263a4205593915751614
jieunyu0623/3522_A00998343
/Assignments/Assignment1/userType.py
944
4.15625
4
import abc from Assignments.Assignment1.users import Users class UserType(abc.ABC): """ UserType abstract class for three different user types. """ def __init__(self): """ constructs an user type object. """ pass @abc.abstractmethod def lock_account(self, use...
true
4790a6d2a36efc60b01acf00688dbe7ea27c8719
ethan5771/Ethans-Programming-Programs
/EthanMadLib.py
761
4.125
4
print ("Welcome to the mad lib project.") name = input("What is your name?") place = input("Name a place.") verb = input("Name a verb.") place_two = input("Name a different place.") noun = input("Name a noun.") name_two = input("What is another name?") print("%s went to %s to %s. The next day %s went to %s to get %s f...
true
bfa5b716adaadf7c02118e1811a3546af71e0242
llpj/coding_the_matrix
/WORK_DPB/matrix/The_Function.py
1,553
4.15625
4
# version code 778a5ea1ddbc+ # Please fill out this stencil and submit using the provided submission script. ## 1: Problem 0.8.3Tuple Sum def tuple_sum(A, B): ''' Input: -A: a list of tuples -B: a list of tuples Output: -list of pairs (x,y) in which the first element of the ith pair is the sum of t...
true
46d0eb250ee3ba2d29035d7ff0b34a75ec20febc
lounotlew/CS-61A-Spring-2015
/notes/trees.py
2,373
4.25
4
"""Trees""" """Slicing: creates a new list.""" lst = [1, 2, 3, 4, 5] sliced = lst[1:3] # includes index 1, excludes index 3. """ >>> sliced [2, 3] """ """Tree Functions""" def tree(root, branches=[]): for branch in branches: assert is_tree(branch), 'branches must be trees.' return [root] + list(branches) def ...
true
07dc3932efe8a630417374bb410f9581643e1829
lounotlew/CS-61A-Spring-2015
/notes/mutable_values.py
1,833
4.46875
4
"""Mutable Values""" """ Lists: Mutable values that can change in the course of a program. Only lists and dictionaries can change. """ """ Operations: - lst.pop(): removes the last element of a list and returns it. **add argument n to lst.pop() to remove nth index.** - lst.append(x): adds x to the end of a list. - ...
true
9f6ebe67bc4ffff12763624aaec64f6098b6a697
ro-mak/GeekbrainsPython
/lesson2/task3_2.py
554
4.1875
4
time_of_the_year_list = {(1, 2, 12): "winter", (3, 4, 5): "spring", (6, 7, 8): "summer", (9, 10, 11): "autumn"} while True: try: month = int(input("Input a month: ")) if month not in range(1, 13): raise Exception("Your number is out of range (1-12)") for el in time_of_the_year_li...
true
d6b3efe5a222ff24c0362f4e433a2a9db5712d63
PacktPublishing/IPython-7-Cookbook
/Chapter04/code/heapsort.py
761
4.28125
4
#thanks to https://rosettacode.org/wiki/Sorting_algorithms/Heapsort#Python def heapsort(lst): ''' Heapsort. Note: this function sorts in-place (it mutates the list). ''' # in pseudo-code, heapify only called once, so inline it here for start in range(int((len(lst)-2)/2), -1, -1): siftdown(lst, start, len(ls...
true
b69ecb102c3671c26b469df894b4433ec2ba119e
gokulvenkats/python-exercise
/scripts/list.py
2,147
4.1875
4
# Basic list exercises # Fill in the definitions for the required functions. The main functions and the testing # has been handled, so when you run a program, you will get an output of how many testcases # passed and how many didn't. # A. alphanum Score def alphanum_score(words): """ The function takes a list of wo...
true
ac8cbad6497bcf36a62f01c801d80920203e39dc
lphdev/python
/rps.py
2,679
4.40625
4
# Rock Paper Scissors from random import randint name = input("What is your name? ") print("\nHello %s! Welcome to the Rock, Paper, Scissors's game. \nRemember the rules: rock beats scissors; paper beats rock; scissors beats paper. \nYou have to accumulate three points to win the game. Let's play!" % (name)) player_s...
true
48175bfb53a63c722ae5d167a2027a8f8bd49ed0
qademo2015/CodeSamples
/Python/010_substring_occurrence.py
1,390
4.3125
4
###################################################################### # this file contains different implementations of finding index of # first sub-string occurrence within given string and returning -1 # in case if nothing found ###################################################################### # this function...
true
8ff7db5bb4e257a52984ee1c63976299b8927123
Michael-Wisniewski/algorithms-unlocked
/chapter 3/3_select_sort.py
1,323
4.1875
4
def sort(numbers, numbers_count): """Time complexity - Θ(n**2), memory consumption - O(n), replacements O(n). >>> numbers = [8, 6, 7, 4, 5, 2, 3, 1] >>> numbers_count = 8 >>> sort(numbers, numbers_count) [1, 2, 3, 4, 5, 6, 7, 8] """ for i in range(0, numbers_count - 1): index_of_m...
true
0de917ca9e6bd4b8d3f76bf24fec06eb3ec5eb93
Michael-Wisniewski/algorithms-unlocked
/chapter 4/2_count_equal_keys.py
1,046
4.21875
4
def count_equal_keys(A, n, m): """Time complexity: Θ(n) if m is constant, memory consumption - Θ(n). >>> numbers = [1, 0, 4, 2, 3, 0, 2, 0, 1] >>> numbers_count = 9 >>> max_number = 4 >>> count_equal_keys(numbers, numbers_count, max_number) [3, 2, 2, 1, 1] """ equal_keys = [0] * (m + 1...
true
80e38eaa81b52f0db759fb2fd862f65a14b24fe3
rexfordcode/codefights
/python/pressureGauges.py
574
4.15625
4
""" https://app.codesignal.com/arcade/python-arcade/drilling-the-lists/SkTfc263CQbGNMtoj Given the pressures Harry wrote down for each pipe, return two lists: the first one containing the minimum, and the second one containing the maximum pressure of each pipe during the day. Example For morning = [3, 5, 2, 6] and e...
true
31ca138ab4f6cd87443dd26e1b25e46bcb48dadb
sahadatsays/pythonStore
/PythonBasic/conditions.py
457
4.3125
4
age = 20 if age < 18: print("You are Teenager. Because Your age is under 18") else : print("You are Adult. Because Your age is upto 18 Years") #login and, or if age < 1: print("Under 1 years called Babby !") elif (age == 2) or (age > 18): print("Upto 2 years and Under 18 years, called teenage") elif...
true
de2f3d2d43d0ece3158754e9a71648be6a9119b2
jonathanthen/INFO1110-and-DATA1002-CodeDump
/xprime.py
1,276
4.21875
4
def modulus(num,divisor): if type(num) != int or type(divisor) != int: raise TypeError("Input(s) are not integers.") else: # Handle divisor equals to 0 case if (divisor == 0): return False n = num # Handle negative values if n < 0: ...
true
d4374f5d35f227735e3bebac6212115a60d6d259
tashachin/coding-challenges
/lemur.py
1,574
4.28125
4
def lemur(branches): """Return number of jumps needed.""" assert branches[0] == 0, "First branch must be alive" assert branches[-1] == 0, "Last branch must be alive" # given a bunch of 0s and 1s, i have to return the num of jumps it takes the lemur # to reach the last branch (last 0) # she ca...
true
44853bce4f2b354c083129ada61b9505eeabdf9a
tashachin/coding-challenges
/reverse-string-in-place.py
427
4.15625
4
def reverse(characters): """Reverses a list of characters in place. >>> "hello" "olleh" >>> "How are you?" "?uoy era woH" """ left_index = 0 right_index = len(characters) - 1 while left_index < right_index: characters[left_index], characters[right_index] = characters[rig...
true
093d482a93abbeab61e942dddf11d970eb2c90f9
tashachin/coding-challenges
/euler3.py
1,421
4.28125
4
""" 1. factor is a thingy that a num can be evenly divided by 2. a prime num is a num that can only be divided by 1 and itself!!!! 3. a prime factor is a thingy that a num can be evenly divided by, and that can only be divided by 1 and itself """ import math def find_prime_factors(num): """Returns a list of all t...
true
06e2b44f31d4b647be868d03b11a69421ae9f9cd
kevin-ss-kim/coding-problems
/linked_list/xor_linked_list.py
2,137
4.1875
4
''' An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev fields, it holds a field named both, which is an XOR of the next node and the previous node. Implement an XOR linked list; it has an add(element) which adds the element to the end, and a get(index) which ret...
true
b6b123f794048e613ec2787b5272fb856f04db69
sleepyheead/Numpy-Tensorflow-ScikitLearn_Exercises
/Numpy/generate-random-matrix-of-array-and-dot-product.py
967
4.3125
4
import numpy as np # For example, to create an array filled with random values between 0 and 1, use random function. # This is particularly useful for problems where you need a random state to get started. # But here the elements will be decimals A = np.random.rand(2,3) print(A) """ Output of above [[0.62857547 0.14...
true
32ea85ab9db1390a418066a5dd81211a152cee64
truckson/playtime
/lesson4playtime.py
1,457
4.25
4
# Challenge level: Beginner # Scenario: You have two files containing a list of email addresses of people who attended your events. # File 1: People who attended your Film Screening event # https://github.com/shannonturner/python-lessons/blob/master/section_09_(functions)/film_screening_attendees.txt # # File 2: Peopl...
true