blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
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
8daba7389dc26afa87c05397f504da786b983af4
santihadad/python-course
/tuples.py
508
4.21875
4
# Definiendo tuplas x = (1, 2, 3, 4, 5) # print(x) # print(type(x)) # months = ('January', 'Febrary', 'March') # print(months) # Creando tuplas a partir de la funcion "Tupla", al igual que las listas # y = tuple((1, 2, 3)) # print(y) # Metodos de una tupla # print(dir(y)) #Tuplas de un solo elemento # z = (1) # prin...
false
58f5fbe2ed1417afd3954439a35004257e37e51c
santihadad/python-course
/conditionals.py
1,081
4.28125
4
# Vamos a empezar a ver las estructuras condicionales, interectuando valores con el usuario y comparando parametros. Usaremos la estructura "if" # que solo devulve valores booleanos (True or False). # Para comparar se usan dos simbolos de igualdad (==) # 3==3 ---> True #Vamos a comparar el valor asignado a X con 30, ...
false
6a1c682b853b466e1c351c14d0e18730925c008b
ruizsugliani/Algoritmos-1-Essaya
/Unidad 9/9_3.py
1,405
4.1875
4
def agenda(): ''' El programa solicita al usuario que ingrese nombres, si el nombre se encuentra debe mostrar el teléfono y opcionalmente permitir modificarlo si no es correcto. Si el nombre no se encuentra, debe permitir ingresar el telefono correspondiente. El usuario puede utilizar la cadena...
false
e88a11fabb8e0c604448db82e18beb3969997b4d
ruizsugliani/Algoritmos-1-Essaya
/Unidad 12/12_3.py
1,260
4.21875
4
""" a) Crear una clase Vector, que en su constructor reciba una lista de elementos que serán sus coordenadas. En el método __str__ se imprime su contenido con el formato [x,y,z] b) Implementar el método __add__ que reciba otro vector, verifique si tienen la misma cantidad de elementos y devuelva un nuevo vector con...
false
e5ca12b6f4a8bbea235afb53bcad237e7891e39c
ruizsugliani/Algoritmos-1-Essaya
/PARCIALITOS/P3/pila.py
1,002
4.3125
4
class Pila: """Representa una pila con operaciones de apilar, desapilar y verificar si está vacía.""" def __init__(self): """Crea una pila vacía.""" self.items = [] def __str__(self): """Muestra por pantalla la pila indicando el tope.""" return f"{self.items} ...
false
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
7cc14a4d00bc0de076a043e46a12c3d3ff55f1fd
Steven24K/First-Python
/Full_circle.py
598
4.34375
4
def DrawCircle(diameter): import math center_x = diameter/2 center_y = diameter/2 circle = "" for y in range(int(diameter+1)): for x in range(int(diameter+1)): distance = math.sqrt((center_x - x )**2 + (center_y - y)**2) distance = math.ceil(distance) ...
false
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
acd6dfc6362f466a4b77b5b8cd1217fe65a8fc15
ZuDame/studyForPython
/design_patterns/dahua/factory_method.py
1,445
4.15625
4
""" 工厂方法模式,定义一个用于创建对象的接口,让子类决定实例化哪个类。 工厂方法使一个类的实例化延迟到其子类。 代码示例:学习雷锋好榜样,继承雷锋精神的大学生和社区的构建:: >>> factory = UndergraduateFactory() >>> student = factory.create_leifeng() >>> student.buyrice() 买米 >>> student.sweep() 扫地 >>> student.wash() 洗衣 工厂方法把简单工厂的内部逻辑判断移到了客户端代码来进行。 """ import abc class...
false
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
1ba7e0187c1800f680d5f80dfd3698b81304351d
developergaurav-exe/Minimal-Python-Programs
/PythonPrograms/largest no.py
334
4.21875
4
n1=int(input('number1: ')) n2=int(input('number2: ')) n3=int(input('number3: ')) #conditions if n1>n2: if n1>n3: largest=n1 else: largest=n3 else: if n2>n3: largest=n2 else: largest=n3 #to print largest no print('largest no...
false
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
bf96b609bebf534386cd7d6df28842630686fc18
avldokuchaev/testProject
/multiplicational_table.py
575
4.53125
5
# Напишите программу, выводящую на экран таблицу умножения. Первым делом она должна # спрашивать, для какого числа требуется вывести таблицу. number_for_multipl = int(input("Введите число для таблицы умножения: ")) number_1_for_multiple = int(input("Введите число до какого множителя: ")) for i in range(1, number_1_for_...
false
1c52d6473878fa04879dabed4b798aed74266201
avldokuchaev/testProject
/sell_procent.py
1,138
4.34375
4
# В магазине распродажа. На товары за 10 долларов и меньше скидка 10%, а на товары дороже 10 долларов # — 20 %. Напишите программу, которая будет запрашивать цену товара и показывать # размер скидки (10 или 20 %) и итоговую цену. cost_of_thing = float(input("Введите цену товара: ")) if cost_of_thing <= 10: cost_of...
false
7177047bb7942ee379b9a656bd76e19b93703c25
adipopbv/pf-laboratory-4-6
/Cheltuieli_de_familie/UI/Graphics.py
1,937
4.34375
4
def EmptyLine(): """ prints an empty line in the console """ print("") def Display(text): """ prints the given text in the console Args: text (str): text to be printed """ print(text) #EmptyLine() def DisplayAppName(): """ displays the name of the app "...
false
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
ad1a87911099f0691ea8aa2557d3326115780a2b
viniciuslizarte/Python3
/First Steps/Ex032.py
574
4.1875
4
'''''Desenvolva um programa que leia 3 comprimentos de retas e imprima se ele pode ou não formar um triângulo''' print('PODE OU NÃO SER UM TRIÂNGULO...') r1 = float(input('Digite o valor de uma reta: ')) r2 = float(input('Digite o valor de uma reta: ')) r3 = float(input('Digite o valor de uma reta: ')) r4 = (r1 + r2) ...
false
2341a384da37e088a76648c701c1f836b35c3dca
viniciuslizarte/Python3
/First Steps/Ex033.py
1,052
4.21875
4
'''ESCREVA UM PROGRAMA QUE APROVE UM EMPRÉSTIMO BANCÁRIO PARA A COMPRA DE UMA CASA. O PROGRAMA IRÁ PERGUNTAR O VALOR DA CASA, O SALÁRIO DO COMPRADOR E EM QUANTOS ANOS ELE IRÁ PAGAR CALCULE O VALOR DA PRESTAÇÃO MENSAL, SABENDO QUE ELA NÃO PODE ULTRAPASSAR 30% DO SALÁRIO OU ENTÃO O EMPREPÉSTIMO SERÁ NEGADO''' import tim...
false
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
59f157d861704930e57aacc4eddf8c2bdd49254e
Danya1998/DP-189-TAQC
/elem3/venv/triangle.py
1,114
4.125
4
import math def input_triangle(): input_param = input("Input triagle name and it's 3 sides through the ',':") input_param=input_param.split(',') return input_param def real_triangle(a,b,c): if a+b > c and a+c > b and b+c >a> 0 and b> 0 and c> 0: return True else: print("Enter corre...
false
66e43d92a853402d0bc638d8bd4796c2d9ced2b1
AlexandreLouzada/Pyquest
/envExemplo/Lista04/Lista04Ex08.py
1,310
4.15625
4
# Programa que calcula a área de um retângulo, círculo ou triângulo retangulo = lambda lado_a_ret, lado_b_ret: lado_a_ret * lado_b_ret triangulo = lambda lado_triângulo, altura_triângulo: (lado_triângulo * altura_triângulo) / 2 circulo = lambda raio_circulo: 3.14 * (raio_circulo ** 2) opcao = -1 while opcao != 0: ...
false
a581b59db57011f22159e88df376f9993c5fb2ec
afforeroc/find-the-real-gauss
/find_the_real_gauss.py
1,922
4.46875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Find The Real Gauss!""" def iterative_sum(num_list): """Calculate the sum using a for loop.""" total = 0 for num in num_list: total += num return total def python_sum(num_list): """Calculate the sum using standart 'sum' function of python."...
false
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
b3a590436d1bc37cbe6685d1f49735ed36c29b29
iamfakeBOII/pythonP
/lab_record_LISTS.py
1,517
4.28125
4
#PROGRAM TO FIND INDEX VALUE ''' l = eval(input('ENTER NUMBERS: ')) e = float(input('ENTER THE ELEMENT: ')) if e in l: print(f'{e} has {l.index(e)} index vlaue') else: print('not found') ''' #LARGEST/SMALLEST VALUE IN A LIST/TUPLE ''' l = eval(input('ENTER ELEMENTS: ')) print(f'THE LARGEST VALUE...
false
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
fd0130467b3315994ce1929ff9d785b5a903d1d2
Sigrud/lesson1
/hello.py
739
4.125
4
# a=input() # print(f'hello '+a) # numbers # -------------------------- a=2 b=4.5 print(a+b) # v=int(input('введите число')) # print(v+10) # strings # ------------------------- # name=input('введите ваше имя: ') # print('привет, '+name+'! Как дела?') # lists # -------------------------- a=[2,3,4,5,6,7] print(a) a.a...
false
6a5ffd1b7303589ebe16318946ce964b4b988dee
Igor-fr/GB
/Python_algorithms/lesson_2/les_2_task_1.py
1,857
4.125
4
# 1. Написать программу, которая будет складывать, вычитать, умножать или делить два числа. Числа и знак операции # вводятся пользователем. После выполнения вычисления программа не завершается, а запрашивает новые данные для # вычислений. Завершение программы должно выполняться при вводе символа '0' в качестве знака оп...
false
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
6c27fcf13ad2a6dbef592436c8ebd4b75ccec8b1
PCLWXM/pclpy
/my-控制语句/mypy03.py
647
4.125
4
#使用完整的条件表达式结构 score = int(input("请输入分数:")) grade = '' if(score<60): grade = "不及格" if(60<=score<80): grade = "及格" if(80<=score<90): grade = "良好" if(90<=score<=100): grade = "优秀" print("分数是{0},等级是{1}".format(score,grade)) print("******************************************************") #使用多分支结构 score = in...
false
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
171bb33eb82dd199aa78153963536b9191092d4b
zyall/demo
/Downloads/PycharmProjects/pyse11/python_base/function_test.py
740
4.28125
4
''' 用引号 1.多行注释 2.类、方法、函数内部注释 ''' def add(a=1, b=2): '''用于计算(参数默认)a add b ''' return a + b # print(add(5, 7)) # print(help(add)) #类和方法 ''' class jisuan(object): class jisuan(): class jisuan: class A(): def __init__(self, a, b): self.a = int(a) self.b = int(b) def add(self): ...
false
de333ba0ab185ab9a7d3dbbe4af3ba7809034ddc
Devinwon/master
/coding-exercise/hankerRank/python/Introduction/lists.py
779
4.1875
4
""" https://www.hackerrank.com/challenges/python-lists/problem insert i e print remove e append e sort pop reverse """ if __name__ == '__main__': N = int(input()) lst=[] for _ in range(N): cmd=input().split() if 'insert' in cmd: lst.insert(int(cmd[1]),int(cmd[2])) elif 'print' in cmd: print(lst) e...
false
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
fe2ad273f8168e73392cdc8f1cf19930375b29ff
lucabecci/IP-UNGS
/guia-1/exer16.py
841
4.125
4
""" # Determinar cuántos segundos tiene una hora, y cuántos tiene un día. # Escribir una expresión matemática que transforme un lapso de tiempo expresado en segundos a uno expresado en minutos. # Escribir otra para transformar a horas y una última que transforme a días. # Escribir un programa en Python que pida al us...
false
70c0c7fb617551ed849ecd84f9e8b07d2d4bdbc3
runda87/she_codes_python
/user_input_playground.py
1,666
4.125
4
# name = input("what is your name?") # print(f"Hi {name}") # age = input(f" Hi {name}, how old are you ?") # years_until_100 = 100 - int(age) # print(f"Wow {name} You'll be 100 in {years_until_100} years!") # question 1 # number1 = input("enter a number =") # number2 = input("enter another number =") # total1 = int...
false
cbc6012a9ffab6745f197b42a9a081f3c4d0c0af
polo1250/CS50-Projects
/Problem_Set_6/mario/more/mario.py
280
4.25
4
# Get the right value for the height while True: height = input("height: ") if (height.isdigit()) and (1 <= int(height) <= 8): height = int(height) break # Print the pyramid for i in range(1, height+1): print(" " * (height-i) + "#"*i + " " + "#"*i)
true
ca2f6b097aa5462fd678bc93466dcc90aef4c593
clintjason/flask_tutorial_series
/4_url_building/app.py
1,031
4.28125
4
from flask import Flask, url_for # import the Flask class and the url_for function ''' url_for() is used to build the url to a function. It takes as first argument the function name. If it takes any more arguments, those arguments will be variables used to build the url to the function. ''' app = Flask(__name__) # ins...
true
fea11f166857be327b4a9919c671bf2d42c70d80
leeseoyoung98/javavara-assignment
/2nd week/python_if_elif.py
473
4.15625
4
my_name="이서영" print(f"my name is {my_name}.") #{}안에서 연산도 가능. ex) my_name.upper() #리스트 안에 리스트 list_in_list=[1, 2, [3, 4, 5], 6] print(len(list_in_list)) list_in_list[2][0] #index=2에서의 0번째 (chained index) #조건문 name = "이서영" if name == "이서영": print("백현을 JONNA 사랑한다.") else: print("오늘부로 입덕한다.") #ternary operator n...
false
6bcdb7d66372b11c9631d05a25192db2104c1506
kaushiks90/FrequentInterviewPrograms
/Program28.py
425
4.15625
4
#Program to reverse an Array def reverseAnArray(arraynum): for x in range(len(arraynum)-1,-1,-1): print arraynum[x] reverseAnArray([56,3,45,12,89,34]) def reverseArrayMethod2(arraynum): limit=len(arraynum)/2 totalSize=len(arraynum) for x in range(0,limit): temp=arraynum[x] arraynum[x]=arraynum[totalSize-1...
false
ac3397c2fcc339bacadefdbb11e4370581bc53c3
Beelthazad/PythonExercises
/EjerciciosBasicos/ejercicio33.py
665
4.28125
4
# -*- coding: utf-8 -*- # Implemente una función tal que dada una lista de palabras devuelva un conjunto con todos los caracteres de esas palabras. # Puedes hacer varias versiones, mediante un recorrido de las palabras de la lista y dentro recorrer los caracteres... # O por comprensión con un doble for o bien usando la...
false
29551642e0ccfb4874e64ef84701c46bc5d4760c
CloudBIDeveloper/PythonTraining
/Code/Strings Methods.py
303
4.21875
4
str='Baxter Internationl' print(str.lower()) print(str.upper()) s1 = 'abc' s2 = '123' """ Each character of s2 is concatenated to the front of s1""" print('s1.join(s2):', s1.join(s2)) """ Each character of s1 is concatenated to the front of s2""" print('s2.join(s1):', s2.join(s1))
true
5950e80a726c7f13e3c94b36f7709395a6a6d0d5
allenmo/python_study
/049_is_prime.py
1,081
4.21875
4
import time def isPrime(n): if n==2 or n ==3: return True if n%2==0 or n<2: print '\t', 2 return False for i in range(3, int(n**0.5)+1, 2): #only odd numbers if n%i == 0: print '\t', i return False return True def is_prime(n): if n==2 or n==3: re...
false
29b87f157ef7686c53d896f60724bd97189a2851
huskydj1/CSC_630_Machine_Learning
/Python Crash Course/collatz_naive.py
366
4.40625
4
def print_collatz(n): while (n != 1): print(n, end = ' ') if (n % 2 == 0): n = n // 2 else: n = 3*n + 1 print(1) num = input("Enter the number whose Collatz sequence you want to print: ") try: num = int(num) print_collatz(num) except: print("Error. Y...
true
b34016ca1e68e8e207f7d781283cc0f9fb8d6586
santosh96r/test
/regular expression.py
2,428
4.28125
4
##import re ##var = 'python is the programming lang' # match used to search 1st word of string ##var1 = re.match("python" , var) ## ##print(var1) ##print(var1.group()) ##print(var1.start()) ##print(var1.end()) ##var = 'python is the programming lang' #search used to search any word in strin...
false
2955a1dac0e1ff268564954509c7100dcbe8c334
shazia90/code-with-mosh
/numbers.py
268
4.25
4
print (10 + 3) print (10 - 3) print (10 * 3) print (10 / 3) #which gives float no print (10 // 3)# this gives integer print (10 % 3)#modulus remainder of division print (10 ** 3)#10 power 3 x = 10 x = x + 3 # a) x += 3 # b) a, b both are same print (x)
true
0a0c80b6182e450fe6d7c90e6fcd438dc8e0a6bf
pranshuag9/my-cp-codes
/geeks_for_geeks/count_total_permutations_possible_by_replacing_character_by_0_or_1/main.py
768
4.1875
4
""" @url: https://www.geeksforgeeks.org/count-permutations-possible-by-replacing-characters-in-a-binary-string/ @problem: Given a string S consisting of characters 0, 1, and ‘?’, the task is to count all possible combinations of the binary string formed by replacing ‘?’ by 0 or 1. Algorithm: Count the number of ? c...
true
2bd068d2ef3a4069eeeed84807cf730a806abac1
pranav1698/algorithms_implementation
/Problems/unique_character.py
318
4.15625
4
def uniqueChars(string): # Please add your code here char=list() for character in string: if character not in char: char.append(character) result="" for character in char: result = result + character return result # Main string = input() print(uniqueChars(string))
true
70956143a82115aff42295f241d966c6aa3d55f6
UN997/Python-Guide-for-Beginners
/Code/number_palindrome.py
271
4.15625
4
num = input('Enter any number : ') try: val = int(num) if num == str(num)[::-1]: print('The given number is PALINDROME') else: print('The given number is NOT a palindrome') except ValueError: print("That's not a valid number, Try Again !")
true
3480189cc08cc286884c0b0b4506997960f864bc
Matheuspaixaocrisostenes/Python
/ex009.py
569
4.15625
4
num = int(input('digite um numero: ')) print('-' * 12) print('{} x {:2} = {}'.format(num , 1 , num * 1)) print('{} x {:2} = {}'.format(num , 2 , num*2)) print('{} x {:2} = {}'. format(num , 3 , num*3)) print('{} x {:2} = {}'.format(num , 4 , num * 4)) print('{} x {:2} = {}'.format(num , 5 , num* 5)) print('{} x {:2} = ...
false
485369e97ba682adae1920a4eb135330bd8ef2d2
tecmaverick/pylearn
/src/43_algo/11_permutation_string.py
1,180
4.1875
4
# The number of elements for permutations for a given string is N Factorial = N! (N=Length of String) # When the order does matter it is a Permutation. # Permutation Types - # Repetation allowed - For a three digit lock, the repeat permutations are 10 X 10 X 10 = 1000 permutations # No Repeat - For a three digit lock...
true
372a40b95e5464150724b67f66c94b59c2424a04
tecmaverick/pylearn
/src/38_extended_args/extended_args_demo.py
2,116
4.90625
5
#extended argument syntax #this allows functions to receive variable number of positional arguments or named arguments #example for variable positional args, which accepts variable number of argument print "one","two" #example of variable keyword args, which accepts variable number of keyword aegs val = "hello {a}, {b...
true
46bb500aa36043c5d94e7217dc2b4b9a04c71eb3
tecmaverick/pylearn
/src/39_scopes/scope_demo.py
1,051
4.1875
4
#LEGB Rule #Local, enlcosing, global, built-in my_global_var = "this is global" def outer(): outer_msg = "outer msg" val1 = {"test":"val"} def inner(): #here the variables in the enclosing scope in outer() function #is closed over by referencing the vairables referred #the enclosed variables can be viewed by...
true
73d5479e38e90c50d977e16ad32e549185b633ba
tecmaverick/pylearn
/src/32_closures/closuredemo.py
1,360
4.5
4
#Python closure is lst nested function that allows us to access variables of the outer function even after the outer function is closed. def my_name(name, time_of_day): def morning(): print "Hi {} Good Morning!".format(name) def evening(): print "Hi {} Good Evening!".format(name) def night(): print "Hi {} ...
true