blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0ec823ff787e42cbc840d8e7b10d0779bc084006
taramakhija/repository
/triangles.py
218
4.21875
4
import math def triangle_3rd_side(): a = int(input(" what does a equal")) b = int(input(" what does b equal")) csqr= a*2 + b*2 c = math.sqrt(csqr) print(f"the third side is {c}") triangle_3rd_side()
false
b11a066923bb37615bf23d01bcc5c22055fbda08
gosub/programming-praxis-python
/010-mardi-gras/mardi_gras.py
2,337
4.21875
4
# Mardi Gras # Compute the date of Easter # Programming Praxis Exercise 10 # http://programmingpraxis.com/2009/02/24/mardi-gras/ from datetime import date, timedelta def computus(year): """ Return the date of Easter for every year in the Gregorian Calendar. The original algorithm was submitted to Nature in 1...
false
89ebfba3b074ecdf011aff1e1f0a1013f980ab56
rafa761/algorithms-example
/insertion_sort.py
585
4.28125
4
unsorted_list = [7, 3, 9, 2, 8, 4, 1, 5, 6] def insertion_sort(num_list): # We don't need to consider the index 0 because there isn't any number on the left for i in range(1, len(num_list)): # store the current value to sort value_to_sort = num_list[i] # While there are greater values on the left while num...
true
55ca73caa0515d4f6a514e9869b0a65a9bfeb602
CaioJrVS/Algest
/python/DS/linkedlist/singlyllist.py
1,856
4.125
4
class Node: def __init__(self,data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def traverse(self): temp = self.head while temp != None: print(temp.data, end = " ") temp = temp.next prin...
false
eda70418204060e275cfb778bd85bc9852ae72dd
17764591637/jianzhi_offer
/剑指offer/15_ReverseList.py
528
4.15625
4
''' 输入一个链表,反转链表后,输出新链表的表头。 思路: step1:None step2:1->None step3:2->1->None ... ''' class Solution: # 返回ListNode def ReverseList(self, pHead): # write code here if not pHead or not pHead.next: return pHead p_before = None pNode = pHead while pNode != None: ...
false
981ca7c3e0a1e0ee84e20a4869e6c564cb5e9fce
17764591637/jianzhi_offer
/剑指offer/63_GetMedian.py
953
4.25
4
''' 如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值, 那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值, 那么中位数就是所有数值排序之后中间两个数的平均值。 我们使用Insert()方法读取数据流,使用GetMedian()方法获取当前读取数据的中位数。 ''' class Solution: def __init__(self): self.nums = [] def Insert(self, num): # write code here self.nums.append(num) return self...
false
7fac6b0e87c550f517d9bea7834585812ff6ddac
Raeebikash/python_class2
/practice/exercise77.py
538
4.25
4
# define is_palindrome function that take one world in string as input # and return True if it is palindrome else return false # palindrome - word that reads same backwards as forwards #example # is_palindrome ("madam") ------> True # is_palindrome ("naman")------> True #is_palindrome ("horse")----->False # lo...
true
2a4e100e806ffed91ee5ed7098dc89644e06b084
ijaha/PY100
/1.1.py
222
4.1875
4
# Записать условие, которое является истинным , когда целое А кратно двум или трем. A = int(input()) if A % 2 == 0 or A % 3 == 0: print('True')
false
32d93101bcb08f1af155821534a19e7098a0100f
gargchirayu/Python-basic-projects
/factorial.py
217
4.125
4
num = int(input("Enter number:")) fac = 1 if num<0: print("Negative number invalid") elif num == 0: print("Factorial = 1") else: for i in range(1, num+1): fac = fac*i print("Factorial = ",fac)
false
8fa3d457aeb3c0162a2b0d677ce3b089dd8e1e25
BalaKumaranKS/Python
/codes/assignment 01- 01.py
209
4.4375
4
#program for calculating area ofcircle value01 = int (input('Enter radius of circle in mm ')) value02 = (value01 * value01) value03 = (3.14 * value02) print ('The area of circle is',str(value03),'mm^2' )
true
628bfaf8e262ab8186103f95e52f478ed7381082
BalaKumaranKS/Python
/codes/assignment 02- 02.py
235
4.3125
4
# Program to check number is positive or negative inp = int(input('Enter the Number: ')) if inp > 0: print('The number is Positive') elif inp== 0: print ('The number is 0') else: print('The number is Negative')
true
0bd9287e31945c94caf4cb3ee7c41635435a7273
heecho/Database
/webserver-3.py
2,628
4.1875
4
''' Phase three: Templating Templating allows a program to replace data dynamically in an html file. Ex: A blog page, we wouldn't write a whole new html file for every blog page. We want to write the html part, and styling just once, then just inject the different blog data into that page. 1) Add the following l...
true
afc147e559f9589487ce969973e8342beae3a05b
Ulkuozturk/SQL_Python_Integration
/movie_Create_AddData.py
648
4.4375
4
import sqlite3 connection = sqlite3.connect("movie.db") cursor= connection.cursor() cursor.execute('''CREATE TABLE IF NOT EXISTS Movies (Title TEXT, Director TEXT, Yera INT)''' ) famousfilms=[("Pulp Fiction","Quantin Tarantino", 1994),("Back To The Future","Steven Spielberg", 1985), ("Moo...
true
35f0ae91acf3ccd76a04ed1aeca5faef42eae435
EdwardRamos2/EstruturaDeDecisao
/03.py
453
4.28125
4
#!/usr/bin/env python #*-*coding: utf-8 *-* #Faça um Programa que verifique se uma letra digitada é "F" ou "M". #Conforme a letra escrever: F - Feminino, M - Masculino, Sexo Inválido. sexo = input('Digite (F Feminino) ou (M Masculino): ') print(sexo) if sexo.upper() == 'M': print ('(+) Sexo escolhido: Masculino'...
false
f3c5fe7381107bb91c110a7cb9bf708b699b3d5b
andkashkaha/GeekBrains_lessons
/Lesson1_Task2.py
534
4.15625
4
#Пользователь вводит время в секундах. Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс. Используйте форматирование строк. user_time=int(input("Введите время в секундах: ")) all_minutes=user_time//60 seconds=user_time%60 hours=all_minutes//60 minutes=all_minutes%60 print(f"Время в нуж...
false
554f4435cd9ec0bdbdff8e5f6b61a50b3ae8f355
taylortom/Experiments
/Python/MyFirstPython/Lists.py
518
4.3125
4
# # Lists # list = [0,1,'two', 3, 'four', 5, 6, 'Bob'] # add to the list list.append('kate') print list # remove an item list.pop(3) # can also use list.pop() to remove last item print list # sort a list list.sort() print list # reverse a list list.reverse() print list # list nesting matrix = [[-1,0,0], [0,-1,0]...
true
3bf15f4e63a239fd34a0806ff00bbae0163a417a
wesley-1221/python_learning
/python类编程/进阶篇/双下划线方法_one.py
947
4.3125
4
# -*- coding:utf-8 -*- """ 作者:wesley 日期:2020年11月29日 """ # __len__ # __hash__ # __eq__ class Student(object): def __init__(self, name): self.name = name def __len__(self): print("____len____") return 1 # 需要返回一个整数 def __hash__(self): print("____hash____"...
false
8666c0e53861a399e74c4e8f0808e6d1ea1eb7f0
wesley-1221/python_learning
/python类编程/进阶篇/双下划线方法_three.py
1,465
4.46875
4
# -*- coding:utf-8 -*- """ 作者:wesley 日期:2020年11月29日 """ # 重要 ''' str函数或者print函数调用时--->obj.__str__() repr或者交互式解释器中调用时--->obj.__repr__() 如果__str__没有被定义,那么就会使用__repr__来代替输出 注意:这俩方法的返回值必须是字符串,否则抛出异常 ''' # class Student(object): # # def __init__(self, name, age): # self.name = name # self.age = age # # ...
false
fa5e9a2770fbc24836104db247d0d1e6866ee77b
sidmaskey13/python_assignments_2
/P12.py
599
4.375
4
# Create a function, is_palindrome, to determine if a supplied word is # the same if the letters are reversed. givenString = input('Enter string: ') def check_palindrome(given_string): word_length = len(given_string) half_word_length = int(word_length/2) match = 0 for i in range(0, half_wor...
true
61e354e9f4d5c5cabbd6a804150cf5e6c505285a
sidmaskey13/python_assignments_2
/P3.py
586
4.3125
4
# Write code that will print out the anagrams (words that use the same # letters) from a paragraph of text. givenString = input('Enter string: ') def check_anagrams(given_string): word_length = len(given_string) half_word_length = int(word_length/2) match = 0 for i in range(0, half_word_len...
true
8d085c2ca7fe0c47b2c772c551466919c24899c2
lgd405/hello
/tutorial/bmi.py
791
4.15625
4
# -*- coding: utf-8 -*- while True : name = input("Your name : ") h = input("Your Height (m) : ") w = input("Your Weight (kg) : ") Height = float(h) Weight = float(w) bmi = Weight / (Height*Height) if bmi < 18.5: print("Your are too light(name = %s , BMI = %d) !" % (name, bmi)) e...
false
70a2412549fe5a7e8bf54f626457e529363f3a9b
mccricardo/project_euler
/problem_46/python/problem46.py
627
4.3125
4
# Start with prime 3. # # If none of the primes in prime_list divide n, then it's also prime and # add it to the list. # # If not, let's put the problem formula with another aspect: # prime = odd_number - 2 * pow(i, 2) # # This means that we can check if any of the primes can be constructed in terms # of the odd numb...
true
365df8c8ca7c12b37c84963376692b16a476c503
mohammadrezamzy/python_class
/List_sample1.py
707
4.28125
4
students = [ ("John", ["CompSci", "Physics"]), ("Vusi", ["Maths", "CompSci", "Stats"]), ("Jess", ["CompSci", "Accounting", "Economics", "Management"]), ("Sarah", ["InfSys", "Accounting", "Economics", "CommLaw"]), ("Zuki", ["Sociology", "Economics", "Law", "Stats", "Music"])] print(len(studen...
false
a3def7eec0586d8dfdbef1aa55c6feec20b5c854
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_4/4-1.pizzas.py
273
4.6875
5
""" Store three kinds of pizza in a list 1. print them in a for loop 2. write about why you love pizza """ pizzas = ['americana', 'hawaina', 'peperoni'] for pizza in pizzas: #1 print(f'I like {pizza}') print('I REALLY LOVE PIZZA IS MY FAVORITE FOOD IN THE WORLD') #2
true
d1076809fe1826dad2117b9ced283dcb7173fcdb
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_10/10-2.learning_c.py
458
4.28125
4
""" Read in each line from the file you just created, learning_python.txt, and replace the word Python with the name of another language, such as C. Print each modified line to the screen. """ filename = './learning_python.txt' with open(filename) as f: lines = f.readlines() for line in lines: if 'Pyt...
true
ee10c39f6ec686f1644016633282fdaacd279843
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_6/6-8.pets.py
691
4.4375
4
""" Make three dictionaries representing different pets, and store all three dictionaries in a list called pets. Loop through your list of pets. As you loop through the list, print everything you know about each pet """ pets = [] chulu = { 'kind': 'cat', 'owner': 'james', 'name' : 'chulu' } pets.append(ch...
false
8655935a7d3a32c2e1a89ef3091db2f3f3de256a
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_9/9-2.three_restaurants.py
838
4.4375
4
""" Start with your class from Exercise 9-1. Create three different instances from the class, and call describe_restaurant() for each instance. """ class Restaurant: def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type ...
true
085723b30c9de5a3dae534fa25a02f3deaafe065
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_8/8-12.sandwiches.py
545
4.15625
4
""" Write a function that accepts a list of items a person wants on a sandwich. The function should have one parameter that collects as many items as the function call provides, and it should print a summary of the sandwich that is being ordered. """ def sandwiches_order(*sandwich): print('ORDER:') for order...
true
2565e37340942909c482bb4501d45d057fb3960e
wreyesus/Learning-to-Code
/regExp/scripts/exercise_2.py
323
4.25
4
"""Write a Python program that matches a string that has an a followed by zero or more b's.""" import re def finder(string): """using 're.match'""" regex = re.match('^a[\w]*', string) if regex: print('We have a MATCH') else: print('NO MATCH') finder('abc') finder('abbc') finder('abbba...
true
2264c01614e3ba01e621b7cc9ae50920f2a54bc0
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_5/5-2.more_conditional_tests.py
1,021
4.3125
4
# 1. Tests for equality and inequality with strings print('='*5) car = 'Tesla' print(car == 'tesla') print(car == 'Tesla') # 2. Tests using the lower() function print('='*5) name = 'James' test = name.lower() == 'james' print(test) # 3. Numerical tests involving equality and inequality, # greater than and less than,...
true
e93ba2f959698ef3a4d35bfd8d32dfa0b4907974
mmonali/monisha2007
/2007 assignment4 module3(chapter 1).py
2,227
4.15625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #numbers frm 0 to 6(excluding 3 n 6) for x in range(6): if (x == 3 or x==6): continue print(x,end=' ') print("\n") # In[2]: #counting odd or even numbers numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9) count_odd = 0 count_even = 0 for x in numbers: if ...
false
ab3e9f61cd9942019c125f1d940daff547c80888
Abdulvaliy/Tip-calculator
/Tip calculator.py
468
4.125
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 print("Welcometo the tip calculator.") bill = float(input("What was the total bill? $")) percent = int(input("What percentage tip would you like to give? 10, 12 or 15? ")) people = int(input("H...
true
240cad4398853e25f993842413a88eef365af76b
brian-rieder/DailyProgrammer
/DP146E_PolygonPerimeter.py
1,903
4.3125
4
__author__ = 'Brian Rieder' # Link to reddit: http://www.reddit.com/r/dailyprogrammer/comments/1tixzk/122313_challenge_146_easy_polygon_perimeter/ # Difficulty: Easy # A Polygon is a geometric two-dimensional figure that has n-sides (line segments) that closes to form a loop. # Polygons can be in many different shap...
true
7bbd62ff212c1a9a6b33b8bab369ba3b9c025488
amandazhuyilan/Breakfast-Burrito
/Data-Structures/BinarySearchTree.py
2,911
4.1875
4
# Binary Search tree with following operations: # Insert, Lookup, Delete, Print, Comparing two trees, returning tree # elements # example testing tree: # 8 # / \ # 3 10 # / \ \ # 1 6 14 # / \ / # 4 7 13 class node: def __init__(self, data): se...
true
d2ece47f1eed48fffd1e820e18d84f12598b017f
amandazhuyilan/Breakfast-Burrito
/Problems-and-Solutions/python/isPalindrome.py
477
4.28125
4
def is_Palindrome_Recrusive(s): if s == "": return True if s[0] == s[-1]: return is_Palindrome_Recrusive(s[1:-1]) def is_Palindrome_Iteration(s): if s == "": return True for i in range(len(s)//2): if s[i] != s[-(i+1)]: return False return True TEST_CASE1 = "abuttuba" TEST_CASE2 = "word" print("Ori...
false
0971f0292c5f040685704da9a064f5328a180615
mayank-gubba/Compiler-Design
/Complier_Design/lexical/type_of_operator.py
860
4.3125
4
"""CODE BY MAYANK GUBBA this lexical analyser uses regular expression to find out the type of operator of data that is given as input""" import re t=int(input('enter the number of test cases: ')) for i in range(t): s=input("enter operator/data: ") if (re.match('^\*$',s)): print('multiplication o...
false
7c9c7bfbaac7077ec4beaa4dac1405d726799eb7
hayleymathews/data_structures_and_algorithms
/Lists/examples/insertion_sort.py
819
4.34375
4
"""python implementation of Insertion Sort with Positional List >>> p = PositionalList() >>> p.add_first(1) Position: 1 >>> p.add_first(3) Position: 3 >>> p.add_first(2) Position: 2 >>> insertion_sort(p) PositionalList: [1, 2, 3] """ from Lists.positional_list import PositionalList def insertion_sort(List): if len...
true
cbe8c75f0538700abf4c7e528176c83944be8080
hayleymathews/data_structures_and_algorithms
/Arrays/examples/insertion_sort.py
439
4.28125
4
""" python implementation of Insertion Sort >>> insertion_sort([3, 2, 1]) [1, 2, 3] """ def insertion_sort(array): """ sort an array of comparable elements in ascending order O(n^2) """ for index in range(1, len(array)): current = array[index] while index > 0 and array[index - 1]> curre...
true
f06dce01ee6561b52c9abd3681fba7c55ddc618c
RodrigoCh99/basic-challenges-in-python-language
/desafio37.py
856
4.3125
4
""" Escreva um programa que leia um número inteiro qualquer e peça para o usuario escolher qual será a base de conversão: """ print('\nESSE PROGRAMA É UM CONVERSOR DE BASES!') print('*'*25) print('Os codigos das bases são:') print('1 para binario,\n2 para octal\n3 para hexadecimal') print('*'*25) n...
false
3845efa0fa83dbbddb300186fbc3b8f7a04daf21
RodrigoCh99/basic-challenges-in-python-language
/desafio55.py
479
4.125
4
print('Esse programa calcula o peso de 5 pessoas e mostra a mais pesada!') pesado = 0 leve = 0 for c in range(1,6): peso = float(input('Informe o peso da {}° pessoa: '.format(c))) if c == 1: pesado = peso leve = peso else: if peso > pesado: pesado = peso ...
false
13aeaa9b88bb275c2cddb52ca10b6574371b8794
RodrigoCh99/basic-challenges-in-python-language
/desafio45.py
1,087
4.1875
4
""" Crie um Programa que faça o computador jogar pedra papel tesoura com voce! """ from random import randint print('\nVamos jogar pedra, papel e tesoura?') numc = randint(1,3) print('-'*25) print('Escolha [1] para pedra\nEscolha [2] para papel\nEscolha [3] para tesoura') print('-'*25) numj = int(inp...
false
8bffdf5b0bbccc50713e33273c9dfd9c678e4e68
leo-0101/exercicios-python
/exercicio_rpg-poo.py
1,963
4.28125
4
class Personagem: # PRECISA SER UM ATRIBUTO BASE PARA NÃO DAR PROBLEMA # vida = 150 mana = 100 inteligencia = 30 forca = 30 agilidade = 30 carisma = 20 def __init__(self, nome): self.nome = nome def atacar(self, inimigo): inimigo.vida -= self.forca print(f'O...
false
17d8341915e5f154a32bc5080e3685999b4a0c70
Sincab/d_s01
/yout-03.py
401
4.25
4
# floor division // ---- 3 // 2 = 1 # exponent ** ---- 3 ** 2 = 9 # modulus % ----- 5 % 3 = 2 # equal 3 == 2 # not equal 3 != 2 # greater or equal 3 >= 2 # smaller or equal 3 <= 2 num_1 = 3 # int num_2 = 3.5 # float num = 1 num = num + 2 print(num) num = 1 num **= 2 print(num) print(abs(-7)) print(round(3.7589, 2)) p...
false
97e9c3f73ab4dfa755eb467fa8bba65f2d4c71f5
epicmonky/Project-Euler-Solutions
/problem020.py
430
4.125
4
# n! means n x (n - 1) x ... x 3 x 2 x 1 # For example, 10! = 10 x 9 x ... x 3 x 2 x 1 = 3628800, # and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. # Find the sum of the digits in the number 100! import math def sum_of_digits(n): s = 0 while n > 0: s += n % 10 ...
true
9f443ffa4598eeb84214fa77e7d6d1a9bfa27e2b
xujundong/demo
/列表.py
1,300
4.3125
4
#申明列表 list1 = ["a","b","c",1,2,3] #打印列表 print(list1) #通过索引获取元素,0开始,-1末尾 print(list1[0]) # a #添加元素("增"append, extend, insert) #append增加元素 list1.append("A") print(list1) #extend列表A增加到列表B list2 = ["aa","bb"] list1.extend(list2) print(list1) #insert在指定位置index前插入元素object----注意是前面 list1.insert(2,"AA") print(list1) #修改元素,...
false
7d734ce53f66b6ffbd13b9a18332428188d0bec3
Lizi2hua/Understanding-Python
/python/Python_base/python基本知识.py
905
4.1875
4
"""python的/y永远返回浮点""" a = 25 b = 5 print(type(a / b)) """floor除法, //得到整数结果""" a1 = 7 a2 = 3 print(a1 // a2) # 2 # 7//3.5=2.0 """转义""" print("\"Yes,\"he said") print("C:\some\name") # \n是换行符,使用r来使用原始字符串 print(r"C:\some\name") """使用 \ 作为连续符""" print("liu\ mengyuan") # liumengyuan """或者这样""" print('liu' ' mengyua...
false
440f7e019f7621b8f497beb4dd3d6156870bfb3c
colehoener/DataStructuresAndAlgorithms
/Hash/open_hash.py
1,809
4.15625
4
#Mark Boady - Drexel University CS260 2020 #Implement an OPEN hash table import random #Hash Functions to test with def hash1(num,size): return num % size def hash2(num,size): x=2*(num**2)+5*num+num return x % size def hash3(num,size): word=str(num) total=0 for x in range(0,len(word)): c=word[x] total=total+...
true
980aeca14a04f2727cd917c4acf0151646b92e52
andresbonett/python-basico
/diccionarios.py
1,026
4.15625
4
def run(): mi_diccionario = { 'llave1': 1, 'llave2': 2, 'llave3': 3, } print(mi_diccionario) # {'llave1': 1, 'llave2': 2, 'llave3': 3} print(mi_diccionario['llave2']) # 2 ############## poblacion_paises = { "Colombia": 50, "Argentina": 44, "Brasil": ...
false
abf112da79470c8d9b14e7d17747ad699858718b
arcPenguinj/CS5001-Intensive-Foundations-of-CS
/homework/HW1/tables.py
1,226
4.25
4
''' Yici Zhu CS 5001, Fall 2020 it's a program calculating how many table can be assembled test cases : 4 tops, 20 legs, 32 screws => 4 tables assembled. Leftover parts: 0 table tops, 4 legs, 0 screws. 20 tops, 88 legs, 166 screws => 20 tables assembled. Leftover parts: 0 table tops, 8 legs, 6 screws. 100 tops, ...
true
e6146ffced7b19a485620bbac781e8cf59774471
arcPenguinj/CS5001-Intensive-Foundations-of-CS
/in_class_excercise/lecture5_inclass_excercise.py
216
4.3125
4
for i in range(0, 6): print (i) for i in range(5, -1, -1): print(i) for i in range(1, 12, 2): print(i) word = "Hello, World" for letter in range(1, len(word), 2): print(word[letter])
false
cc47e4a1c80f09bbeb121b624dc1f5d2fca087f8
arcPenguinj/CS5001-Intensive-Foundations-of-CS
/homework/HW2/exercise.py
1,669
4.21875
4
''' Fall2020 CS 5001 HW2 Yici Zhu it's a program for planning exercise based on different conditions ''' def main(): days = input("What day is it? ").title() holidays = input("Is it a holiday? ").title() rains = input("Is it raining? ").title() temps = float(input("What is the temperatur...
true
a77c1e503d0e39d55e2915962131bad2f0970126
algorithmsmachine/PythonAlgorithms
/misc/factorial.py
256
4.1875
4
num = 90 factorial=1 if num <0: print("cannot print factorial of negative num ") elif num == 0: print("The factorial of 0 is 1") else: for i in range(1,num + 1): factorial = factorial*i print("The factorial of",num," is ",factorial)
true
84a41b50164514518b02a83722820605d0468e0e
prabhakarzha/pythonimportantcode
/main.py
2,146
4.125
4
# reduce() function is not a built-in function anymore ,and it can be found in the functools module from functools import reduce def add(x,y): return x+y list =[2,3,4,5,6] print(reduce(add,list)) # map() function -The map() function iterates through all items in the given iterable # and execute the function...
true
ca3819dc5cd360988f9eb8c2f6f3ae7942ac1446
Gowthini/gowthini
/factorial.py
261
4.28125
4
num=int(input("enter the number")) factorial=1 if num<0: print("factorial does not exist for negative numbers") elif num==0: print("The factorial is") else: for i in range(1,num+1): factorial=factorial*i print("The factorial of"num,"is",factorial)
true
d33fb48a41a852ab3d3bfcb4624e7693dad18f9c
jwmarion/daily
/euler/35multiple.py
427
4.21875
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # # Find the sum of all the multiples of 3 or 5 below 1000. multiples = [] result = 0 for x in range(0,1000): if x % 3 == 0: multiples.append(x) if x % 5 == 0 and x % 3 !...
true
d19cef12494dc50a7beb21a625a23823ce93d98c
eghadirian/Python
/P10-FindTwoElements.py
377
4.15625
4
# find the if sum of two elements is a value # find pythagoream triplets def sum_of_two(arr, val): found = set() for el in arr: if val - el in found: return True found.add(el) return False def func(arr): n = len(arr) for i in range(n): if sum_of_two(arr[:i]+arr[i+...
true
e358e998f4b59281e990ffd5b41dc2ecc81db548
devpatel18/PY4E
/ex_05_02.py
484
4.21875
4
largest=None smallest=None while True: num1=input("Enter a number:") if num1=="done": break try: num=int(num1) except: print("Please enter numeric value") continue if largest is None: largest=num elif num>largest: largest=num if ...
true
109af5cbe8647fef80c83a92b088cbe77505d3ce
joelmedeiros/studies.py
/Fase12/Challange37.py
385
4.125
4
number = int(input('Write a number ')) base = int(input('''Chose an option: \n 1 - binary 2 - octal 3 - hexadecimal ''')) if base == 1: print("The number {0} in binary is {0:b}".format(number)) elif base == 2: print("The number {0} in octal is {0:o}".format(number)) elif base ==3: print("The number {0} in ...
false
a6d8a0779cfc7092ef6f8651f0b8bc9ab9da774c
joelmedeiros/studies.py
/Fase7/Challange6.py
265
4.28125
4
number = int(input("Tell me the number you want to know the double, triple and square root: ")) double = number*2 triple = number*3 sqrt = number**(0.5) print("The double of {} is {} and the triple is {} and the sqrt is {:.2f}".format(number, double, triple, sqrt))
true
8907a33161a9922cca2925059520c857ee7c4451
Jay-mo/Hackerrank
/company_logo.py
1,604
4.53125
5
""" A newly opened multinational brand has decided to base their company logo on the three most common characters in the company name. They are now trying out various combinations of company names and logos based on this condition. Given a string S, which is the company name in lowercase letters, your task is to find...
true
a163cf56718a5fe33b00f120073ba193292a5933
VickeeX/LeetCodePy
/desighClass/ShuffleArray.py
1,198
4.25
4
# -*- coding: utf-8 -*- """ File name : ShuffleArray Date : 18/05/2019 Description : 384. Shuffle an Array Author : VickeeX """ import random class Solution: def __init__(self, nums: list): # # trick # self.reset = lambda: nums # self.shuffle ...
true
cea604980474aeb6996ab3b925b4c1fe8dc17cd2
Qurbanova/PragmatechFoundationProjects
/Algorithms/week09_day04.py
2,679
4.5625
5
# 1)Write a Python function to sum all the numbers in a list. Sample List : (8, 2, 3, 0, 7) Expected Output : 20 # 2)Write a Python function to multiply all the numbers in a list. Sample List : (8, 2, 3, -1, 7) Expected Output : -336 # 3)Write a function called returnDay. This function takes in one parameter ( a numbe...
true
7dc89b6e60710ae6437519899cb6e3520e6cf53f
nandhinipandurangan11/CIS40_Chapter4_Assignment
/CIS40_Nandhini_Pandurangan_P4_9.py
664
4.15625
4
# CIS40: Summer 2020: Chapter 4 Assignment: Problem 9 : Nandhini Pandurangan # This program reads a string and prints the string in reverse. # print_reverse() reads user input and prints it in reverse def print_reverse(): string = input("Please enter a word: ").strip() for i in range(len(string) - 1, -1, -1)...
true
a9be48c1b64fc1dfdf33f58b9d6c35f8b9caae1a
sich97/WakeyWakey
/server/server_setup.py
2,149
4.375
4
""" File: server_setup.py This file creates / or resets the server database. """ import sqlite3 import os DATABASE_PATH = "server/db" def main(): """ In the case that a database already exists, ask the user if it's really okay to reset it. If no, then do nothing and exit. If yes, delete the existing da...
true
8a2e5a2ed33489e1db0dc410db6cc3aa8e083f44
sweekar52/APS-2020
/Daily-Codes/Median of an unsorted array using Quick Select Algorithm.py
2,067
4.15625
4
# Python3 program to find median of # an array import random a, b = None, None; # Returns the correct position of # pivot element def Partition(arr, l, r) : lst = arr[r]; i = l; j = l; while (j < r) : if (arr[j] < lst) : arr[i], arr[j] = arr[j],arr[i]; i += 1; j += 1; arr[i], arr[r] = a...
true
fa9b017ec497e894b7222af17575ad0abe015f52
sajaram/Projects
/text_adventure_starter.py
1,609
4.375
4
start = ''' You wake up one morning and find that you aren’t in your bed; you aren’t even in your room. You’re in the middle of a giant maze. A sign is hanging from the ivy: “You have one hour. Don’t touch the walls.” There is a hallway to your right and to your left. ''' print(start) print("Type 'left' to go left ...
true
bb7219177527b96c77d15869c247ad16615a0693
sagdog98/PythonMiniProjects
/Lab_1.py
2,248
4.34375
4
# A list of numbers that will be used for testing our programs numbers = [1, 2, 3, 4, 5, 6, 7, 8] # Question 1: Create a function called even, which takes in an integer as input and returns true if the input is even, and false otherwise def even(num): # Provide your code here return True if num % 2 == 0 else F...
true
61fe504a5f0ef1f70db4799e6901f84b8e9f3333
roince/Python_Crash_Course
/Mosh_Python/guessing_game.py
1,073
4.125
4
chance = 3 # get a myth number, and check : whether it is a number and whether it is in # range (0-9) myth = input("your myth number: ") if myth.isdigit(): myth = int(myth) if myth > 9 or myth < 0: print("please enter a number in range (0-9)") quit() else: print("only numbers are allowed!") ...
true
d331294da6be5b723d9ee85d749f692c4d6b5d70
maximkavm/ege-inf
/23/Количество программ с обязательным этапом/8 - 13749.py
476
4.21875
4
""" Сколько существует программ, для которых при исходном числе 2 результатом является число 12 и при этом траектория вычислений программы содержит числа 8 и 10? +1 +2 *3 """ def f(x, y): if x < y: return f(x + 1, y) + f(x + 2, y) + f(x * 3, y) elif x == y: return 1 else: return 0 print(f(2, 8) * f(8, 10) *...
false
d3c4602b79623679ac3a07bdd09ff55eeb222b8f
lorenzobrazuna/cursopython
/exer33.py
365
4.125
4
num1 = int(input('Digite o numero 1: ')) num2 = int(input('Digite o numero 2: ')) num3 = int(input('Digite o numero 3: ')) if (num1 > num2): maior = num1 menor = num2 else: maior = num2 menor = num1 if maior < num3: maior = num3 elif menor > num3: menor = num3 print('O numero {} é o maior, e ...
false
434e727b3400f54428c65c146ec4e44eab74bc6c
Lewis-blip/python
/volume.py
233
4.125
4
pie = 3.14 radius = int(input("input radius: ")) height = float(input("input height: ")) rradius = radius**2 volume = pie * rradius * height final_volume = volume//1 print("the volume of the cyclinder is ", final_volume, "m^3")
true
9962385de6e1191e9e664a4ad9b9be20a55e2a79
fccoelho/PH-Translations
/Manipulating-Strings-Python/codigo_teste.py
1,960
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 2 16:56:08 2021 @author: Felipe Marques Esteves Lamarca Script teste dos códigos da tradução para o português da lição "Manipulating Strings in Python" do The Programming Historian. """ # ------------------------------------- mensagem = "Olá Mun...
false
2e3a8be86da4c724d636afc20f3dbf784c23b6c5
Snafflebix/learning_python
/ex9.py
507
4.125
4
# Here's some new strange stuff, remember type it exactly days = "Mon Tue Wed Thu Fri Sat Sun" #this makes each thing after \n on a new line months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" #this puts days after the string with a space print "Here are the days: ", days print "Here are the months: ", months print "...
true
608b3cff314db322da9d826b8491f8d3d9026796
ranog/python_work
/capitulo_03-Introducao_as_listas/nomes.py
283
4.125
4
# 3.1 - Nomes: # Armazene os nomes de alguns de seus amigos em uma lista chamada # names. Exiba o nome de cada pessoa acessando cada elemento da lista, # um de cada vez. nomes = ["joao", "paulo", "joao paulo", "paulo joao"] print(nomes[0]) print(nomes[1]) print(nomes[2]) print(nomes[3])
false
f023205fbfb15d2d12ee1460cb13ab31a27e504b
shalemppl/PythunTuts
/Tuples.py
2,143
4.59375
5
# Tuples are similar to lists, but once a tuple is created it cannot be changed #List (created with []) mylist = [1, 2, 3] print(mylist) mylist[2] = 4 print(mylist) #Tuple (created with ()) mytuple = (1, 2, 3) print(mytuple) #mytuple[2]=4 would result in a traceback, as an item within a tuple cannot be changed #So w...
true
4a3c26ab8368289cdb8e20912c26def8660bdd52
AFishyOcean/py_unit_five
/fibonacci.py
482
4.34375
4
def fibonacci(x): """ Ex. fibonacci(5) returns "1 1 2 3 5 " :param number: The number of Fibonacci terms to return :return: A string consisting of a number of terms of the Fibonacci sequence. """ fib = "" c = 0 a = 0 b = 1 for x in range(x): c = a + b a = b ...
true
21d9d56ea3e130d01489144c7e118a9bb147e21b
tatianimeneghini/exerciciosPython_LetsCode
/Aula 2/exercicio1.py
348
4.1875
4
numero1 = int(input("Insira um número ")) numero2 = int(input("Insira um número ")) if numero1 > numero2: print("O número " , numero1 , " é maior que o número " , numero2) elif numero1 < numero2: print("O número " , numero1 , " é menor que o número " , numero2) else: print("O número " , numero1 , " é igual que o nú...
false
31bb7ccdea6104bfacbd18e099f0935b3bc2d0e7
eecs110/spring2020
/course-files/lectures/lecture_04/in_class_exercises/08_activity.py
869
4.15625
4
# Write a function that prints a message for any name # with enough stars to exactly match the length of the message. # Hint: Use the len() function. def print_message(first_name:str, symbol:str='*'): message = 'Hello ' + first_name + '!' print(symbol * len(message)) print(message) print(symbol * len(...
true
d740731f12f6aff6f7175086263f0c9308b43b4a
eecs110/spring2020
/course-files/lectures/lecture_03/challenge_problem_2.py
1,900
4.34375
4
from tkinter import Canvas, Tk ##################################### # begin make_grid function definition ##################################### def make_grid(canvas, w, h): interval = 100 # Delete old grid if it exists: canvas.delete('grid_line') # Creates all vertical lines at intevals of 100 fo...
true
3d2de0860b3c106661671232cffcef522c187993
liturreg/blackjack_pythonProject
/deck.py
2,389
4.125
4
import random card_names = { 1: "Ace", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine", 10: "Ten", 11: "Jack", 12: "Queen", 13: "King" } card_suits = { 0: "Hearts", 1: "Diamonds", 2: "Clubs", 3: "Spades" } def generate_deck_dict()...
true
eee192feba564a8682d06b98c26abc33c0c31a38
alisiddiqui1912/rockPaperScissors
/Rock Pap S/finalVersion.py
1,229
4.34375
4
import random player_win = 0 computer_win = 0 win_score = input("Enter the Winning Score: ") win_score = int(win_score) while win_score > player_win and win_score > computer_win: print(f"Your Score:{player_win},Computer Score:{computer_win}") player = input("Make your move: ").lower() rand_num = random....
true
a3f70a3c9d8b47aa53eaa3ca9c4337b9b7bb4d2e
vukasm/Problem-set-2019-Programming-and-Scripting-
/question-vii.py
619
4.46875
4
#Margarita Vukas, 2019-03-09 #Program that takes a positive floating number as input and outputs an approximation of its square root. #This will import math module. import math #Asking user to enter a positive floating number which will be tha value of f. f=float(input("Please enter a positive number:")) #Using...
true
eee3e14ebd6c8df03effc41e02b8abb0784b5f05
musflood/code-katas
/direction-reduction/dir_reduct.py
1,666
4.25
4
"""Kata: Directions Reduction. #1 Best Practices Solution by Unnamed and others opposite = {'NORTH': 'SOUTH', 'EAST': 'WEST', 'SOUTH': 'NORTH', 'WEST': 'EAST'} def dir_reduct(plan): new_plan = [] for d in plan: if new_plan and new_plan[-1] == opposite[d]: new_plan.pop() else: ...
true
ebb7e4b3143c89f27a322cd6adaf718a37115d7c
musflood/code-katas
/string-pyramid/string_pyramid.py
2,807
4.25
4
"""Kata: String Pyramid. #1 Best Practices Solution by zebulan def watch_pyramid_from_the_side(characters): if not characters: return characters width = 2 * len(characters) - 1 output = '{{:^{}}}'.format(width).format return '\n'.join(output(char * dex) for char, dex in zip...
true
f3b7fb3044363da065c2e7e85fc0efeb46eaf89e
Ifeoluwakolopin/ECX-30daysofcode-2020
/code files/Ifeoluwa_Are_day23.py
897
4.34375
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 17 17:14:20 2020 @author: TheAre """ def find_Armstrong(start, end): '''This function takes in two integers indicating the start and end of an interval it returns the armstrong numbers within that interval. Note: An armstrong number is a number that is...
true
73ecc8d7a746aa750721f0fc79e3d80ea5db1098
Ifeoluwakolopin/ECX-30daysofcode-2020
/code files/Ifeoluwa_Are_day6.py
411
4.3125
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 31 18:07:11 2020 @author: TheAre """ import itertools def power_list(list1: list): ''' Takes in a list and returns the corresponding power list of the list''' pow_list = [] for i in range(len(list1)+1): for j in itertools.combinations(list1...
true
55c3a23948c26489410b73cb44ee07a42a249c67
UchechiUcheAjike/programming_with_functions
/checkpoint_02_boxes.py
922
4.4375
4
#A manufacturing company needs a program that will help its employees # pack manufactured items into boxes for shipping. Write a Python # program named boxes.py that asks the user for two integers: 1) # the number of manufactured items and 2) the number of items that # the user will pack per box. Your program must...
true
62c46356a8e61d296ca3f6cf44723477950d6a44
FrenchBear/Python
/Learning/130_Fluent_Python/fp2-utf8/blocinteractive/example 2-22.py
517
4.375
4
# Example 2-22. Basic operations with rows and columns in a numpy.ndarray >>> import numpy as np >>> a = np.arange(12) >>> a array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) >>> type(a) <class 'numpy.ndarray'> >>> a.shape (12,) >>> a.shape = 3, 4 >>> a array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ ...
false
67610b84cdcde5d34e0a974c544262fb7871922a
FrenchBear/Python
/Pandas/base2.py
531
4.71875
5
# Learning Pandas # 2021-03-01 PV # https://www.learndatasci.com/tutorials/python-pandas-tutorial-complete-introduction-for-beginners/ import pandas as pd data = { 'apples': [3, 2, 0, 1, 4, 3], 'oranges': [0, 3, 7, 2, 5, 0] } # Create from scratch # Each (key, value) item in data corresponds to a column ...
true
65f6092cc51de46f8dd6cabbba3594df83c11ec2
FrenchBear/Python
/Learning/107_Multiple_Constructors/a_newinit.py
680
4.375
4
# Play with Python contructors # 01 Refresher about __new__ and __init__ # # 2022-03-19 PV # A base class is object, identical to class A(object): class A: def __new__(cls): print("Creating instance of A") return super(A, cls).__new__(cls) # Should return None def __init__(self): ...
true
c40ebfa80afc506486e4818d013a524c499f7d37
FrenchBear/Python
/Learning/013_Arrays/13_Arrays.py
1,664
4.4375
4
# Arrays # Learning Python # 2015-05-03 PV # Simple array myList = [] for i in range(10): # mylist[i]=1 # IndexError: list assignment index out of range myList.append(1) myList = [i*i for i in range(10)] # Array of squares [0, ..., 81] # Creates a list containing 5 lists initialized to 0 using ...
true
4fb893b494e6206e6125d67f4af89fd65b4d5610
Som94/Python-repo
/20 july/Test 1.py
1,347
4.1875
4
def proverb1(): print ('from func proverb1 --- God\'s mill grinds slow but sure ') def proverb2(): print ('from func proverb2 --- All THAT GLITTERS IS NOT GOLD ') def greet(): print ('welcome ...good day') print ('happy to note that all is well ') def add(a,b): if ((a > 9 and a < ...
false
73e2c938ecb79fc89af46158f1f448c90ec10a31
Som94/Python-repo
/14 July/test-4.py
939
4.125
4
''' 1) union a union b ''' a = {12,55,66,77} b = {10,12,25,55} # 12,55,66,77,10,25 (12,55 are common HENCE APPEARS once) print('union',a.union(b)) ''' 2) intersection a intersection b a = {12,55,66,77} b = {10,12,25,55} o/p 12,55 (which are common in a and b) ''' prin...
false
fe32573df0314ce6dc03a27a607ce75fa63ca174
Som94/Python-repo
/display no of 2nd n 4th saturday in given range of date.py
908
4.125
4
""" Given two dates d1 to d2 ( both inclusive) Print all the 2nd and 4th Saturdays Count how many are there? """ import datetime print("Enter dates input format example: 8 Feb 2021") date_start_str = '20 Feb 2010' #input("Enter start date: ") date_end_str = '12 Dec 2011' # input("Enter end date: ") # convert string...
true
c878f65bfb95acf1b9495ad2cbb0f9c66e42c6a7
Som94/Python-repo
/9th july/Largest nad smallest among 3 numbers.py
907
4.28125
4
''' Input 3 numbers from user and find out highest and lowest number among them ''' fist_number=int(input("Enter first number : ")) second_number=int(input("Enter second number : ")) third_number=int(input("Enter third number : ")) if fist_number>second_number and second_number>third_number: print("highest number ...
false
7ce7a8f93858d069aec1cb98d795f07c9c506a88
Som94/Python-repo
/21st july/Assignment 2.txt
506
4.25
4
''' Take several input from user as string , check wether it is palindrome or not store into a dictionary as if it is palindrome assign the value as true else assign false {'liril': True, 'abc' : False} And so on ''' def palindrome(n): for i in range(n): str1=input("Enter any String :") if st...
true
50063f065de4c19c68024ee8410f49a68456dd80
polinaya777/goit-python
/python_1/lesson_02/hw_03.py
1,089
4.34375
4
flag = True while (flag): num_1 = input('Enter number 1: ') try: num_1 = int(num_1) except ValueError: print(f"Number {num_1} is not a number") else: flag = False flag = True while (flag): num_2 = input('Enter number 2: ') try: num_2 = int(num_2) except Value...
true
0d56bd057ee09a9eddf0d6079cfc31129e576c33
diazinmotion/LearnCode
/Python/Part I/06. Conditions/IFElseComparison.py
730
4.28125
4
## # IFElseComparison.py # Simple if else (conditions) with comparison example # # @package LearnCode # @author Dimas Wicaksono # @since 2018-15-25 ## # create a function def max_number(num1, num2, num3): if num1 >= num2 and num1 >= num3: return num1 elif num2 >= num1 and num2 >= num3: ...
false
45e96a7a37eb0e6c7ecf0c6779426d83266b2c00
pkoarmy/Learning-Python
/sorting/sorting.py
684
4.40625
4
# Sort in Python def sort(array): # run loops two times: one for walking through the array # and the other for comparison for i in range(len(array)): for j in range(0, len(array) - i - 1): # To sort in descending order, change > to < in this line. if array[j] > array[j + 1]: ...
true
a7bb9bd5fa9535112126b900f360f4cd1978b685
Monsteryogi/Python
/string_methods.py
308
4.4375
4
#string methods used for manuputlating the Strings word=input("Enter the string:") lenght_word=len(word) upper_case=word.upper() lower_case=word.lower() print ("Lenth of String: %s" %(lenght_word)) print ("Upper case of String: %s" %(upper_case)) print ("Lower case of String: %s" %(lower_case))
true