blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0e21ece8f07b4abc07641459cc09d68cc31f351c
Nam1130Tx/Python
/Python Assignments/PY_Class_Assignment.py
1,304
4.125
4
# Python: 3.8.5 # Name: Nicholas Mireles # Assignment: Class Assignment class instrument(): def __init__(self, name, section, band): self.name = name self.section = section self.band = band class strings( instrument ): def __init__(self, name, section...
false
73d4dbc12fed8bc83ac68f19a31a729283c9a05f
cascam07/csf
/hw2.py
2,244
4.34375
4
# Name: ... Cameron Casey # Evergreen Login: ... cascam07 # Computer Science Foundations # Programming as a Way of Life # Homework 2 # You may do your work by editing this file, or by typing code at the # command line and copying it into the appropriate part of this file when # you are done. When you are done, runnin...
true
8bbd6935cc49c5280a79327c61d90ffb2ef5889c
Skp80/mle-tech-interviews
/data-structure-challenges/leetcode/543. Diameter of Binary Tree.py
1,658
4.25
4
""" Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. The length of a path between two nodes is represented by the number of edges between ...
true
9086e676e72f459b15df69d93859f939f4cb4a0f
starFaby/cursoPython
/parte 20 - 30/iConjuntos.py
930
4.21875
4
# Conjuntos # Conjuntos nos muestra cunado existe un numero repetitivo ya no se mostarar lo quitara print('Conjuntos nos muestra cunado existe un numero repetitivo ya no se mostarar lo quitara') conjunto = set() conjunto = {1,2,3,4,5,1} conjunto.add(4) conjunto.add(6) print(conjunto) # Para quitar del conjunto print('...
false
f0881f9ec77a982825071ed8106c4900278ac1a5
vuthysreang/python_bootcamp
/sreangvuthy17/week01/ex/17_str_last.py
625
4.40625
4
""" Description : You will write a program that ask for one string as and return the last character. If no argument is passed, display “Empty” Requirements : ● Program must be named : ​17_str_last.py​ and saved into​ week01/ex ​folder Hint : ❖ print function ❖ string ind...
true
b09cbe34ac66a41d58ab047f0dfbb6024c9a105e
vuthysreang/python_bootcamp
/Documents/week03/sreangvuthy17/week03/ex/45_auto_folder.py
2,173
4.46875
4
""" Description : You will create a program that take a list of string as argument, that represents folders names. Then, for each, you will create a folder with the corresponding name. Before create anything, you will check that the folders doesn’t already exists. ...
true
201dac84630f55ffceb24392cd58051b66e60495
vuthysreang/python_bootcamp
/sreangvuthy17/week01/ex/08_random.py
465
4.28125
4
""" Description : You will write a program that take display a random number between 1 and 100 Requirements : ● Program must be named : ​08_random.py​ and saved into​ week01/ex ​folder Hint : ❖ print function ❖ random """ # import random library import random # print random output between ...
true
421e2d5f4300102b66651efd180d3dbd6bf66a82
vuthysreang/python_bootcamp
/sreangvuthy17/week01/ex/06_odd_even.py
1,491
4.46875
4
""" Description : You will write a program that take will ask for a number in parameter and display ​“<number> is EVEN” or ​“number is ODD”​. If the number is not an integer, you will have to display ​“<input> is not a valid number.”​. If you enter ​“exit” ​or “EX...
true
926c19499256827be9c6f281257082f307432908
vuthysreang/python_bootcamp
/Documents/week03/sreangvuthy17/week03/ex/59_regex_html.py
1,235
4.1875
4
""" Description : You will create a function that take a string in parameter and remove every HTML content ( everything between ‘<’ and ‘>’ ) You will return the new formatted string. You need to do it using REGEX only. EXAMPLE : regex_html​("<html lang = 'pl' >...
true
a287483a91fa92fd183f524039b0255d4ea11f7d
vuthysreang/python_bootcamp
/sreangvuthy17/week02/ex/35_current_time.py
1,079
4.3125
4
""" Description : You will write a function that return the current time with the following format: hh:mm:ss The return value must be a string. Requirements : ● Program must be named : 35_current_time.py and saved into week02/ex folder Hint : ❖ function ❖ datetime Output : ...
true
0613d7beaa42dfe4acbccbcd93a154f788ba7c6f
vuthysreang/python_bootcamp
/sreangvuthy17/week03/ex/41_current_path.py
577
4.15625
4
""" Description : You will write a function that print the current path of your program folder, then you will return it as a string. Requirements : ● Program name : ​41_current_path.py ● Function name : ​current_path ● Directory : ​week03/ex ​folder Hint : ❖ ...
true
aa27c29c3a7884b708bcb5490e6698ad96ec275b
Wright2533/cti110
/P2HW1_CelsiusConverter(Resubmit)_ShawnWright.py
374
4.28125
4
# Celsius Fahrenheit Converter # 9/10/18 # CTI-110 P2HW1 - Celsius Fahrenheit Converter # Shawn Wright # #temperature in celcius c= celcius c = float(input('Enter temperature in celsius: ')) #convert farenheit F = Fahrenheit FE = 9/5c FE = c* 1.8 F = FE + 32 #show the conerted temperature in Fare...
false
a075edb4de5ac8b34032dd82dee03978fbf0b6ac
anversa-pro/ejerciciosPython
/excepciones.py
1,665
4.21875
4
#usr/bin/python # -*- coding: utf -*- print(""" Lo que hace try es ejecutar un bloque de sentencias en un “entorno controlado”, para que el error generado (si se da) no detenga el programa, sino que se retorne de modo que pueda manejarse. Por ejemplo, el clasico error de la division por 0 hara que el programa falle ...
false
9e2f2ccb0e7c1f8103abb86d1581e24ca4d03f3d
aengel22/Homework_Stuff
/module12_high_low.py
2,532
4.21875
4
# The get_price function accepts a string that is assumed to be # in the format MM-DD-YYYY:Price. It returns the Price component # as a float. def get_price(str): # Split the string at the colon. items = str.split(':') # Return the price, as a float. return float(items[1]) # The get_year funct...
true
55ebfed116af1e9389e2a81d432a237b90e7262e
RecklessDunker/Codewars
/Get the Middle Character.py
789
4.25
4
# -------------------------------------------------------- # Author: James Griffiths # Date Created: Wednesday, 3rd July 2019 # Version: 1.0 # -------------------------------------------------------- # # You are going to be given a word. Your job is to return the middle character of the # word. If the word's length is ...
true
deec653fc1bbe1f2ff5d32d2970265a89e68b7b0
cthompson7/MIS3640
/Session01/hello.py
2,277
4.59375
5
print("Hello, Christian!") # Whenever you are experimenting with a new feature, you should try to make mistakes. For example, in the “Hello, world!” program, what happens if you leave out one of the quotation marks? What if you leave out both? What if you spell print wrong? print(Hello, world!") # When I leave out o...
true
e2ae0826393ebf746222d47506a538662f0c4016
cthompson7/MIS3640
/Session11/binary_search.py
1,069
4.28125
4
def binary_search(my_list, x): ''' this function adopts bisection/binary search to find the index of a given number in an ordered list my_list: an ordered list of numbers from smallest to largest x: a number returns the index of x if x is in my_list, None if not. ''' left = 0 right =...
true
d2c3f792c5b41ff79f7d6f7fa76c75317c6687be
aleperno/blog
/fibo.py
1,313
4.25
4
#!/usr/bin/python import time def recursiveFibo(number): """Recursive implementation of the fibonacci function""" if (number < 2): return number else: return recursiveFibo(number-1)+recursiveFibo(number-2) def iterativeFibo(number): list = [0,1] for i in range(2,number+1): list.append(list[i-1]+list[i-2])...
true
7850a710550a6bba787f81b5945d70098c60ba14
jradd/small_data
/emergency_map_method.py
518
4.46875
4
#!/usr/bin/env python ''' the following is an example of map method in python: class Set: def __init__(self, values=None): s1 = [] # s2 = Set([1,2,2,3]) self.dict = {} if values is not None: for value in values: self.add(value) def __repr__(self): return "Set: " + str(self.dic...
true
28aa9e66286818d5ee939a6016df3dbe5490a265
xxpasswd/algorithms-and-data-structure
/other/queue.py
1,334
4.21875
4
''' python 队列实现 is_empty():O(1) enqueue(item):O(n) dequeue(item):O(1) size():O(1) ''' class Queue: def __init__(self): self._queue = [] def is_empty(self): return self._queue == [] def enqueue(self, item): self._queue.insert(0, item) def dequeue(self): return self._...
false
95a3aa9fbc89837526c1f3e4dd44e85783176f20
bhaumik1991/Python-Basic-Programs
/prime_number.py
481
4.1875
4
#Python program to print all Prime numbers in an interval n = int(input("Enter the number of terms:")) for num in range(2,n+1): for i in range(2,num): if num%i == 0: break else: print(num) #Python Program to check Prime Number n = int(input("Enter a number:")) if n>1: for i in r...
false
925ffcfcff7df4ee4db086783374321ee32f092a
Andreabrian/python-programming-examples-on-lists
/assign1.py
295
4.21875
4
#find the largest number in the list. a=[] n=int(input("Enter the number of elements:")) for i in range(n): a.append(int(input("enter new element:"))) print(a) s=a[0] for i in range(1,len(a)): if a[i]>s: s=a[i] y=("the largest number is: ") print(y,s)
true
5f498fc6d83701963d4800d121630523e805568b
chriskok/PythonLearningWorkspace
/tutorial11-tryelsefinally.py
1,333
4.4375
4
# ---------- FINALLY & ELSE ---------- # finally is used when you always want certain code to # execute whether an exception is raised or not num1, num2 = input("Enter to values to divide : ").split() try: quotient = int(num1) / int(num2) print("{} / {} = {}".format(num1, num2, quotient)) except ZeroDivision...
true
1d1b0213e352a561d37417353719711b31bd3de4
chriskok/PythonLearningWorkspace
/primenumber.py
696
4.34375
4
# Note, prime can only be divided by 1 and itself # 5 is prime because only divided by 1 and 5 - positive factor # 6 is not a prime, divide by 1,2,3,6 # use a for loop and check if modulus == 0 True def is_prime(num): for i in range(2, num): if (num % i) == 0: return False return True d...
true
8d598dc40e8428a74f5668cc6b6a29a86214e9bd
chriskok/PythonLearningWorkspace
/pinetree.py
1,026
4.3125
4
# How tall is the tree: 5 # 1 while loop and 3 for loops # ### ##### ####### ######### # # 4 spaces: 1 hash # 3 spaces: 3 hashes # 2 spaces: 5 hashes # ... # 0 spaces: 9 hashes # Need to do # 1. Decrement spaces by 1 each time through the loop # 2. Increment the hashes by 2 each time through the loop #...
true
cd6759aa55356291bb5b1f277fd8f0a88f950be1
TapasDash/Python-Coding-Practice
/oddEvenList.py
519
4.1875
4
''' This is a simple programme which takes in input from the user as a series of numbers then, filter out the even and odd ones and append them in two different lists naming them oddList and evenList Input : 1,2,3,4,5,6 Output : oddList = [1,3,5] evenList = [2,4,6] ''' myList = [eval(x) for x in input("Enter ser...
true
04edbaa127a19c39abb58fc4ab009161ddd40aee
rexarabe/Python_Projects
/class_01.py
1,414
4.53125
5
"""Creating and using class """ #The car class class Car(): """ A simple attemt to model a car. """ def __init__(self, make, model, year): """Initialize car attributes.""" self.make = make self.model = model self.year = year #Fuel capacity and level in gallons. ...
true
b71c815fa1f8167c8594774745dfccef3931add9
mustafaAlp/StockMarketGame
/Bond.py
1,075
4.3125
4
#!/usr/bin/env python """ This module includes Bond class which is a subclass of the Item class. Purpose of the module to learn how to use inheritance and polymorphizm in the python. Its free to use and change. writen by Mustafa ALP. 16.06.2015 """ import random as ra from Item import Item # ...
true
26c3e650eddb2c736279bccc1f8c99c5c6f794aa
rlopezb115/CursoPython
/4. HerramientasControlFlujo/b_FuncionRANGE.py
1,099
4.125
4
print('Inicio...') print('\nSecuencia de números, básico') # único parámetro, indica el final y no es parte de la secuencia. for num in range(10): print('Número: ', num) print('\nSecuencia de número, empieza con otro rango.') # Primer parámetro indica el comienzo del rango. # Segundo parámetro indica el final y n...
false
4aa65e5ce29cd4fae61a8e321842cf2b11af1eee
fernandezfran/python_UNSAM
/ejercicios/Clase12/burbujeo.py
1,362
4.53125
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def ord_burbujeo(lista): """ Ordenamiento por burbujeo. O(N^2) Pre: los elementos de la lista deben ser comparables Post: la lista está ordenada Devuelve la cantidad de comparaciones realizadas """ #comparaciones = 0 n = len(lista) -...
false
76512e65fadd9589b50889cbf42b99f68686983e
andrewlehmann/hackerrank-challenges
/Python Data Structures/Compare two linked lists/compare_linked_lists.py
956
4.1875
4
#Body """ Compare two linked list head could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node return back the head of the linked list in the below method. """ def equalityCheck(first, ot...
true
f5090b41b7e5cb5e98c4dc3ac85f092df79000bd
iyoussou/CAAP-CS
/hw1/fibonacci.py
469
4.28125
4
#Prints a specific value of the Fibonacci Sequence. def main(): print("This program prints a specific term of the Fibonacci Sequence.") term = eval(input("Which term of the Fibonacci Sequence would you like?: ")) current = 1 previous = 0 old_previous = 0 for i in range(0, term-1): old_previous = previous ...
true
2212f3aa40b95de35bb686d7462c95119bc865be
idealgupta/pyhon-basic
/matrix1.py
310
4.1875
4
matrix =[ [3,4,5], [5,7,8], [4,9,7] ] print(matrix) transposed=[] #for colem for i in range(3): list=[] for row in matrix: list.append(row[i]) transposed.append(list) print(transposed) #same trans =[[row[i] for row in matrix] for i in range(3)] print(trans)
true
38fa12bb089d62f76120c49953c8b0b359368281
forzen-fish/python-notes
/1.简单介绍/5简单操作.py
1,186
4.25
4
#语句与函数 #赋值语句:由辅助符号构成的一行代码 #赋值语句用来给变量赋予新的数据值 #赋值语句右侧的数据类型同时作用于变量 #如: #代码: # a = 10 # b = "10" # c = str(a) # print(type(a)) # print(type(b)) # print(type(c)) #输出结果: # <class 'int'> # <class 'str'> # <class 'str'> #分支结构语句 #作用:根据判断条件决定运行方向的语句 # 由if elif else 构成 #格式: """ if 条件: 成立语句 elif 条件: el...
false
4bb1f08be42cd7249b668f40e707a79cfca25477
forzen-fish/python-notes
/4.元组列表&字典/3列表排序与元祖.py
768
4.53125
5
""" 列表的排序操作 sort从小到大,如需大到小排序,利用reverse翻转 num = [1,5,61,7,8,5] num.sort() print(num) [1, 5, 5, 7, 8, 61] num = [1,5,61,7,8,5] num.sort() num.reverse() print(num) [61, 8, 7, 5, 5, 1] """ """ 列表的嵌套 列表中还有列表: [[1,2],[2,3],[3,4]] """ """ 元组 与列表类似但是元组不能修改,使用圆括号 a = (1,2,3,4) 索引从零开始 a[0]--》1 ... """ """ 修改元组 元组的值是不允许修改的,但...
false
8646d28c0880d9b3851d0ec49e97ef259031bec3
akshitshah702/Akshit_Task_5
/# Task 5 Q3.py
436
4.21875
4
# Task 5 Q3 def mult_digits(): x = input("Enter number ") while type(x) is not int: try: while int(x) <= 1: x = input("Please enter a number greater than 1: ") x = int(x) except ValueError: x = input("P...
true
183b9a7d439dca14510d9257712d90d1adc8a515
ANTRIKSH-GANJOO/-HACKTOBERFEST2K20
/Python/QuickSort.py
801
4.125
4
def partition(array, low, high): i = (low - 1) pivot = array[high] for j in range(low, high): if array[j] <= pivot: i = i + 1 array[i], array[j] = array[j], array[i] array[i+1], array[high] = array[high], array[i+1] return (i + 1) def quickSort(array, low, high)...
true
c4f2ba0d605988bfcfb046c42e92b4ef216c0534
ANTRIKSH-GANJOO/-HACKTOBERFEST2K20
/Python/Merge_sort.py
916
4.28125
4
def merge_sort(unsorted_list): if len(unsorted_list) <= 1: return unsorted_list # Finding the middle point and partitioning the array into two halves middle = len(unsorted_list) // 2 left = unsorted_list[:middle] right = unsorted_list[middle:] left = merge_sort(left) right = merge_s...
true
6e3235205388258659eb7ac63925152e52267ed9
ANTRIKSH-GANJOO/-HACKTOBERFEST2K20
/Python/Insertion_sort.py
305
4.21875
4
def insertionSort(array): for index in range(1,len(array)): currentvalue = array[index] position = index while position>0 and array[position-1]>currentvalue: array[position]=array[position-1] position = position-1 array[position]=currentvalue return array
true
04994935faa67526f4588d98d22ca235e993285d
rodrigobn/Python
/Lista de exercício 4 (laços)/ex09.py
275
4.21875
4
""" 9 - Faça um programa para calcular a área de N quadriláteros. Fórmula: Área = Lado * Lado. """ quadrados = int(input("Informe quantos quadrados: ")) for i in range(quadrados): lado = float(input("Informe o lado do quadrado: ")) area = lado * lado print(area)
false
c2b759bb13e094290557153d12bb221a97b9718a
rodrigobn/Python
/Lista de exercício 3 (if, elif, else)/ex13.py
1,252
4.375
4
""" 13. Faça um programa que calcule as raízes de uma equação do segundo grau, na forma ax2 + bx + c. O programa deverá pedir os valores de a, b e c e fazer as consistências, informando ao usuário nas seguintes situações: • Se o usuário informar o valor de A igual a zero, a equação não é do segundo grau e o programa ...
false
4b974df000fc347992e1cf94bde59a217fd55dfd
rodrigobn/Python
/Lista de exercício 4 (laços)/ex07.py
278
4.15625
4
""" 7 - Escreva um programa que calcula o fatorial de um dado número N. """ num = int(input("Digite o valor: ")) while num < 0: num = int(input("Digite o valor: ")) fatorial = 1; #O valor neutro da multiplicação for i in range(num, 1, -1): fatorial *= i print(fatorial)
false
970d9c88ae8b94072b9fe44dda83bfba5b13195e
redclazz2/LogicaDeProgramacion
/Quizzes/Quiz23Abril/Punto6.py
282
4.125
4
palabra = input("Ingrese una palabra para verificar si es un palíndromo: ") palabraLista = list(palabra.lower()) palabraInver = list(palabra.lower()) palabraInver.reverse() if palabraLista == palabraInver: print("Es un palíndromo!") else: print("No es un palíndromo!")
false
f48416b78c2e6a29a4b041b843cd8de5d280a2b0
anilgeorge04/cs50harvard
/python-intro/credit.py
1,958
4.25
4
# This software validates a credit card number entered by the user # Validity checks: Format, Luhn's checksum algorithm*, Number of digits, Starting digit(s) with RegEx # Output: It reports whether the card is Amex, Mastercard, Visa or Invalid # *Luhn's checksum algorithm: https:#en.wikipedia.org/wiki/Luhn_algorithm im...
true
0cf8dabae652848b5d0ac46fd753e0ee977630ee
AjayMistry29/pythonTraining
/Extra_Task_Data_Structure/ETQ8.py
831
4.1875
4
even_list=[] odd_list=[] while True: enter_input = int(input("Enter a number from from 1 to 50: ")) if enter_input>=1 and enter_input<=50 and (enter_input % 2) != 0 and len(odd_list)<5: odd_list.append(enter_input) print("Odd List :" ,odd_list) continue elif enter_input>=...
true
b7497ea31a107328ecb0242600df34d808483353
AjayMistry29/pythonTraining
/Task4/T4Q2.py
359
4.3125
4
def upperlower(string): upper = 0 lower = 0 for i in string: if (i>='a'and i<='z'): lower=lower+1 if (i>='A'and i<='Z'): upper=upper+1 print('Lower case characters = %s' %lower, 'Upper case characters = %s' %upper) string = input("E...
true
3fab33ec2b0ec5d95bcfefbab6c1b878d0c81daf
mrodzlgd/dc-ds-071519
/Warm_Ups/number_finder.py
766
4.25
4
def prime_finder(numbers): import numpy as np prime=np.array([]) """will select only the prime #'s from a given numpy array""" for n in np.nditer(numbers): if (n%2)>0: prime = np.append(prime,n) return prime #a series of numbers in which each number ( Fibonacci number ) ...
true
df78a002fdb80aa75916d98777f5036f53c24082
mariololo/EulerProblems
/problem41.py
1,162
4.25
4
""" We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? """ def is_pandigital(n): digits = [] for dig in str(n): if dig in digits: return ...
true
28785e79791f208e24240290142fd8bb87680e92
boquer/Python
/condicionales.py
477
4.125
4
numero = int(input("Digite un número: ")) if numero>0: #Si el número es mayor a cero, imprime lo de abajo. print("El número que ingresó es positivo") #Si el número no es mayor a cero, pasa a elif elif numero==0:#Si el número es igual a cero, imprime lo de abajo. print("El número que ingresó es cero") #Si n...
false
97cc0a8e13f2517cd8c55c0741cc5d94bfa4d7ea
AshTiwari/Standard-DSA-Topics-with-Python
/Array/Array_Merge_Sorted_Array_in_O(1)_Space.py
772
4.28125
4
# Merge two sorted array in O(1) time. from binaryInsertion import binaryInsertion ######### Increase the Efficiency by using binaryInsertion function to add element in sorted arr2 ########### def addElement(arr,element): index = 0 # alternate way is to use binaryInsertion. while(index < len(arr)-1): if arr[in...
true
835cfbcb2ebd756769226a1b3745427f70c17c50
LucioOSilva/HackerRankPython-PS
/LinkedList-PrintTheElementsOfALinkedList.py
1,868
4.375
4
""" If you're new to linked lists, this is a great exercise for learning about them. Given a pointer to the head node of a linked list, print its elements in order, one element per line. If the head pointer is null (indicating the list is empty), don’t print anything. Input Format: The first line of input contains "n"...
true
8db7becd41ea2f645a1f523a662ca9715da4121b
MrKonrados/PythonTraining
/Change Calculator/change_calc.py
1,369
4.3125
4
""" BASIC GOAL Imagine that your friend is a cashier, but has a hard time counting back change to customers. Create a program that allows him to input a certain amount of change, and then print how how many quarters, dimes, nickels, and pennies are needed to make up the amount needed. For example, if he inputs 1.47...
true
393492c970c349b49cc63d282ab8cc521308f462
shebilantony/3numlar
/3lar.py
262
4.25
4
num1=float(input("Enter first no:")) num2=float(input("Enter second no:")) num3=float(input("Enter third no:")) if(num1>num2) and (num1>num3): largest=num1 elif(num2>num1) and (num2>num3): largest=num2 else: largest=num3 print("the largest no is",largest)
false
b017de724c850cdc2c2dd757d7508ee2083db0f6
lmitchell4/Python
/ch_3_collatz.py
428
4.3125
4
## Collatz sequence def collatz(number): if number % 2 == 0: print(number // 2) return(number // 2) else: print(3*number + 1) return(3*number + 1) inputOK = False while not inputOK: try: print('Enter an integer to start the Collatz sequence:') n = int(input()) inputOK = True excep...
true
a95914f8996bc96b2e60ca8951bdeaf3611652d5
igelritter/learning-python
/ex35-lphw.py
2,759
4.125
4
#This is basically a text style adventure. Each room is defined as a function #as well as the starting and dying text. #importing the exit function from sys import exit #gold room. def gold_room(): print "This room is full of gold. How much do you take?" next=(raw_input(">")) #This 'if/else' statement is brok...
true
aa4e4e9f3f69af579d0f62498167fc4cdf087f91
igelritter/learning-python
/ex34-lphw.py
512
4.28125
4
#demonstarting the difference between ordinal numbers and #the cardinal numbers of indices in lists animals = ['bear' ,'python' ,'peacock' ,'kangaroo' ,'whale' ,'platypus'] print animals print "The animal at 1" print animals[1] print "The 3rd animal" print animals[2] print "The 1st animal" print animals[0] print "The a...
false
95af2966515dd3cfca5459096762f8c0d5790ab3
dao-heart/Leetcode-solutions
/pythonDataStructures/llist.py
2,157
4.1875
4
# Linked List class Node: def __init__(self, data): self.data = data self.next = None ## Test the nodes n1 = Node("Mon") n2 = Node("Tues") n1.next = n2 print(n1) class LinkedList: print_list = [] def __init__(self): self.headval = None def __repr__(self): return "->".j...
true
06e0eeff8467efd1538056e984644ea665656c0c
mobbarley/python2x
/fizzbuzz.py
559
4.3125
4
# This program mocks the script for the game fizz - buzz where we print all the numbers # from 1 to the number entered by the user but we say Fizz when number is divisible by 3 # and Buzz when it is divisible by 5, when it is both like in 15, 30 etc we will say FizzBuzz num = int(raw_input("Enter a number : ")) if nu...
true
88663a9fba92b5e8ca7a0121d3fdfabea283cb05
cindygao93/Dartboard
/assignment 2 third try.py
2,469
4.1875
4
##this is a program in turtle that will draw a dart board from turtle import * def main() : shape("turtle") pendown() pencolor("yellow") pensize(5) speed(20) radius=200 subradius=0 forward(radius) left(90) sideCount = 0 color = "yellow" while sideCount <80: ...
true
8dc6e4c41403953b42dde18cfb626598815bcee7
rkuzmyn/DevOps_online_Lviv_2020Q42021Q1
/m9/task9.1/count_vowels.py
428
4.125
4
vowels = 'aeiou' def count_vowels(string, vowels): # casefold() it is how lower() , but stronger string = string.casefold() # Forms a dictionary with key as a vowel count = {}.fromkeys(vowels, 0) # To count the vowels for character in string: if character in count: count[...
true
899721b5c37fc46b0ff9cc23180428800a349589
rogerroxbr/pysuinox-sprint-zero
/capitulo 04/exercicio-04-08.py
415
4.125
4
a = float(input("Primeiro número:")) b = float(input("Segundo número:")) operação = input("Digite a operação a realizar (+,-,* ou /):") if operação == "+": resultado = a + b elif operação == "-": resultado = a - b elif operação == "*": resultado = a * b elif operação == "/": resultado = a / b else: ...
false
d643bffc1fc1c1c029543510b66c5a0b1bc77377
slauney/Portfolio
/Python/InClassMarking/TC5/HighestCommonDivisor.py
2,611
4.125
4
########################################### # Desc: Highest Common Divisor # # Author: Zach Slaunwhite ########################################### def main(): #initialize the continue condition continueLoop = "y" #while continue loop is equal to y, repeat the program while(continueLoop == "y"): ...
true
6c85d89a5becfcce7df81801b3cd511c82b829b8
slauney/Portfolio
/Python/Labs/Lab04/ProvincialTaxes.py
2,194
4.21875
4
########################################### # Desc: Enter application description here. # # Author: Enter name here. ########################################### def main(): # Constants GST = 1.05 HARMONIZED_TAX = 1.15 # PROVINCIAL_TAX will be added onto GST to bring tax to 1.11 PROVINCIAL_TAX = 0....
true
df11e224537c2d5ea2aa747b7a71e12b0c4a975c
slauney/Portfolio
/Python/InClassMarking/TC2/taxCalculator.py
1,638
4.25
4
########################################### # Desc: Calculates the total amount of tax withheld from an employee's weekly salary (income tax?) # # Author: Zach Slaunwhite ########################################### def main(): # Main function for execution of program code. # Make sure you tab once for every li...
true
067ba4d62b07896b1a484dc7a47a39d9aba968e7
ggibson5972/Project-Euler
/euler_prob_1.py
232
4.15625
4
result = 0 #iterate from 1 to 1000 for i in range(1000): #determine if i is a multiple of 3 or 5 if ((i % 3 == 0) or (i % 5 == 0)): #if i is a multiple of 3 or 5, add to sum (result) result += i print result
true
052857681781833e79edd5eecb1e32b99f561749
chmod730/My-Python-Projects
/speed_of_light.py
944
4.375
4
''' This will query the user for a mass in kilograms and outputs the energy it contains in joules. ''' SPEED_OF_LIGHT = 299792458 # c in m/s2 TNT = 0.00000000024 # Equivalent to 1 joule def main(): print() print("This program works out the energy contained in a given mass using Einstein's famous equation:...
true
eb54fcd8f36e094f77bccdcebc0ae8230a2db34d
adneena/think-python
/Iteration/excercise1.py
1,142
4.25
4
import math def mysqrt(a): """Calculates square root using Newton's method: a - positive integer < 0; x - estimated value, in this case a/2 """ x = a/2 while True: estimated_root = (x + a/x) / 2 if estimated_root == x: return estimated_root break ...
true
3642cd6a682a9a05c2a5bc9c7597fd02af43a417
adneena/think-python
/Fruitiful-functions/excercise-3.py
856
4.34375
4
''' 1. Type these functions into a file named palindrome.py and test them out. What happens if you call middle with a string with two letters? One letter? What about the empty string, which is written '' and contains no letters? 2. Write a function called is_palindrome that takes a string argument and returns True if i...
true
5674ddd6d622dad21e14352332cdb85bf7adf9fc
adneena/think-python
/variables-expressions-statements/excercise1.py
520
4.375
4
''' Assume that we execute the following assignment statements: width = 17 height = 12.0 delimiter = '.' For each of the following expressions, write the value of the expression and the type (of the value of the expression). 1. width/2 2. width/2.0 3. height/3 4. 1 + 2 * 5 5. delimiter * 5 ''' width = 17 height = 12.0 ...
true
5327e3c6d6563e1fe25572b838f7274c7524c7ba
09jhoward/Revison-exercies
/task 2 temprature.py
482
4.15625
4
#08/10/2014 #Jess Howard #development exercises #write a program that reads in the temperature of water in a container(in centigrade and displays a message stating whether the water os frozen,boiling or neither. temp= int(input(" Please enter the water temprature in the unit of centigrade:")) if temp<= 0: pr...
true
056182ab50cd45d941652e85d9758c6a2d24011c
agmghazi/arcpySamples
/python Tutorial/20.Python_If... Else.py
1,197
4.3125
4
# Python Conditions and If statements # Equals: a == b # Not Equals: a != b # Less than: a < b # Less than or equal to: a <= b # Greater than: a > b # Greater than or equal to: a >= b # a = 33 # b = 200 # if b > a: # print("b is greater than a") # a = 33 # b = 33 # if b > a: # print("b is greater than a") # eli...
false
7aa43ddbb81ccbb9e8ad6fa74424dbe46fdeca35
Wambita/pythonwork
/converter.py
597
4.1875
4
#Program to convert pounds to kilograms #Prompt user to enter the first value in pounds print("Enter the first value in pounds you wish to convert into kilograms") pound1= float(input()) #prompt user to enter the second value in pounds print("Enter the second value in pounds you wish to convert into kilograms") pound...
true
0a1054b195d5ffe53bc14e92e6080edf6093d5f3
deodacodesage/data_science_program
/classes.py
1,154
4.21875
4
class Human (object): """ Class that defines human beings """ def __init__ (self, name, age, race, gender, religion): self.name = name self.age = age self.race = race self.gender = gender self.religion = religion def __person(self): profile = """ ...
false
f06a59233c6ebdbd37e9da2a4ca06321ca839055
clwater/lesson_python
/old/learn_old/if.py
693
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #if 注意条件后加: 自上至下 某个符合后则忽略后面的 # age = 20 # if age >= 6: # print('teenager') # elif age >= 18: # print('adult') # else: # print('kid') # birth = input('birth: ') # #通过int()将input得到的str类型转换为int类型 # birth = int(birth) # if birth > 2000: # print '00后' # else : #...
false
12fd7ae41f492a7cb882e38fcdb9d729d6289189
rmesquita91/exerciciosPOOpython
/exercicio03.python.py
1,007
4.46875
4
""" Faça um Programa que leia três números e mostre o maior e o menor deles. " print ('************************************************************') print ('*** INFORMA O MAIOR E MENOR NUMERO ************************') print ('***************** RAFAEL MESQUITA *************************') print ('****** SISTE...
false
e0aea95c21e5134bef5cf6501033d9b9d7d8119a
hwichman/CYEN301
/KeyedCaesar/KeyedCaesar.py
1,330
4.21875
4
import sys alphabet = "abcdefghijklmnopqrstuvwxyz" ### Main ### # Check for arguments if sys.argv < 3: raise Exception("CaesarCipher.py <1-25> <alphabetKey>") try: # Make sure second argument is an int numKey = int(sys.argv[1]) except: print "Key must be an integer." alphaKey = sys.arv[2] # New al...
true
2a4a4034e78d0dca4a5e3429fc29e0df2cfbb35e
popovata/ShortenURL
/shorten_url/app/utils.py
393
4.21875
4
""" A file contains utility functions """ import random import string LETTERS_AND_DIGITS = string.ascii_letters + string.digits def get_random_alphanumeric_string(length): """ Generates a random string of the given length :param length: length of a result string :return: a random string """ ...
true
3e34aff568ec6791a2cb378f93a45ce714083911
GabrielRioo/Curso_em_Video
/Curso_Python/Exercícios/ex016.py
401
4.25
4
# Crie um programa que leia um numero Real qualquer pelo teclado e mostre na tela a sua porção inteira # Ex: Digite um numero: 6.127, o numero 6.127 tem a parte inteira 6. num = float(input('Digite um numero: ')) print('O numero digitado foi {} e em inteiros é: {}'.format(num, int(num))) # OU from math import trunc p...
false
f2fba366bd724b0bbcb6d9ef80cad1edcb1e546e
AswinSenthilrajan/PythonRockPaperScissor
/PaperStoneScissor/StonePaperScissor.py
848
4.1875
4
from random import randrange options = ["Scissor", "Stone", "Paper"] random_number = randrange(3) user_option = input("Choose between Paper, Scissor and Stone:") computer_option = options[random_number] def play(): if computer_option == user_option: user_optionNew = input("Choose again:") elif compute...
true
2311b07ae564fd53cabee5532a39392c9e86793c
hiteshvaidya/Football-League
/football.py
2,397
4.25
4
# Football-League #This is a simple python program for a Football League Management System. It uses sqlite and tkinter for managing database and UI. #created by Hitesh Vaidya from tkinter import * import sqlite3 class App: def __init__(self,master): frame = Frame(master) frame.pack() a=St...
true
2224d73582b20f4542eb637c3a40579571ed4ac3
azzaHA/Movie-Trailer
/media.py
1,220
4.21875
4
""" Define Movie class to encapsulate movies attributes and methods """ class Movie(): """ Define attributes and methods associated to Movie objects * Attributes: title (string): Movie name story_line (string): Brief summary of the movie trailer_youtube_id (string): trailer ID on ...
true
36a3e44f366e2bcf8bbab61ce3cee2f551acd80b
itsfarooqui/Python-Programs
/Program15.py
275
4.125
4
#15. Write a method to find number of even number and odd numbers in an array. arr = [8, 4, 3, 6, 9, 2] i = 0 for i in range(0, len(arr)): if arr[i]%2 == 0: print("Even Number: ", arr[i]) else: print("Odd Number: ", arr[i]) i = i +1
true
960bc02fa729a588f9220769365fd4194fc7e0a3
thinkphp/rabin-miller
/rabin-miller.py
2,613
4.21875
4
# Miller-Rabin Probabilistic Primality Test. # # It's a primality test, an algorithm which determines whether a given number is prime. # # Theory # # 1. Fermat's little theorem states that if p is a prime and 1<=a<p then a^p-1 = 1(mod p) # # 2. If p is a prime x^2 = 1(mod p) or(x-1)(x+1) = 0 (mod p), then x = 1 (mod ...
true
15b439cc89bae13fbfd7a981ce68aa5c23ecaf0f
randcyp/FIT2085
/Practical 1/Exercise 1 - task_1.py
1,633
4.21875
4
# Non-assessed practical """ This module demonstrates a way to interface basic list operations. """ __author__ = "Chia Yong Peng" from typing import List, TypeVar T = TypeVar('T') list_of_items = [] def print_menu() -> None: """ Prints the menu. """ menu_items = ["append", "reverse", "print", "pop...
true
461c5e56da879c382f30317af48f304d8e33840d
Frindge/Esercizi-Workbook
/Exercises Workbook Capit. 1/Exercise 033 - Sort 3 Integers.py
697
4.1875
4
# Exercise 33: Sort 3 Integers # Creare un programma che legga tre numeri interi dall'utente e li mostri in ordine ordinato # (dal più piccolo al più grande). Usate le funzioni min e max per trovare il valore più piccolo e # quello più grande. Il valore medio può essere trovato calcolando la somma di tutti e tre i val...
false
583f9a7bf7f1aa39295f404f8ad42ba4c529abb3
Frindge/Esercizi-Workbook
/Exercises Workbook Capit. 2/Exercise 040 - Sound Levels.py
845
4.4375
4
# Exercise 40: Sound Levels # Jackhammer 130 dB # Gas Lawnmower 106 dB # Alarm Clock 70 dB # Quiet Room 40 dB Sound=float(input("Enter a number to define a sound level in decibels: ")) if Sound > 130: Sound="The sound level is louder than a Jackhammer" elif Sound == 130: Sound="The sound level is Jackhammer"...
true
93153b09c6c76b9e8b7daf4643d507e2a4bbacde
Frindge/Esercizi-Workbook
/Exercises Workbook Capit. 2/Exercise 051 - Roots of a Quadratic Function.py
547
4.1875
4
# Exercise 51: Roots of a Quadratic Function import math a=float(input("Enter the value a: ")) b=float(input("Enter the value b: ")) c=float(input("Enter the value c: ")) discriminant = (b**2) - (4 * a * c) print(discriminant) if discriminant < 0: print("has no real roots") elif discriminant == 0: result =...
true
22c14c12f08fcc25ab970493f8ef05cb5b73982b
Frindge/Esercizi-Workbook
/Exercises Workbook Capit. 2/Exercise 035 - Even or Odd.py
208
4.125
4
# Exercise 35: Even or Odd? number=int(input("Enter a valid integer number: ")) number1=number % 2 if number1 == 0: number1="the number is even." else: number1="the number is odd: " print(number1)
true
b971b310ae02ec049a32d1bebca9ea41a6ac5fb1
taoyuc3/SERIUS_NUS
/5.28.py
1,699
4.125
4
# https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/ from keras.models import Sequential from keras.layers import Dense import numpy # fix random seed for reproducibility numpy.random.seed(7) # Load pima indians dataset dataset = numpy.loadtxt("pima-indians-diabetes.data.csv", delimiter=",")...
true
9d44df3ad84744af06d02d53553f0049c382f2d2
Nana-Antwi/UVM-CS-21
/distance.py
799
4.125
4
#Nana Antwi #cs 21 #assignment 4 #distance.py #write a program that calculates distance #distance is equal to speed muliple by time #variables speed = 0.0 time = 0.0 distance = 0.0 var_cons = 1.0 #user input variable speed = float(input('Enter speed: ')) #user prompts #condition loop statements wh...
true
0c2bc2ff035678d3f8d947124c05d6293a0c7da0
rynoV/andrew_ng-ml
/mongo-lin-reg/src/computeCost.py
790
4.3125
4
import numpy as np def computeCost(X, y, theta): """ Compute cost for linear regression with multiple variables. Computes the cost of using theta as the parameter for linear regression to fit the data points in X and y. Parameters ---------- X : array_like The dataset of sh...
true
2a84fde9734f92965d0545bb3dd0fb0a6b06a190
ClaudiaMoraC/Ciclo1_Python
/Clase11junioListas_Tuplas.py
2,106
4.15625
4
# thislist = ["apple", "banana", "cherry"] # print(thislist) # Longitud de lita # thislist = ["apple", "banana", "cherry"] # print(len(thislist)) #tipo # mylist = ["apple", "banana", "cherry"] # print(type(mylist)) #Acceder a un elemento de la lista # thislist = ["apple", "banana", "cherry"] # print(thislist[1]) # p...
false
7a2aba24cf92a368bdeef9eae3951420627c2830
nazomeku/miscellaneous
/fizzbuzz.py
489
4.375
4
def fizzbuzz(x): """Take integer and check if it is divisable by: 3: return 'fizz', 5: return 'buzz', 3 and 5: return 'fizzbuzz', otherwise: return input as string. Args: x: The integer for which the condition is checked. Returns: Corresponding string value. """ if x ...
true
cc79f38420b39113f7d988a6171bdf3fd6f27e2d
UmmadisettyRamsai/ramsai
/labprogramme2.py
1,140
4.46875
4
# basic operations on single array #A PYTHON PROGRAM TO PERFORM UNIARY OPERATIONS import numpy as np a = np.array([1, 2, 5, 3]) # add 2 to every element print ("Adding 2 to every element:", a+2) # subtract 3 from each element print ("Subtracting 3 from each element:", a-3) # multiply each element b...
true
ab7ef4dd24c0e21a857cd1a8c28c9fdb36739169
Psycadelik/sifu
/general/is_integer_palindrome.py
486
4.15625
4
""" Check Whether a Number is Palindrome or Not Time complexity : O(log 10(n)). We divided the input by 10 for every iteration, so the time complexity is O(log10(n)) Space complexity : O(1) """ def is_palindrome(num): original_num = num reversed_num = 0 while (num != 0): num, rem = divmod(num, ...
true
1f3533dc0dd324766f4e7d39681dbdf434ad0d4d
MPeteva/HackBulgariaProgramming101
/Week0/1-PythonSimpleProblemsSet/T11_CountSubstrings.py
330
4.25
4
def count_substrings(haystack, needle): count_of_occurrences = haystack.count(needle) return count_of_occurrences def main(): String = input("Input a string: ") Word = input("Input a word to count occurrences of it in string: ") print (count_substrings(String, Word)) if __name__ == '__main__': ...
true
5445bd1df1895ec3906c10d5362b51d138400726
benjamin0905883618/goCode_LeetCode
/Day_5.py
2,838
4.40625
4
""" 這道題目曾出現在 Uber 的面試中。 給定一個 linked list 的 head node, 刪除所有總和為 0 的 sub linked lists, 直到此 linked list 不存在一個總和為 0 的 sub linked list 為止, 最後 return 刪除後的 linked list head node。 Example 1: Input: 3 -> 2 -> 1 -> -1 -> -2 -> None Output: 3 -> None Explanation: Sub list 2 -> 1 -> -1 -> -2 的總和為 0, 所以可把此 su...
false
15836a7c158c46605a536ab7b889119eed45fe7b
SaudiWebDev2020/Sumiyah_Fallatah
/Weekly_Challenges/python/week5/wee5day3.py
2,632
4.3125
4
# Create a queue using 2 stacks. A hint: stack1 will hold the contents of the actual queue, stack2 will be used in the enQueueing # Efficiency is not the goal! # Efficiency is not the goal! # Efficiency is not the goal! # The goal is to practice using one data structure to implement another one, in our case Queue from ...
true
c059e02dfe1f9c556b82de12ee26cd89a810db93
ton4phy/hello-world
/Python/55. Logic.py
253
4.28125
4
# Exercise # Implement the flip_flop function, which accepts a string as input and, if that string is 'flip', # returns the string 'flop'. Otherwise, the function should return 'flip'. def flip_flop(arg): return 'flop' if arg == 'flip' else 'flip'
true
ca71548c786da72de4c83531cdba7a5d8e6f3519
ton4phy/hello-world
/Python/57. Cycles.py
379
4.3125
4
# Exercise # Modify the print_numbers function so that it prints the numbers in reverse order. To do this, # go from the top to the bottom. That is, # the counter should be initialized with the maximum value, # and in the body of the loop it should be reduced to the lower limit. def print_numbers(n): while n > 0:...
true