blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
62cbd1bb70a63056c31bf7eb173481b151060d0b
zatserkl/learn
/python/plot.py
849
4.1875
4
"""See Python and Matplotlib Essentials for Scientists and Engineers.pdf """ import matplotlib.pyplot as plt x = range(5) y = [xi**2 for xi in x] plt.figure() # fig = plt.figure() # create a figure pointed by fig # fig.number # get number of the figure pointed by fig # plt.gcf().number # get numb...
true
821e0a1793c5fb08e85102dfe2f73d3744f24589
zatserkl/learn
/python/generator_comprehension.py
481
4.3125
4
# modified example from https://wiki.python.org/moin/Generators nmax = 5 # Generator expression: like list comprehension doubles = (2*n for n in range(nmax)) # parenthesis () instead of brackets [] # print("list of doubles:", list(doubles)) while True: try: number = next(doubles) # raises StopIterat...
true
2e449b4aeae7d9409d28e6ff4ae686b58ab315b5
zatserkl/learn
/python/numpy_matrix.py
1,614
4.375
4
################################################################### # This is the final solution: use array for the matrix operations # ################################################################### """ See https://docs.scipy.org/doc/numpy-dev/user/numpy-for-matlab-users.html NumPy matrix operations: use arrays ...
true
bbfa8595002901875ce4e6dd72babcf52921757f
rodrigor/IntroProgramacao-Code
/2014.2-Prova1/prova1-solucao2.py
2,495
4.25
4
# Resolução da prova1: Solução 01 # Prof. Rodrigo Rebouças # [Uma lista, sem função, sem validação] # Nesta solução usamos uma lista para armazenar # o nome e a média do aluno. O nome do aluno # fica armazenado na primeira posição de cada elemento # e a média do aluno fica armazenado na segunda posição NOME = 0 # Va...
false
b02955a662cd3093d93d4783334982e507492132
liyangwill/python_repository
/plot.py
1,395
4.15625
4
# Print the last item from year and pop print(year[-1]) print(pop[-1]) # Import matplotlib.pyplot as plt import matplotlib.pyplot as plt # Make a line plot: year on the x-axis, pop on the y-axis plt.plot(year,pop) plt.show() # Print the last item of gdp_cap and life_exp print(gdp_cap[-1]) print(life_exp[-1]) # Make...
true
f236b8b9866ac9eae15b53802cc2c01854c248f9
MainakRepositor/Advanced-Programming-Practice
/Week 3/Q.1.py
543
4.4375
4
'''1.Develop an Python code to display the following output using class and object (only one class and two objects)''' class Birdie: species = "bird" def __init__(self, name, age): self.name = name self.age = age blu = Birdie("Blu", 10) woo = Birdie("Woo", 15) print("Blu is a {}".format(b...
true
63458826fb3151c4a1f02905ee5b73d4c51641b0
juanignaciolagos/python
/07-Ejercicios/ejercicio4.py
467
4.4375
4
""" Pedir dos numeros al usuario y hacer todas las operaciones basicas de una calculadora mostrarlo por pantalla """ numero1 = int(input("Introduce el numero 1: ")) numero2 = int(input("Introduce el numero 2: ")) print(f"La suma de los dos numeros es: {numero1+numero2}") print(f"La resta de los dos numeros es: {nume...
false
9958f3ae8ed45d535d2fab9444a43426100ede7f
juanignaciolagos/python
/08-Funciones/predefinidas.py
892
4.1875
4
nombre = "Juan Lagos" #funciones Generales print(nombre) print(type(nombre)) #detectar el tipado comprobar = isinstance(nombre,int) if comprobar: print("Esta variable es un string") else: print("no es un string") if not isinstance(nombre,float): print("la variable no es un numero decimal") #limpiar e...
false
379b9516400816ed7641602198bddc6cd690f555
juanignaciolagos/python
/07-Ejercicios/ejercicio7.py
391
4.125
4
""" entre dos numeros que el usuario ingrese mostrar solo los numeros impares """ numero1 = int(input("Introduce el numero 1: ")) numero2 = int(input("Introduce el numero 2: ")) if numero1 <= numero2: rango = range(numero1,numero2) for contador in rango: print( 2*contador ) else: rango = range(...
false
12b16dbd277eb214c3ccc2dc47d64dccfceb0d36
hari-bhandari/pythonAlgoExpert
/QuickAndBubbleSort.py
684
4.15625
4
def quickSort(array): length=len(array) if length<=1: return array else: pivot=array.pop() itemsGreater=[] itemsLower=[] for item in array: if(item>pivot): itemsGreater.append(item) else: itemsLower.append(item) return quickSort(items...
true
357fbd822fa1d9e68afd1b880fc4c2f76988b384
jjen6894/PythonIntroduction
/Challenge/IfChallenge.py
593
4.21875
4
# Write a small program to ask for a name and an age. # When both values have been entered, check if the person # is the right age to gon on an 18-30 holiday must be over 18 # under 31 # if they are welcome them to the holiday otherwise print a polite message # refusing them entry name = input("What's your name? ") ag...
true
49a053c483508ebe7a6bed95bafbe294b56239c1
gabmwendwa/PythonLearning
/3. Conditions/2-while.py
396
4.34375
4
# With the while loop we can execute a set of statements as long as a condition is true. i = 1 while i <= 10: print(i) i += 1 print("---------") # Break while loop i = 1 while i <= 10: print(i) if i == 5: break i += 1 print("---------") # With the continue statement we can stop the current iteration, and continu...
true
b5ab9138384b9079b73d6a64e922a307d500fe42
gabmwendwa/PythonLearning
/4. Functions/1-functions.py
2,308
4.71875
5
# In Python a function is defined using the def keyword: def myfunction(): print("Hello from function") # Call function myfunction() print("-------") # Information can be passed to functions as parameter. def namefunc(fname): print(fname + " Mutisya") namefunc("Mutua") namefunc("Kalui") namefunc("Mwendwa") print("-...
true
71b8b67c39bb8c55568ba0c8dcdbb0e3565c1972
gabmwendwa/PythonLearning
/2. Collections/4-dictionary.py
2,577
4.34375
4
# Dictionary is a collection which is unordered, changeable and indexed. No duplicate members. # A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values. mdic = { "brand" : "Ford", "model" : "Mustang", "year" : 19...
true
e184909d1fc15daaeb34b22bd9f570d55038acfa
CPlusPlusNewb/python
/edhesive/notneededgarbage/2.2 Lesson Practice/question7.py
271
4.28125
4
if (3 * (6 + 2) / 2) == int("19"): print("Its the 1st") elif ((3 * 6) + 2 / 2) == int("19"): print("Its the 2nd") elif ((3 * 6 + 2) / 2) == int("19"): print("Its the 3rd") elif (3 * (6 + 2 / 2)) == int("19"): print("Its the 4th") else: print("Something went wrong")
false
252d6fb9fb6b77cfd70c38325fedc0b50e1d530d
alantanlc/what-is-torch-nn-really
/functions-as-objects-in-python.py
1,897
4.71875
5
# Functions can be passed as arguments # We define an 'apply' function which will take as input a list, _L_ and a function, _f_ and apply the function to each element of the list. def apply(L, f): """ Applies function given by f to each element in L Parameters ---------- L : list containing the op...
true
78c1296a009f6ff19884a46f48e67f6795e312f4
mariarozanska/python_exercises
/zad9.py
768
4.34375
4
'''Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. Extras: Keep the game going until the user types “exit” Keep track of how many guesses the user has taken, and when the game ends, print this ou...
true
4b610d707b407ef845cc19fde9da3eefc6115065
BlakeBeyond/python-onsite
/week_02/08_dictionaries/09_03_count_cases.py
1,065
4.5
4
''' Write a script that takes a sentence from the user and returns: - the number of lower case letters - the number of uppercase letters - the number of punctuations characters (count) - the total number of characters (len) Use a dictionary to store the count of each of the above. Note: ignore all spaces. Example in...
true
68a19b536b3ba06cd7ae5107106d15dd175682e5
BlakeBeyond/python-onsite
/week_02/08_dictionaries/09_02_combine_dicts.py
334
4.34375
4
''' Create a new dictionary using the three dictionaries below. Then print out each key-value pair. ''' dict_1 = {1: 1, 2: 4} dict_2 = {3: 9, 4: 16} dict_3 = {5: 25, 6: 36, 7: 49} new_dict = {} def add_dict(d): for k, v in d.items(): new_dict[k] = v add_dict(dict_1) add_dict(dict_2) add_dict(dict_3) p...
false
d7af1592985a4677bc8929c35905f045b25ca842
BlakeBeyond/python-onsite
/week_02/06_tuples/02_word_frequencies.py
628
4.40625
4
''' Write a function called most_frequent that takes a string and prints the letters in decreasing order of frequency. For example, the follow string should produce the following result. string_ = 'hello' Output: l, h, e, o For letters that are the same frequency, the order does not matter. ''' my_dict = {} sorted...
true
e8f1c5cd3e440886e0fa8f594d1092fb58fb509a
cp105/dynamic_programming_101
/dp101/knapsack01.py
1,896
4.4375
4
""" The knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. It derives its name from t...
true
2f38f4bc5978ba371014073dd189675134becea2
lucho1021/python
/practic.py
2,238
4.21875
4
#puntoA """factorial = input ('ingresa un numero ') factorial = int (factorial) def calculafactorial(factorial): if factorial==0 or factorial==1: resultado=1 elif factorial > 1: resultado=factorial*calculafactorial(factorial-1) return resultado print("el factorial de",factorial...
false
e441e0e4fa599fefe6f3f49f32477c68dd46e29a
jtannas/intermediate_python
/caching.py
1,368
4.65625
5
""" 24. Function caching Function caching allows us to cache the return values of a function depending on the arguments. It can save time when an I/O bound function is periodically called with the same arguments. Before Python 3.2 we had to write a custom implementation. In Python 3.2+ there is an lru_cache decorator w...
true
ebd261d238b7e9fe9a2167c9333de3046439771b
jtannas/intermediate_python
/ternary.py
574
4.25
4
""" 6. Ternary Operators Ternary operators are more commonly known as conditional expressions in Python. These operators evaluate something based on a condition being true or not. They became a part of Python in version 2.4 """ # Modern Python Way. def positive_test(num): return 'positive' if num > 0 else 'not po...
true
fbdcbc79ff16ee1b43ad8a4beafcccf2ccf0d0f3
xuyanlinux/code
/module01/第二章/用户交互和注释.py
1,688
4.125
4
# name = input("Name:") # age = input("Age:") # job = input("Job:") # hometown = input("Hometown:") # # info = '''-------------info of %s---------------- # "Name:" %s # "Age:" %s # "Job:" %s # "Hometown:" %s # ----------------END---------------------- # '''% (name,name,age,job,hometown) # ...
false
9b381446f85c86c9b92fb0749fe97301418828ff
Anjustdoit/Python-Basics-for-Data-Science
/string_try1.py
546
4.25
4
name = "hello" print(type(name)) message = 'john said to me "I\'ll see you later"' print(message) paragraph = ''' Hi , I'm writing a book. I will certainly do''' print(paragraph) hello = "Hello World!" print(hello) name = input('What is your name ? --> ') print(name) # What is your age ...
true
d50626ac217a242938030eb2621bc6263893c191
martinak1/diceman
/diceman/roll.py
2,993
4.25
4
import random def roll( num: int = 1, sides: int = 6) -> list: ''' Produces a list of results from rolling a dice a number of times Paramaters ---------- num: int The number of times the dice will be rolled (Default is 1) sides: int The number of sides the dice has (Default is ...
true
78238441fc78c9fe1c1ba488dc2db3120ed9a3fd
marcelomatz/py-studiesRepo
/python_udemy/introducao-python/dictionary-comprehension.py
494
4.15625
4
lista = [ ('chave', 'valor'), ('chave2', 'valor2'), ] d1 = {x.upper(): y.upper() for x, y in lista} print(d1) print() print('# OU USANDO UM JEITO MAIS SIMPLES \t dict \t PORÉM SEM ALGUNS RECURSOS DE USAR OUTRAS FUNÇÕES NATIVAS') print() d1 = dict(lista) print(d1) # Usando enumerate para criar uma chave - mei...
false
40836d6ef03d53ffb58056150c265ec687fa64ef
marcelomatz/py-studiesRepo
/python_udemy/introducao-python/tuplas.py
452
4.21875
4
""" O que difere Tuplas de Listas é que nas Tuplas não é possível: - alterar o valor das tuplas - alterar o índice - alterar porra nenhuma """ # t1 = 1, 2, 3, 'a', 'Marcelo Matzembacher' # print(t1) # t1 = (1, 2, 3, 4, 5) # t2 = (6, 7, 8, 9, 10) # t3 = t1 + t2 # print(t3, type(t3)) # UMA TUPLA NÃO ACEITA TER SEU ...
false
5f7c4b34d1211802b3a8eb13dfe2b37544e5b60f
Cakarena/CS-2
/sum_double_f.py
279
4.125
4
def sum_double(a,b): a=int(a) b=int(b) if a == b: sum = (a + b) * 2 print (sum) elif a != b: sum = (a + b) print (sum) sum_double(1,2) sum_double(3,2) sum_double(2,2) sum_double(-1,0) sum_double(3,3) sum_double(0,0) sum_double(0,1) sum_double(3,4)
false
36028b8aae863b3c6de5d5e1e76f32c6037c7d7f
Cakarena/CS-2
/numprint.py
235
4.15625
4
##Write a Python program that prints all the numbers from 0 to 6 except 3 and 6. ## Note : Use 'continue' statement. Name the code. Expected Output : 0 1 2 4 5 for i in range(0,7): if i==3 or i==6: continue print(i,end='')
true
097b292ea5a0d040181ec80c9beb3965f1cacb93
JohnKlaus-254/python
/Python basics/String Operations.py
1,105
4.28125
4
#CONCACTINATION using a plus #CONCACTINATION using a format first_name= "John" last_name = "Klaus" full_name = first_name +' '+ last_name print(full_name) #a better way to do this is; full_name = "{} {}".format(first_name, last_name) print(full_name) print("this man is called {} from the family of {} ".for...
true
7dd6519daded48e31f9c24276fee8f1c51a19623
GuptaNaman1998/DeepThought
/Python-Tasks/Rock-Paper-Scissors/Code.py
999
4.21875
4
""" 0-Rock 1-Paper 2-Scissor """ import random import os def cls(): os.system('cls' if os.name=='nt' else 'clear') Options={0:"Rock",1:"Paper",2:"Scissor"} # Created Dictionary of available choices poss={(0, 1):1,(0, 2):0,(1, 2):2} # Dictionary of possibilities and the winner value # print("Hi User!") player...
true
ce4fe060c3a35b03a49650e8aa385dc68d42715d
alexhohorst/MyExercises
/ex3.py
844
4.28125
4
print "I will now count my chickens:" print "Hens", 25 + 30 / 6 #adds 25 and 30 and divides this by 6 print "Roosters", 100 - 25 * 3 % 4 #substracts 25 from 100, multiplies with 3 and divides by 4, returning the remainder print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 #adds 3 and 2 and 1,...
true
8feadece0e5459fa7c9323550be42e5d88c14da1
sptechguru/python-Core-Interview
/Factorial.py
257
4.25
4
def factorial(n): if(n<=1): return 1 else: return(n*factorial(n-1)) n = int(input("Enter an Number:")) print("Factorial number is:", factorial(n)) # Output is: # Enter a Number : 5 # 1x2x3x4x5 =120 # Factorial number is: 120
false
f494f59caa548f497bd1d3825fd5448ac3cff339
MReeds/Classes-Practices
/pizzaPractice/classes.py
1,021
4.4375
4
#Add a method for interacting with a pizza's toppings, # called add_topping. #Add a method for outputting a description of the #pizza (sample output below). #Make two different instances of a pizza. #If you have properly defined the class, #you should be able to do something like the #following code with your Pizza ...
true
4577573df7b0866f4ee5e4fb46d6b4de38fea7c0
11810729/python-programming
/fibonacciseries.py
272
4.125
4
nterms=10 n1=0 n2=1 count=0 if nterms<=0: print("please enter a positive integer") elif nterms==1: print("Fibonacci sequence upto",nterms,":") print(n1) else: print("Fibonacci sequence upto",nterms,":") while count<nterms: print(n1,end=',') nth=n1+n2 n1=n2 n2=nth count+=1
false
bf49ad63a8611cdbcfc34e384f940d47e9eed772
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 11- String Contents.py
1,202
4.28125
4
# The String Contents Problem- Lab 11: CIS 1033 # Seth Miller and Kaitlin Coker # Explains purpose of program to user print("Hello! This program takes a string that you enter in and tells you what the string contains.") # Ask user for string userString = input("Please enter a string ---> ") # Tests if it co...
true
74a25f4969bc732424c26c88dc80441e2f4f499d
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 17- Training Heart Rate.py
1,034
4.21875
4
# The Training Heart Rate Problem # Lab 17: CIS 1033 # Author: Seth Miller # function that calculates training heart rate # based on age and resting heart rate def trainingHeartRate( age, restingHeartRate ) : maxHeartRate = 220 - age result = maxHeartRate - restingHeartRate result2 = result * 0.60...
true
bd4bf3185496a137ef716b6188082d27b9f084e8
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 9- Electric Bill.py
1,048
4.25
4
# The Electric Bill Problem- Lab 9 CIS 1033 # Author: Seth Miller # Input: receives the meter reading for the previous # and current month from the user prevMonthMeterReading = int(input("Meter reading for previous month: ")) currentMonthMeterReading = int(input("Meter reading for current month: ")) # Input: ...
true
3040a6b355ca4ac3a5a1e2c7c4c5cba7a70c4c58
phlalx/algorithms
/leetcode/326.power-of-three.python3.py
706
4.15625
4
# TAGS trick class Solution: def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ return ( n > 0 and 3 ** 20 % n == 0 ) # we suppose we know the biggest possible power # def ispowerof3(n) # if n < 1: # return F...
false
c3050341b766f637b39ba112c5967a9b43d74dfe
MortalKommit/Coffee-Machine
/coffee_machine.py
2,630
4.1875
4
class CoffeeMachine: def __init__(self, capacity, menu): self.capacity = {} contents = ("water", "milk", "coffee beans", "disposable cups", "money") for content, cap in zip(contents, capacity): self.capacity[content] = cap self.menu = menu def get_user_input(self): ...
true
1702acae637148eee91612d432b6e8fa4d594205
toddljones/advent_of_code
/2019/1/a.py
1,013
4.4375
4
""" Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. For example: - For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2. - For a mass of 14, dividing by 3 and rou...
true
12cd29f06a3438996e74f627d0fffacbbb3e4b1a
CertifiedErickBaps/Python36
/Ciclos While/Practica 5/invert.py
754
4.1875
4
# Authors: # A01379896 Erick Bautista Pérez # #Write a program called invert.py. Define in this program a function called invert(n) #that returns an integer comprised of the same digits contained in n but in reversed order. #For example, invert(2015) should return the number 5102. Do not use any string oper...
false
694ac91eec52f84fdac4581f1cd3be42554925d4
CertifiedErickBaps/Python36
/Listas/Practica 7/positives.py
1,028
4.125
4
# Authors: # A013979896 Erick Bautista Perez # #Write a program called positives.py. Define in this program a function called #positives(x) that takes a list of numbers x as its argument, and returns a new #list that only contains the positive numbers of x. # # October 28, 2016. def positives(x): a = ...
true
df7911328fd4b62321d98a88f8399978c053c5d0
CertifiedErickBaps/Python36
/Manipulacion de textos/Practica 6/username.py
2,277
4.3125
4
# Authors: # A01379896 Erick Bautista Pérez #Write a program called username.py. Define in this program a function called username(first, middle, last) #that takes the first name, middle name, and last name of a person and generates her user name given the above #rules. You may assume that every first name...
true
5af607504652e3240c32ecfb8a764987e5e58786
Exclusive1410/practise3
/pr3-4.py
231
4.34375
4
#Write Python program to find and print factorial of a number import math def fact(n): return (math.factorial(n)) num = int(input('Enter the number:')) factorial = fact(num) print('Factorial of', num, 'is', factorial)
true
f14a298f9b623616b2e81fe80aa2d1860e707bf4
StephenJonker/python-sample-code
/sort-list/sort-list-of-integer-list-pairs.py
1,780
4.25
4
# uses python3 # # Written by: Stephen Jonker # Written on: Tuesday 19 Sept 2017 # Copyright (c) 2017 Stephen Jonker - www.stephenjonker.com # # Purpose: # - basic python program to show sorting a list of number pairs # # - Given a list of integer number pairs that will come from STDIN # - first read in n, the number o...
true
cf5a25d897a55ed3ffe9cf4b70c7a3f352b16c56
sylviocesart/Curso_em_Video
/Desafios/Desafio10.py
1,205
4.15625
4
""" Crie um programa que leia quanto dinheiro uma pessoa tem na carteira e mostre quantos Dólares ela pode comprar Considere US$ 1,00 = R$ 3,27 """ dolar = 3.27 print('\nAtualmente o valor do dólar é: {}\n'.format(dolar)) valor = float(input('Quanto de dinheiro você tem na carteira? ')) qnt_dolar = valor // 3.27 qnt_c...
false
e6b38846ceed488f1334a77279b1220c31a4d21d
jeansabety/learning_python
/frame.py
608
4.25
4
#!/usr/bin/env python3 # Write a program that prints out the position, frame, and letter of the DNA # Try coding this with a single loop # Try coding this with nested loops dna = 'ATGGCCTTT' for i in range(len(dna)) : print(i, i%3 , dna[i]) #i%3 -> divide i (which is a number!) by i, and print the remainder for ...
true
632a36b7c686db27cfee436935eecfc9ba74be30
jeansabety/learning_python
/xcoverage.py
1,902
4.15625
4
#!/usr/bin/env python3 # Write a program that simulates random read coverage over a chromosome # Report min, max, and average coverage # Make variables for genome size, read number, read length # Input values from the command line # Note that you will not sample the ends of a chromosome very well # So don't count the ...
true
7efe190f957eec5b5c7a62adb1e45b520066f33f
bensenberner/ctci
/peaksAndValleys.py
638
4.40625
4
''' in an array of ints, a peak is an element which is greater than or equal to the adjacent integers. the opposite for a valley. Given an array of ints, sort it into an alternating sequence of peaks and valleys. ''' def peakSort(arr): for i in range(1, len(arr), 2): # make sure indices don't go out of bou...
true
3559ace9fe63307597bf924f37bc080da3490e00
GabyPopolin/Estrutura_Sequencial
/Estrutura_Sequencial_exe_07.py
278
4.125
4
'''Faça um Programa que calcule a área de um quadrado, em seguida mostre o dobro desta área para o usuário.''' n = float(input('Digiite o valor de um dos lados do quadrado: ')) a = (n**2) * 2 print('') print('O dobro do valor da área do quadrado é: {}' .format(a))
false
f28956d14fb2d0b41b40cda2042d43b28ac500ab
GabyPopolin/Estrutura_Sequencial
/Estrutura_Sequencial_exe_06.py
231
4.125
4
import math '''Faça um Programa que peça o raio de um círculo, calcule e mostre sua área.''' r = float(input('Digite o raio do círculo: ')) a = (r**2) * 3.14 print('') print('Á área do círculo é: {}' .format(a))
false
1a5541ac2b3af545ec206ad68986eaf8d6232512
dheerajps/pythonPractice
/algorithms/unsortedArrayHighestProduct.py
1,344
4.21875
4
# same as highestProduct.py # but find the maximum product possible by three numbers in an array without sorting it #so O(N) must be time requirements def getMaxProductOfThreeNumbers(array): import sys #Max product can be 3 maximum numbers or 2 minimum numbers and 1 max firstMax = -sys.maxsize-1 secondMa...
true
32e8588930e8821ae35ef762dc37c3fa5368fd97
lyndsiWilliams/cs-module-project-algorithms
/sliding_window_max/sliding_window_max.py
1,063
4.5
4
''' Input: a List of integers as well as an integer `k` representing the size of the sliding window Returns: a List of integers ''' def sliding_window_max(nums, k): # Your code here # Check if numbers array exists if nums: # Set an empty list for the max numbers to live max_numbers = [] ...
true
a2b4f9b45b1888a518e7db8a687c3bf452aca122
manu4xever/leet-code-solved
/reverse_single_linked_list.py
506
4.1875
4
Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def reverseList(self, head): ...
true
0d4b6e26e09ea7d90e4d45941f07a4d9046ba1b4
Hety06/caesar_cipher
/caesar_cipher.py
878
4.1875
4
def shift(letter, shift_amount): unicode_value = ord(letter) + shift_amount if unicode_value > 126: new_letter = chr(unicode_value - 95) else: new_letter = chr(unicode_value) return new_letter def encrypt(message, shift_amount): result = "" for letter in message:...
true
1eb92fd964d785db16d04628b9734810a5460374
anterra/area-calculator
/area_calculator.py
1,016
4.15625
4
import math class Rectangle: def __init__(self, length1, length2): self.length1 = length1 self.length2 = length2 def area(self): area = self.length1 * self.length2 return area class Circle: def __init__(self, radius): self.radius = radius def area(self): ...
true
f8cb2d4ff4976169893c680ba37018de7e936e34
dileep208/dileepltecommerce
/test/one.py
341
4.25
4
# This is for printing print('This is a test') # This is for finding the length of a string s = 'Amazing' print(len(s)) # This for finding the length of hippopotomus s='hippopotomous' print(len(s)) # This is for finding the length of string print('Practice makes man perfect') # finding the length of your name s = 'dil...
true
46f4ccac098130227ddf177fc99365cbffa31f86
siva6160/helloworld
/becomde9-3.py
236
4.15625
4
import math as m def pow(num,p): res=num**p return res num=int(input("enter a number")) p=int(input("enter a num")) s=pow(num,p) print(s) print(m.pow(num,p)) print(m.sqrt(num)) print(m.ceil(num)) print(m.floor(num))
false
580e061bc9d72a90ed2411c6ea7b8393f3b6e0f4
johnnyferreiradev/python-course-microsoft
/formatting-strings.py
295
4.1875
4
first_name = 'Johnny' last_name = 'Ferreira' output = 'Hello, ' + first_name + ' ' + last_name output = 'Hello, {} {}'.format(first_name, last_name) output = 'Hello, {1} {0}'.format(first_name, last_name) # Only available in Python 3 output = f'Hello, {first_name} {last_name}' print(output)
false
a7a5cbedf25dc380bfcf6c152cfa4848d32f0c55
vinaykumar7686/Algorithms
/Data Structures/Binary-Tree/Binary Search Tree/[BST] Validate Binary Search Tree.py
2,161
4.375
4
# Validate Binary Search Tree ''' Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node...
true
867ffc604bc02ee32ef1798070530ef9861ef0a1
vinaykumar7686/Algorithms
/Algorithms/Dynamic_Programming/Nth_Fibonacci_No/fibonacci _basic _sol.py
1,022
4.40625
4
def fibo_i(n): ''' Accepts integer type value as argument and returns respective number in fibonacci series. Uses traditional iterative technique Arguments: n is an integer type number whose respective fibonacci nyumber is to be found. Returns: nth number in fiboacci series ''' # Sim...
true
f04e1c9e1d991242d1dcce33de00c651125572a7
ziolkowskid06/Python_Crash_Course
/ch10 - Files and Exceptions/10-03. Guest.py
222
4.4375
4
""" Write a program that prompts the user for their name. """ name = input("What's your name? ") filename = 'guest.txt' # Save the variable into the .txt file with open(filename, 'w') as f: f.write(name)
true
daddc2badb17111c59d9406fdeb09dd7871b620e
ziolkowskid06/Python_Crash_Course
/ch05 - IF Statements/5-02. More Conditional Tests.py
673
4.125
4
""" Write more conditional tests. """ # Equality and iequality with strings. motorcycle = 'Ducati' print("Is motorcycle != 'Ducati'? I predict False.") print(motorcycle == 'ducati') print("\nIs motorycle == 'Ducati'? I predict True.") print(motorcycle == 'Ducati') # Test using lower() method. pc = 'DELL' p...
true
58ca8613f51031792f48d896a3f5c3d6a4cfc565
ziolkowskid06/Python_Crash_Course
/ch05 - IF Statements/5-08. Hello Admin.py
473
4.4375
4
""" Make a list of five or more usernames, including the name'admin'. Imagine you are writing code that will print a greeting to each user after they log in to a website and the question for admin. """ names = ['anna', 'elizabeth', 'julia', 'kim', 'admin', 'rachel'] for name in names: if name == 'admin': ...
true
d90c7e345eb4fe782187b003523f9caa1909447c
ziolkowskid06/Python_Crash_Course
/ch07 - User Input and WHILE Loops/7-10. Dream Vacation.py
494
4.15625
4
""" Write a program that polls users about their dream vacation. """ poll = {} while True: name = input("What's your name? ") vacation = input("If you could visit one place in the world, " "where would you go? ") poll[name] = vacation quit = input("Stop asking? (yes/no) "...
true
b9014e87d1d5167c8cdcd0f0837609b7d61e240e
ziolkowskid06/Python_Crash_Course
/ch03 - Introducing Lists/3-09. Dinner Guests.py
319
4.21875
4
""" Working with one of the programs from Exercises 3-4 through 3-7 (page 42), use len() to print a message indicating the number of people you are inviting to dinner. """ # Print a number of elements guest_list = ['mary jane', 'elizabeth hurtley', 'salma hayek'] print(f" There are {len(guest_list)} people invi...
true
30176a4c40a0682963e4d0d9de8d27004b191ff1
ziolkowskid06/Python_Crash_Course
/ch07 - User Input and WHILE Loops/7-02. Restaurant Seating.py
277
4.21875
4
""" Write a program that asks the user how many people are in their dinner group. """ seating = input('How many people are in your dinner group?\n') seating = int(seating) if seating > 8: print("You need to wait for a table.") else: print("Table is ready!")
true
d8bf5c776f3d205b611959efb6af840f3c55d1e6
mysqlplus163/aboutPython
/20170626/demo1.py
366
4.1875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # Python中的迭代 list1 = [1, 2, 3, 4, 5] # index = 0 # while index < len(list1): # print(list1[index]) # index =index + 1 # for循环 for index in range(len(list1)): # rang(3) -> 0, 1, 2 print(list1[index]) # # 区别于简单的重复 # while True: # print("老男孩教育暑期实训")
false
c41f4dcd82e4b041185764f8646f5de6dc5b1ab6
Alex-Angelico/math-series
/math_series/series.py
1,337
4.3125
4
def fibonacci(num): """ Arguments: num - user-selected sequence value from the Fibonacci sequence to be calculated by the funciton Returns: Calculated value from the sequence """ if num <= 0: print('Value too small.') elif num == 1: return 0 elif num == 2: return 1 else: return fi...
true
cddc10f2fb3571e8d55ac0bc8393f5fe1aabd2cb
Priyojeet/man_at_work
/python_100/string_manipulation1.py
322
4.34375
4
# Write a Python program to remove the nth index character from a nonempty string. def remove_char(str, n): slice1 = str[:n] slice2 = str[n + 1:] #print(slice1) #print(slice2) return slice1 + slice2 l = str(input("enter a string:-")) no = int(input("enter a number:-")) print(remove_char(l, no)...
true
97a822a515d3434b42b402aebbcb5513b01334f4
Priyojeet/man_at_work
/python_100/decision_making_nested_if_else.py
562
4.125
4
# check prime number with nested loop number = eval(input("enter the number you want:-")) if(isinstance(number,str)): print(" please enter an integer value") elif(type(number) == float): print("you enter a float number") else: if (number <= 0): print("enter an integer grater then 0") elif (numb...
true
0862a345a5b5422d0e062f977015a95ef4ad3f3b
dipsuji/coding_pyhton
/coding/flatten_tree.py
1,266
4.1875
4
class Node: """ create node with lest and right attribute """ def __init__(self, key): self.left = None self.right = None self.val = key def print_pre_order(root): """ this is pre order traversal """ if root: # First print the data of root print...
true
44e6ef8dd8212448ed8684262c52fcc71da35d4e
dipsuji/coding_pyhton
/udemy_leetcode/Hash Map Facebook Interview Questions solutions/majority_element.py
846
4.1875
4
""" - https://leetcode.com/problems/majority-element/ Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1: Input: nums = [3,2,3] Output: 3 Exa...
true
0045f7f9c3c0e13656f0b5f5c815f7cb17ac13bc
dipsuji/coding_pyhton
/udemy_leetcode/Microsoft Interview Questions solutions/missing_number.py
1,121
4.15625
4
from typing import List """ Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the mi...
true
77e3b9062540fd72f2a1deb8f3ccf652d982ad0d
lehmanwics/programming-interview-questions
/src/general/Python/4_fibonachi_numbers.py
1,402
4.28125
4
""" 4. Write fibonacci iteratively and recursively (bonus: use dynamic programming) """ # Fibonachi recursively (function calls itself) def fib(nth_number): if nth_number == 0: return 0 elif nth_number == 1: return 1 else: return fib(nth_number-1) + fib(nth_number - 2) ...
true
935726112481fa8173f8e4bc7a817225d123d126
sarma5233/pythonpract
/python/operators.py
2,108
4.40625
4
a = 10 b = 8 print("ARITHMETIC operators") print('1.Addition') print(a+b) print() print('2.subtraction') print(a-b) print('3.Multiplication') print(a*b) print('4.Division') print(a/b) print('5.Modulus') print(a%b) print('6.Exponentiation') print(a**b) print('7.floor Division') print(a//b) print("Comparision Operators"...
true
8fb2558f6f9bed68720ee257727e9be5840cbe0d
sarma5233/pythonpract
/flow_controls/while.py
210
4.15625
4
n = int(input("enter a number:")) sum = 0 total_numbers = 1 while total_numbers <= n: sum += total_numbers total_numbers += 1 print("sum =", sum) average = sum/n print("Average = ", average)
true
c8ff41d4b83e1b1285f1acde17504d2236b453c6
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/04-regular_expression_in_python/e32_flying_home.py
1,297
4.15625
4
""" Flying home The variable flight containing one email subject was loaded in your session. You can use print() to view it in the IPython Shell. Import the re module. Complete the regular expression to match and capture all the flight information required. Only the first parenthesis were placed for you. Find all the m...
true
fa7afe7b83e2d11110183c186ed9019e7043d306
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/05-Working_with_Dates_and_Times/e22_how_many_hours_elapsed_around_daylight_saving.py
1,348
4.5625
5
""" How many hours elapsed around daylight saving? Let's look at March 12, 2017, in the Eastern United States, when Daylight Saving kicked in at 2 AM. If you create a datetime for midnight that night, and add 6 hours to it, how much time will have elapsed? You already have a datetime called start, set for March 12, 20...
true
afb5a251bfa0ba326669aa7ae14f0004c54d914e
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/12-Introduction_to_Deep_Learning_in_Python/e1_coding_the_forward_propagation_algorithm.py
1,574
4.375
4
""" Coding the forward propagation algorithm The input data has been pre-loaded as input_data, and the weights are available in a dictionary called weights. The array of weights for the first node in the hidden layer are in weights['node_0'], and the array of weights for the second node in the hidden layer are in weigh...
true
a5437c79e37d03fd36f379c41ee2f84ea191bb79
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/02-python-data-science-toolbox-part-2/e33_writing_an_iterator_to_load_data_in_chunks3.py
1,534
4.15625
4
""" Writing an iterator to load data in chunks (3) The packages pandas and matplotlib.pyplot have been imported as pd and plt respectively for your use. Instructions 100 XP Write a list comprehension to generate a list of values from pops_list for the new column 'Total Urban Population'. The output expression ...
true
c1a72827d922ed8468dd66d50a7c0d2d4c897ce8
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/02-python-data-science-toolbox-part-2/e18_list_comprehensions_vs_generators.py
1,679
4.5
4
""" List comprehensions vs generators generators does not store data in memnory like list if there a very large list then use generators. There is no point in using large list instead use generators In this exercise, you will recall the difference between list comprehensions and generators. To help with that task, t...
true
7278153d5148595cd0bc4cfb92ccef72cd4706c7
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/10-Supervised_Learning_with_scikit-learn/e28_centering_and_scaling_your_data.py
1,912
4.28125
4
""" Centering and scaling your data You will now explore scaling for yourself on a new dataset - White Wine Quality! Hugo used the Red Wine Quality dataset in the video. We have used the 'quality' feature of the wine to create a binary target variable: If 'quality' is less than 5, the target variable is 1, and otherwi...
true
246c365f2c3f7f10c249933ead07532244770291
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/03-cleaning_data_in_python/e36_pairs_of_restaurants.py
1,325
4.125
4
""" in this exercise, you will perform the first step in record linkage and generate possible pairs of rows between restaurants and restaurants_new. Both DataFrames, pandas and recordlinkage are in your environment. Instructions Instantiate an indexing object by using the Index() function from recordlinkage. ...
true
5b718cdb7f238284afaa3e3a5080213062c4bf15
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/04-regular_expression_in_python/e3_palindromes.py
782
4.28125
4
""" The text of a movie review for one example has been already saved in the variable movie. You can use print(movie) to view the variable in the IPython Shell. Instructions 100 XP Extract the substring from the 12th to the 30th character from the variable movie which corresponds to the movie title. Store it ...
true
d4cf7f2383afe7107d2218d684df69e3f9e4c9e8
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/05-Working_with_Dates_and_Times/e16_the_long_and_the_short_of_why_time_is_hard.py
1,779
4.46875
4
""" The long and the short of why time is hard As before, data has been loaded as onebike_durations. Calculate shortest_trip from onebike_durations. Calculate longest_trip from onebike_durations. Print the results, turning shortest_trip and longest_trip into strings so they can print. """ from datetime im...
true
9aa4a68742400f5dff59647d53bfb1e0e7d91a14
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e32_making_predictions.py
1,169
4.21875
4
""" Making predictions At this point, we have a model that predicts income using age, education, and sex. Let's see what it predicts for different levels of education, holding age constant. Using np.linspace(), add a variable named 'educ' to df with a range of values from 0 to 20. Add a variable named 'age' ...
true
7e486404b32bb6b34085ee5fc263fbb2437cd3b6
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/09-Statistical_Thinking_in_Python_Part2/e7_linear_regression_on_appropriate_anscombe_data.py
1,403
4.125
4
""" Linear regression on appropriate Anscombe data Compute the parameters for the slope and intercept using np.polyfit(). The Anscombe data are stored in the arrays x and y. Print the slope a and intercept b. Generate theoretical and data from the linear regression. Your array, which you can create with np.array(), sh...
true
dab0d9344df34e3f0730c2b87683c050d701e011
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/04-regular_expression_in_python/e2_artificial_reviews.py
1,271
4.15625
4
""" The text of two movie reviews has been already saved in the variables movie1 and movie2. You can use the print() function to view the variables in the IPython Shell. Remember: The 1st character of a string has index 0. Instructions Select the first 32 characters of the variable movie1 and assign it to the variabl...
true
b6eb4dde3b6ef947df4922a52e971102397f01e9
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e7_compute_birth_weight.py
818
4.3125
4
""" Compute birth weight Make a Boolean Series called full_term that is true for babies with 'prglngth' greater than or equal to 37 weeks. Use full_term and birth_weight to select birth weight in pounds for full-term babies. Store the result in full_term_weight. Compute the mean weight of full-term bab...
true
fef3d8a8eb810bfeebd65a7951b14f2f55c514c8
DiniH1/python_concatenation_task
/python_concactination_task.py
507
4.21875
4
# Task 1 name = "" name = input("What is your name? ") name_capitalize = name.capitalize() print(name_capitalize + " Welcome to this task!") # Task 2 full_name = "" full_name = input('What is your full name? ') first_name = (full_name.split()[0]) first_name_capitalize = first_name.capitalize() last_name = (full_name.s...
true
2ae3f62714952207aaf401db24a148f92a9871d1
AtxTom/Election_Analysis
/PyPoll.py
1,017
4.125
4
# The data we need to retrieve. # 1. The total number of votes cast # 2. A complete list of candidates who received votes # 3. The percentage of votes each candidate won # 4. The total number of votes each candidate won # 5. The winner of the election based on popular vote. # Add our dependencies. import csv import o...
true
fceebe8dfa503b1bfe1925f59e1a06c7f14a3851
lengfc09/Financial_Models
/NLP/Codes/code-sklearn-k-means-clustering.py
792
4.3125
4
# This script illustrates how to use k-means clustering in # SciKit-Learn. from sklearn.cluster import KMeans import numpy as np # We create a numpy array with some data. Each row corresponds to an # observation. X = \ np.array( [[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], ...
true
ac7d5491c2ed052cbc296be4e0b00ea7f4a7554c
Asana-sama/Learn5
/Task1.py
799
4.1875
4
# Создать программно файл в текстовом формате, записать в него построчно данные, # вводимые пользователем. Об окончании ввода данных свидетельствует пустая строка. def file_input(name="task1.txt"): file = open(name, "w") input_string = input("Введите строку:") while (input_string != ""): file.write...
false
302334f9a7cd8ac3ae4ff61777bc7926899baca4
sanraj99/practice_python
/prime_number.py
509
4.15625
4
# A Prime number can only divided by 1 and itself def is_prime(num): for i in range(2, num): if (num % i) == 0: return False return True def getPrimes(max_number): list_of_primes = [] for num1 in range(2, max_number): if is_prime(num1): list_of_primes.app...
true
4f97b96ca9683d7dea5defd2201e10d4408b169b
sourav-gomes/Python
/Part - I/Chapter 3 - Strings/03_string_functions.py
854
4.28125
4
story = "once upon a time there was a boy named Joseph who was good but very lazy fellow and never completed any job" # String Functions # print(len(story)) # gives length of the string # print(story.endswith("job")) # returns True or false. In this case True. # print(story.count("a")) # returns how many ...
true
b79a137c9f02c076e43d751bbaec2b0ede6f6603
sourav-gomes/Python
/Part - I/Chapter 5 - Dictionary & Sets/03_Sets_in_python_and methods.py
1,726
4.375
4
''' a = (1, 2, 3) # () means --> tuple print(type(a)) # prints type --> <class 'tuple'> a = [1, 2, 3] # [] means --> list print(type(a)) # prints type --> <class 'list'> a = {1, 2, 3} # {x, y,....} means --> set print(type(a)) # prints type --> <class 'set'> a = {1:3} # {x:...
true