blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
af32739412f82b395268bf8a13e89b42184a8bb8
ton4phy/hello-world
/Python/59. Cycles.py
817
4.125
4
# Exercise # Implement the is_arguments_for_substr_correct predicate function, which takes three arguments: # the string # index from which to start extraction # extractable substring length # The function returns False if at least one of the conditions is true: # Negative length of the extracted substring # Negative...
true
967788a456b5c57b5b5e48a71c2b70fafec26114
patilsakshi123/python.fun
/fibonacci sequence.py
379
4.28125
4
nterms= int(input("how many terms:")) n1,n2= 0,1 count=0 if nterms <=0: print("please enter a positive integer:") elif nterms ==1: print("Fibonacci sequence upto", nterms ,":") else: print("Fibonacci sequence :") while count < nterms : print(n1) nth =n1+n2 n1=n2 ...
false
bd152a5e10c36bfc628bcd88b405966b3741c0c2
Chriskoka/Kokanour_Story
/Tutorials/mathFunctions.py
557
4.28125
4
""" Math Functions """ #Variables a = 3 b = -6 c = 9 #Addition & Subtraction print(a+b) print(a-b) #Multiplication & Division print(a * b) print(a / b) #exponents print(a ** b) # Notice ** means to the power of print(b ** a) #Square Root & Cube Root print(c ** (1/3)) print(c ** (1/2)) #Modulus (% symbol is us...
true
20ffa4780a571b56cd17304dde237f4a4fb7eed5
Chriskoka/Kokanour_Story
/Tutorials/addSix.py
233
4.3125
4
""" This program will take the input of the user and return that number plus 6 in a print statement """ numb = int(input ('Choose an integer from 1 to 10. Input: ')) print ('The number ' + str(numb) + ' plus six = ' + str(numb + 6))
true
0838e7bca4295999e847c41b218bd1b5b928e6c1
josandotavalo/OSSU
/001-Python-for-Everyone/Exercise-9.5.py
814
4.15625
4
# Exercise 5: Write a program to read through the mail box data and when you find line that starts # with “From”, you will split the line into words using the split function. We are interested in who # sent the message, which is the second word on the From line. # You will parse the From line and print out the second...
true
40626631a907c84562a9cb5d4fc47b0aab78da5f
Edward-Lengend/python
/PycharmProjects/11面向对象/py_18_类属性.py
1,178
4.4375
4
""" 类属性就是类对象所拥有的属性,它被该类的所有实例对象所共有。 类属性可以使用类对象或实例对象访问。 类属性的优点 ·记录的某项数据始终保持一致时,则定义类属性。 ·实例属性要求每个对象为其单独开辟一份内存空间来记录数据, 而类属性为全类所共有,仅占用一份内存,更加节省内存空间。 """ # 1.定义类, 定义类属性 class Dog(object): tooth = 10 # 2.创建对象 wangcai = Dog() xiaoqi = Dog() # 3.访问类属性和类对象 print(Dog.tooth) # 类属性可以通过类访问 print(wangcai.tooth) print(xi...
false
7ae4b8e3485df6a76e0fbd3a931c119e698e04f0
Palmerlxp/lxf_learn
/s2.py
562
4.125
4
height=input('身高:') weight=input('体重:') h=float(height) w=float(weight) bmi=w/(h*h) #bmi=w/h**2 另一种平方的写法 if bmi<18.5: print('过轻') elif bmi>18.5 and bmi<25: print('正常') elif bmi>25 and bmi<28: print('过重') elif bmi>28 and bmi<32: print('肥胖') else: print('严重肥胖') #other way height=1.75 weight=80.5 BMI...
false
7b9277b29346c58baf1e8c15068bb2894ab4043d
mohit-singh4180/python
/datatypes/Dictionary.py
1,085
4.59375
5
#Dictionary holds key:value pair. # Creating an empty Dictionary Dict = {} Dict1={"Name": "Mohit", "EMPID":122333, "test_values":[1,2,3,4,5,6,7,8,9,10]} print(Dict) # Creating a Dictionary # with each item as a Pair Dict3 = dict([(1, 'Name'), (2, 'Age')]) print(Dict) # Creating a Nested Dictionary # as shown in the b...
false
ce6840467ee5ec0a8cb7748bd7441527b6fad2da
mohit-singh4180/python
/string operations/StringLogical operation.py
645
4.3125
4
stra='' strb='Singh' print(repr(stra and strb)) print(repr(stra or strb)) stra='Mohit' print(repr(stra and strb)) print(repr(strb and stra)) print(repr(stra or strb)) print(repr(not stra)) stra='' print(repr(not stra)) # A Python program to demonstrate the # working of the string template from string import Tem...
true
ea291fcdc704b8133b4b0ef66f3883c251776399
gonegitdone/MITx-6.00.2x
/Week 5 - Knapsack and optimization/L9_Problem_2.py
1,897
4.15625
4
# ==============L9 Problem 2 ================= ''' L9 PROBLEM 2 (10 points possible) Consider our representation of permutations of students in a line from Problem 1. In this case, we will consider a line of three students, Alice, Bob, and Carol (denoted A, B, and C). Using the Graph class created in the lecture, we c...
true
38829c600a52bf5e486d20efb568254283f46f36
patezno/ejercicios-propuestos
/ejercicio06.py
865
4.25
4
# Escribe un programa que pida por teclado dos valores de tipo numérico # que se han de guardar en sendas variables. ¿Qué instrucciones # habría que utilizar para intercambiar su contenido? (es necesario utilizar # una variable auxiliar). Para comprobar que el algoritmo ideado es correcto, # muestra en pantalla el ...
false
a05b26542169a4cb883d87c62baee613856ece9d
CallieCoder/TechDegree_Project-1
/01_GuessGame.py
938
4.125
4
CORRECT_GUESS = 34 attempts = [1] print("Hello, welcome to the Guessing Game! \nThe current high score is 250 points.") while True: try: guess = int(input("Guess a number from 1 - 100: ")) except ValueError: print("Invalid entry. Please enter numbers as integers only.") else: if guess < 1 or guess > 100: ...
true
28b749e2ea944bcd4e56112453fd2b9836da0cca
amrfekryy/daysBetweenDates
/daysBetweenDates.py
1,800
4.375
4
# Given your birthday and the current date, calculate your age # in days. Compensate for leap days. Assume that the birthday # and current date are correct dates (and no time travel). # Simply put, if you were born 1 Jan 2012 and todays date is # 2 Jan 2012 you are 1 day old. def isLeapYear(year): """returns T...
true
b1545d03a2ae61fa8c7858f14183f60ff9ff4493
joshp123/Project-Euler
/4.py
460
4.21875
4
def isPalindrome(string): if string == string[::-1]: return 1 # string reversed = string else: return 0 # not a palindrome palindromes = [] for num1 in xrange(999, 100, -1): for num2 in xrange(999, 100, -1): product = num1 * num2 if isPalindrome(str(product)) == 1: ...
true
5da058b165afd4f385ade8342eaaa56e00c19e77
sfvitor/monitoria
/processo_selecao/prova/q1.py
2,375
4.1875
4
# Prova de Monitoria para Fundamentos da Computacao # Questao #1 # Aluno: Vitor Fernandes # caso o numero seja triangular, retorna os 3 inteiros positivos # consecutivos que, multiplicados, sao iguais ao numero informado # caso contrario, retorna None def numero_triangular(numero): # loop percorrendo todos os inte...
false
e805d017fb69438e5cf968288dfd77488a00246f
zjuKeLiu/PythonLearning
/GUI.py
1,306
4.21875
4
import tkinter import tkinter.messagebox def main(): flag = True #change the words on label def change_label_text(): nonlocal flag flag = not flag color, msg = ('red', 'Hello, world!')\ if flag else ('blue', 'Goodbye, world') label.conflg(text = msg, fg = color)...
true
1603adb378d36caaba42ea862482e4810f3591b2
igusia/python-algorithms
/binary_search.py
452
4.125
4
import random #searching for an item inside a search structure def binary_search(search, item): low = 0 high = len(search)-1 while low <= high: mid = (low + high)//2 #if odd -> returns a lower number guess = search[mid] if guess < item: low = mid+1 #it's not mid, so we d...
true
cd70df45ab8f7635e3e4d4ae38fed02e8bab4e51
oluyalireuben/python_workout
/session_one.py
1,398
4.25
4
# getting started print("Hello, World!") # syntax if 5 > 2: print("Five is greater than two") # Variables x = 23 y = 45 print(x + y) a = "python " b = "is " c = "awesome" print(a + b + c) u = "I like " j = "Codding " k = "with python language" print(u + j + k) # python numbers and strings h = "Welcome to eMobi...
true
090435b9cf27a02233288045250d90f4181f4b9b
Maciejklos71/PythonLearn
/Practice_python/palidrom.py
635
4.4375
4
#Ask the user for a string and print out whether this string is a palindrome or not. # (A palindrome is a string that reads the same forwards and backwards.) def palidrom(string): string = string.lower().replace(" ","") for i in range(0,len(string)): if string[i]==string[-i-1]: if i ==...
true
692d14e3fea32a798eb19731e5d2b214fa40dcdc
robado/automate-the-boring-stuff-with-python
/2. Flow Control/5. If, Else, and Elif Statements.py
1,216
4.1875
4
# if statement name = 'Alice' if name == 'Alice': print('Hi Alice') print('Done') # Hi Alice # Done # if name is other than Alice than the output will beDone # else statement password = 'swordfish' if password == 'swordfish': print('Access granted.') else: print('Wrong password.') # If password is swordfis...
true
dd109d0231382f4680d93159ac106fe0f9d2e0b0
scarletgrant/python-programming1
/p9p1_cumulative_numbers.py
593
4.375
4
''' PROGRAM Write a program that prompts the user for a positive integer and uses a while loop to calculate the sum of the integers up to and including that number. PSEUDO-CODE Set and initialize number to zero Set and initialize total to zero Prompt user for first positive integer While number => 0: total += numb...
true
340b1481b39b4ed272b3bd09ad648f933570e7de
scarletgrant/python-programming1
/p8p3_multiplication_table_simple.py
415
4.3125
4
''' PROGRAM p8p3 Write a program that uses a while loop to generate a simple multiplication table from 0 to 20. PSEUDO-CODE initialize i to zero prompt user for number j that set the table size while i <= 20: print(i, " ", i*j) increment i+=1 print a new line with print() ''' i = 0 j = int(input("Please...
true
3bfb8410e8a4e2b498ed3387833a74ed905088e3
scarletgrant/python-programming1
/p10p1_square_root_exhaustive_enumeration.py
1,305
4.25
4
''' PROGRAM Write a program that prompts the user for an integer and performs exhaustive enumeration to find the integer square root of the number. By “exhaustive enumeration”, we mean that we start at 0 and succcessively go through the integers, checking whether the square of the integer is equal to the number entered...
true
707e0ea61e1f821b44b7225c5e287a6645a04815
LucaDev13/hashing_tool
/hashing/hash_text.py
1,252
4.1875
4
from algoritms import sha1_encryption, sha224_encryption, sha256_encryption, sha512_encryption, md5_encryption, \ sha3_224_encryption print("This program works with hashlib library. It support the following algorithms: \n" "sha1, sha224, sha256, sha512, md5, sha3_224\n") print("In order to use this program ...
true
97d524a37d3d43918209824c6601eb58d1a0d723
tripaak/python
/Practice_Files/closestPowerTo2.py
533
4.25
4
# closest power to 2: find number greter than or equal to n whose submission make closest number to power of 2 # input = 3 # output = 5 because 3 + 5 = 8 = 2 power to 3 # 3 --> 3 + 4 --> 7 check if mod with 2 is 0 --> if yes return 4 else --> 3 + 5 --> check 8 % 2 == 0 def closestPowerToTwo(n): closest_num =...
false
47208a23d4ea29f0ad4cf605d0ded3aa4c4ca495
tripaak/python
/Practice_Files/cube_finder.py
638
4.1875
4
# Execercise # Define a Function that takes a number # return a dictionary containing cubes of number from 1 to n # example # cube_finder(3) # {1:1, 2:8, 3:27} ####### First approach # def cube_finder(input_number): # dNumb = {} # for j in range(1,input_number + 1): # vCube = 1 # for i in...
true
e8f93243c5fdb8b236abf3defd638a338884ca14
vibhor-shri/Python-Basics
/controlflow/Loops.py
400
4.34375
4
separator = "============================" print("Loops in python") print("There are 2 types of loops in python, for loops and while loop") print(separator) print() print() print("A for loop, is used to iterate over an iterable. An iterable is an object which returns one of it's elements " "at a time") cities =...
true
87ad826d00f46ec7c95d21c87b3387bb42f60f21
Uncccle/learning-python1
/2.注释&输出.py
546
4.21875
4
#python的注释分为两类 #单行和多行 #单行 # #多行 """ """ #dsmfsd """ sdkf """ #注释解释器是不运行的 #---------------------------------------# # 打印输出 # a="啦啦啦啦" b=22222 c=1.1 #第一种: print(a) print(b) print(c) #第二种: print(f'{a}') print(f'{b}') print(f'{c}') #第三种: print("%s" % a) #当为字符串时,应该用s print("...
false
8d271335108f2e82d4cd1bb0643710deba3caaaf
vids2397/vids2397
/Day 1/exercise4.py
376
4.25
4
n1 = int(input("Enter 1st number: ")) n2 = int(input("Enter 2nd number: ")) n3 = int(input("Enter 3rd number: ")) if n1 > n2 and n1 > n3: print('%d is the biggest number.' % n1) elif n2 > n1 and n2 > n3: print('%d is the biggest number.' % n2) elif n3 > n2 and n3 > n1: print('%d is the biggest number.' % n3) else: ...
false
3817df8619e45824b2a425b5e2768bd6d8989b40
curtisjm/python
/personal/basics/functions.py
1,210
4.46875
4
# declare a function def my_function(): print("Hello from a function") # call a function my_function() # arbitrary arguments # if you do not know how many arguments that will be passed into your function, # add a * before the parameter name in the function definition # this way the function will receive a tuple of ...
true
7de2665bd9b5d91fab286fd7b09c4172d85363ad
curtisjm/python
/personal/basics/inheritance.py
1,890
4.5625
5
# create a parent class class Person: def __init__(self, fname, lname): self.firstname = fname self.lastname = lname def printname(self): print(self.firstname, self.lastname) x = Person("John", "Doe") x.printname() # to create a class that inherits the functionality from another class, # send the parent cla...
true
ea5f66e0cb2fc04de9dfa1b1e7ab64f34698c6ce
Rokuzz/conversion-de-unidades-longitud
/operacions.py
2,070
4.1875
4
def programa(): pregunta_inicial = input("Escriba que operación matematica que usted quiera utilizar: ") if pregunta_inicial == "+": sum1 = int(input("Escribe el primer numero que quieras sumar: ")) sum2 = int(input("Ahora escribe el otro numero que quieras sumar: ")) print("La su...
false
f0c27da11efe0dfda2bc81b296bedfdc64303b2b
chettayyuvanika/Questions
/Easy/Pascals_Triangle_Problem.py
1,236
4.28125
4
# Problem Name is Pascals Triangle PLEASE DO NOT REMOVE THIS LINE. """ /* ** The below pattern of numbers are called Pascals Triangle. ** ** Pascals Triangle exhibits the following behaviour: ** ** The first and last numbers of each row in the triangle are 1 ** Each number in the triangle is the sum of t...
true
0311c673ba64df27b3acf07c4ade56ebbc823a87
chettayyuvanika/Questions
/Medium/Best_Average_grade_Problem.py
1,820
4.1875
4
# Problem Name is &&& Best Average Grade &&& PLEASE DO NOT REMOVE THIS LINE. """ Instructions: Given a list of student test scores, find the best average grade. Each student may have more than one test score in the list. Complete the bestAverageGrade function in the editor below. It has one parameter, scores, ...
true
ec304864d363af08d7245df034c786523674b85d
kornel45/basic_algorithms
/quick_sort.py
533
4.15625
4
#!/usr/bin/python import random def quick_sort(lst): """Quick sort algorithm implementation""" if len(lst) < 2: return lst pivot = lst[random.randint(0, len(lst) - 1)] left_list = [] right_list = [] for val in lst: if val < pivot: left_list.append(val) elif ...
true
a7faa8c5043ecf8405c113f3ef1b7e21bc690dc9
TarSen99/python3
/lab7_3.py
1,163
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def UI_input_string() -> str: '''Function input string''' checkString = input("Enter some string ") return checkString def UI_print_result(result: bool): '''Print result''' if result: print("String is correct") else: print("String is NOT correct") ...
true
875bb31378cf1de15998763dc39d985c906bd6d3
TarSen99/python3
/lab8_2.py
758
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import random def set_size() -> int: '''inputs size''' size = int(input("Enter size of list ")) return size def print_sorted(currList: list): '''print sorted list''' print(currList) def generate_list(size: int) -> list: '''generate list''' cu...
true
a51cbcf803b13929c0737ba36c30c2a189ec650b
TarSen99/python3
/lab52.py
552
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- print('Enter 2 dimensions of the door') width = int(input()) height = int(input()) print('Enter 3 dimensions of the box') a = int(input()) b = int(input()) c = int(input()) exist = False if (width > a and height > b) or (width > b and height > a): exist = True el...
true
9a1ddd72238f9b770e0e6754f82a6d1348ab757a
SakiFu/sea-c28-students
/Students/SakiFu/session03/pseudocode.py
991
4.3125
4
#!/usr/bin/env python This is the list of donors donor_dict = {'Andy': [10, 20, 30, 20], 'Brian': [20, 40, 30], 'Daniel': [30, 40,10, 10, 30]} prompt the user to choose from a menu of 2 actions: 'Send a Thank You' or 'Create a Report'. If the user chose 'Send a Thank You' Prompt for a Full Name. ...
true
ad43d34ca563c60c7987d0a02de482407b558d99
liberdamj/Cookbook
/python/ShapesProject/shape/circle.py
948
4.1875
4
# Circle Class import math class Circle: # Radius is passed in when constructor called else default is 5 def __init__(self, radius=5): self.radius = radius self.circumference = (2 * (math.pi * self.radius)) self.diameter = (radius * 2) self.area = (math.pi * (radius * radius)) ...
true
ff46a43fbb377a07fc38ecf781220c6cf1cad33d
klbinns/project-euler-solutions
/Solutions/Problem09.py
546
4.25
4
from math import floor ''' Problem 9: A Pythagorean triplet is a set of three natural numbers, a b c, for which, a**2 + b**2 = c**2 For example, 3**2 + 4**2 = 9 + 16 = 25 = 5**2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. ''' s = 1000 a = 3 ...
true
cf178e7555cc8328e34236a426827dca48c0d61f
klbinns/project-euler-solutions
/Solutions/Problem19.py
1,600
4.21875
4
''' 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. How many...
false
00069652dcb1d3adab681230ee43147a97f8b831
nmasamba/learningPython
/23_list_comprehension.py
819
4.5
4
""" Author: Nyasha Masamba Based on the lessons from Codecademy at https://www.codecademy.com/learn/python This Python program is an example of Python's expressiveness. Less is more when it comes to true Pythonic code, and list comprehensions prove that. A list comprehension is an easy way of automatically creatin...
true
2c0d1241ef7354776f28dbf02587b1c3ef705942
nmasamba/learningPython
/22_iteration.py
1,121
4.5
4
""" Author: Nyasha Pride Masamba Based on the lessons from Codecademy at https://www.codecademy.com/learn/python This Python program shows a way to iterate over tuples, dictionaries and strings. Python includes a special keyword: in. You can use in very intuitively, like below. In the example, first we create and i...
true
e88c2d3097b8f1eda62acb39223f4c5e2848a96b
nmasamba/learningPython
/14_anti_vowel.py
849
4.25
4
""" Author: Nyasha Pride Masamba Based on the lessons from Codecademy at https://www.codecademy.com/learn/python This Python program is an example of modularity, encapsulation and algorithmic thinking. It is simply a function that takes a string text as input. It will then return that string without any vowels. No...
true
c1e5a23c822dc77349e3ffd91817d59e71dd62f8
nmasamba/learningPython
/20_remove_duplicates.py
589
4.25
4
""" Author: Nyasha Pride Masamba Based on the lessons from Codecademy at https://www.codecademy.com/learn/python This Python program is an example of modularity, encapsulation and algorithmic thinking. It is simply a function that takes in a list of integers. It will then remove elements of the list that are the ...
true
2f7babc6a8534a696d89cbb073d307f9b7eef0fb
amitagrahari2512/PythonBasics
/Sorting/BubbleSort.py
282
4.28125
4
def bubbleSort(list): for i in range(len(list)-1,0,-1): for j in range(i): if(list[j] > list[j+1]): list[j],list[j+1] = list[j+1],list[j] list = [2,1,3,89,43,90,66] print("Unsorted List : ",list) bubbleSort(list) print("Sorted List : ",list)
false
46d1f70fb0f3f02d4b4c89c091dd669a6126644b
amitagrahari2512/PythonBasics
/ForLoopBasics.py
675
4.40625
4
print("Iterate List") x = [2, 4, 'Amit'] for i in x: print(i) print("Iterate String") x = 'Amit' for i in x: print(i) print("Initialize List direct in for loop iteration") for i in [2,4 , 'PPPP'] : print(i) print("Initialize String direct in for loop iteration") for i in 'Amit': print(i) print("We ...
false
248a46e01c23a9a818ca88afc3e78b0f9e85269b
amitagrahari2512/PythonBasics
/Numpy_Array_ShallowAndDeepCopy.py
1,376
4.21875
4
from numpy import * print("Copy of array") arr1 = array([1,2,3,4,5]) arr2 = arr1 print(arr1) print(arr2) print("Both address is same") print(id(arr1)) print(id(arr2)) print("------------------------------Shallow Copy------------------------------------------------") print("So we can use view() method , so it will g...
true
c388cc4fb91fd3b4e4d568f9b8dcfebdffc9319e
ryanhake/python_fundamentals
/02_basic_datatypes/2_strings/02_09_vowel.py
533
4.3125
4
''' Write a script that prints the total number of vowels that are used in a user-inputted string. CHALLENGE: Can you change the script so that it counts the occurrence of each individual vowel in the string and print a count for each of them? ''' def isvowel(c): return (c == "a") or (c == "e") or (c...
true
16d8884b52f368d613c1c75b7965f116678001ae
ryanhake/python_fundamentals
/10_testing/10_02_tdd.py
1,171
4.375
4
''' Write a script that demonstrates TDD. Using pseudocode, plan out a couple simple functions. They could be as simple as add and subtract or more complex such as functions that read and write to files. Instead of writing out the functions, only provide the tests. Think about how the functions might fail and write te...
true
4c0960015e4ebfe69e5e06a30c0c0c0223f7979d
DesireeMcElroy/hacker_rank_challenges
/python_exercises.py
2,383
4.21875
4
# Python exercises # If-Else # Task # Given an integer, , perform the following conditional actions: # If is odd, print Weird # If is even and in the inclusive range of to , print Not Weird # If is even and in the inclusive range of to , print Weird # If is even and greater than , print Not Weird # Input Fo...
true
c535f20a9f7bc234840dc7d97db6a8e00b5b7ff3
Boris-Rusinov/BASICS_MODULE
/Nested Loops/Ex03-Sum_Prime_Non_Prime.py
858
4.1875
4
prime_nums_sum = 0 non_prime_nums_sum = 0 curr_num = 0 no_remainder_divisions = 0 while True: command = input() no_remainder_divisions = 0 if command == "stop": break else: curr_num = int(command) if curr_num == 0: continue elif curr_num == 1: n...
false
f069c3a13efd9d60c94023a1331701083f9f7b35
jjeong723/Study_note
/12000026/04/Link.py
1,276
4.1875
4
class Node : # Ʈ ϴ data+ def __init__(self, data, next=None) : self.data = data self.next=next def init() : # Ʈ Ѵ. node 1~node 4 ׸ global node1 node1 = Node(1) node2 = Node(2) node3 = Node(3) node4 = Node(4) node1.next = node2 node2.next = node3 node3.next = node4 def delete(del_data) ...
false
f8cd504dd44ff54de0c85010baced9f3b202c051
prathameshkurunkar7/common-algos-and-problems
/Math and Logic/Prime Number/Prime.py
378
4.21875
4
def isPrime(number): if number == 1 or number == 0: return False limit = (number // 2) + 1 for i in range(2, limit): if number % i == 0: return False return True if __name__ == "__main__": number = int(input("Enter a number: ")) print("Entered number is", ...
true
5f3def601254e9e873f48b1ec47153f6d1abc00e
seige13/SSW-567
/HW-01/hw_01_chris_boffa.py
1,044
4.3125
4
""" # equilateral triangles have all three sides with the same length # isosceles triangles have two sides with the same length # scalene triangles have three sides with different lengths # right triangles have three sides with lengths, a, b, and c where a2 + b2 = c2 """ def classify_triangle(side_a, side_b, side_c):...
true
308e92c4dc6f53a773e2e8320463fdb7eb0925b4
manpreet1994/topgear_python_level2
/q5.py
2,347
4.5625
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 23 12:16:54 2020 @author: manpreet python assignment level 2 Level 2 assignment: ------------------- program 1: write a python program using regex or by any other method to check if the credit card number given is valid or invalid. your python ...
true
211e3d01f7c4d681e95d270d2d7ba2130f08394a
bkabhilash0/Python-Beginners-Projects
/16_Leap_Year.py
1,985
4.375
4
import sys print("***********************************Leap Year Finder*******************************************") print("Enter a Year to check if it is a leap year or Not?") leap_years = [2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048, 2052, 2056, 2060, 2064, 2068, 2072, 2076, 208...
false
4b3860beff600e1652754a3d467e8e0814c7b3c2
peleduri/baby-steps
/baby steps/Learn_py/ex9.py
361
4.3125
4
days = "Mon Tue Wed Thu Fri Sat Sun" # now we will learn how to drop one line with n months = "Jan\nFeb\nMar\nApr\nJun\nJul\nAug" # we will now just gonna print out the days and months print("Here are the days: ", days) print("Here are the months:", months) # we will learn that we can use """" to keep on typing prin...
false
191d92772eb8464c5fa2a9e37298ae1911b2c2f2
cnastoski/Data-Structures
/Hybrid Sort/HybridSort.py
2,482
4.65625
5
def merge_sort(unsorted, threshold, reverse): """ Splits a list in half until it cant anymore, then merges them back together in order :param unsorted: the unsorted list :param threshold: if the list size is at or below the threshold, switch to insertion sort :param reverse: sorts the list in descen...
true
a83cb5b5cab2973aa697cab221e20aaf3bea570e
ksemele/coffee_machine
/coffee_machine.py
2,235
4.125
4
class CoffeeMachine: def __init__(self): self.water = 400 self.milk = 540 self.beans = 120 self.cups = 9 self.money = 550 def status(self): print("\nThe coffee machine has:") print(str(self.water) + " of water") print(str(self.milk) + " of milk") print(str(self.beans) + " of coffee beans") print(...
true
2ca25165a87b7a7360d35e86b519469f9606da1f
Mahiuha/RSA-Factoring-Challenge
/factors
1,887
4.34375
4
#!/usr/bin/python3 """ Factorize as many numbers as possible into a product of two smaller numbers. Usage: factors <file> where <file> is a file containing natural numbers to factor. One number per line You can assume that all lines will be valid natural numbers\ greater tha...
true
1a7ef6b488b6ce7e7a592d8dbeac6625547ea0fc
rdasxy/programming-autograder
/problems/CS101/0035/solution.py
350
4.21875
4
# Prompt the use to "Enter some numbers: " # The user should enter a few numbers, separated by spaces, all on one line # Sort the resulting sequence, then print all the numbers but the first two and the last two, # one to a line. seq = raw_input("Enter some numbers: ") seq = [int(s) for s in seq.split()] seq.sort() fo...
true
f3213933c26dc79928dfb3be5323cec7977b2884
dasdachs/smart
/08/python/to_lower.py
384
4.28125
4
#! /usr/bin/env python2 # -*- coding: utf-8 -*- """Return the input text in lower case.""" import argparse parser = argparse.ArgumentParser(description='Transforms text to lower case.') parser.add_argument('text', type=str, nargs="+", help='Text that will be transformed to lower case.') args = parser.parse_args() if...
true
715df80224d4637c68ccf079bf8903df7c50206e
dasdachs/smart
/10/python/game.py
867
4.125
4
def main(): country_capital_dict = {"Slovenia": "Ljubljana", "Croatia": "Zagreb", "Austria": "Vienna"} while True: selected_country = country_capital_dict.keys()[0] guess = raw_input("What is the capital of %s? " % selected_country) check_guess(guess, selected_country, country_capital...
true
244caeca775b8de42eb502a37da16fed80f23796
iPedriNNz/Exercicios
/ex022.py
608
4.46875
4
# Exercício Python 022: Crie um programa que leia o nome completo de uma pessoa e mostre: # - O nome com todas as letras maiúsculas e minúsculas. # - Quantas letras ao #odo (sem considerar espaços). # - Quantas letras tem o primeiro nome. name = str(input('Digite seu nome completo: ')) print('Seu nome com as letras min...
false
338e2b7085fa942cabb25a3b273814bf13faa1f7
iPedriNNz/Exercicios
/ex019.py
527
4.125
4
# Exercício Python 019: Um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que # ajude ele, lendo o nome dos alunos e escrevendo na tela o nome do escolhido. from random import choice student1 = input('Nome do primeiro aluno ') student2 = input('Nome do segundo aluno ') student3...
false
ad6fb4595aeadbb1e5fd4c9b2cda5273d0f8df7f
iPedriNNz/Exercicios
/ex036.py
783
4.3125
4
# Exercício Python 036: Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa. # Pergunte o valor da casa, o salário do comprador e em quantos anos ele vai pagar. A prestação mensal não pode exceder # 30% do salário ou então o empréstimo será negado. home = float(input('Qual o valor da casa: ...
false
6ecbbd21bb3a7ff477c7223ae2ea8d2d820d8f7c
magnuskonrad98/max_int
/FORRIT/python_verkefni/byrjendanamskeid/verkefni_day_2/while_verkefni/verkefni__02.py
217
4.21875
4
low = int(input("Enter an integer: ")) high = int(input("Enter a higher integer: ")) while low <= high: a = low % 2 if a!=0: print(low) low=low+2 else: low=low+1 print("Done!")
false
f1337838af3d2dafe14302b84ac07870d7409029
magnuskonrad98/max_int
/FORRIT/timaverkefni/27.08.19/prime_number.py
341
4.15625
4
n = int(input("Input a natural number: ")) # Do not change this line # Fill in the missing code below divisor = 2 while divisor < n: if n % divisor == 0: prime = False break else: divisor += 1 else: prime = True # Do not changes the lines below if prime: print("Prime") else: ...
true
8fa2839f5c02e9c272f21e437caa8e2ab7f4f2c9
TedYav/CodingChallenges
/Pramp/python/flatten_dict.py
1,137
4.125
4
""" Time Complexity: O(n) based on number of elements in dictionary 1. allocate empty dictionary to store result = {} 2. for each key in dictionary: call add_to_output(key,value,result) add_to_output(prefix,value,result) - if value is dict: for each key in dict, call add_...
true
0d890a36cebce9c9bb058c2cff8a06ab54eb82cc
ozMoreira/Python_Exercises
/CheckPoint1/Tarefa1_Exercicio2.py
2,146
4.21875
4
print("") print("------------------------------------------------------------------------------------------------------------------") print("| Este eh o exercicio 02 da Lista de CheckPoint #1, da disciplina de Computational Thinking do Curso de Analise |") print("| e Desenvolvimento de Siste...
false
d65f38aa4d1a9715b7579bd9b6ac02b34bfa82c2
ozMoreira/Python_Exercises
/CheckPoint1/Tarefa1_Exercicio3.py
1,111
4.125
4
import math print("") print("------------------------------------------------------------------------------------------------------------------") print("| Este é o exercicio 01 da Lista de CheckPoint #1, da disciplina de Computational Thinking do Curso de Analise |") print("| e Desenvolvime...
false
b600abf744c3dbb8abbaa694f1df0516847b1cab
lucianopereira86/Python-Examples
/examples/error_handling.py
661
4.15625
4
# Division by zero x = 1 y = 0 try: print(x/y) except ZeroDivisionError as e: print('You must NOT divide by zero!!!') finally: print('This is a ZeroDivisionError test') # Wrong type for parsing a = 'abc' try: print(int(a)) except ValueError as e: print('Your string cannot to be parsed to int') fina...
true
b85fd57a82d8cd32671f1f7c6cfe05659d182cf0
mydopico/HackerRank-Python
/Introduction/division.py
539
4.1875
4
# Task # Read two integers and print two lines. The first line should contain integer division, aa//bb. The second line should contain float division, aa/bb. # You don't need to perform any rounding or formatting operations. # Input Format # The first line contains the first integer, aa. The second line contains the ...
true
57ba583649fdb78dfd5afdad714e2b9bd72ea363
nini564413689/day-3-2-exercise
/main.py
546
4.34375
4
# 🚨 Don't change the code below 👇 height = float(input("enter your height in m: ")) weight = float(input("enter your weight in kg: ")) # 🚨 Don't change the code above 👆 #Write your code below this line 👇 BMI = round (weight / height ** 2,1) if BMI < 18.5: result = "You are underweight." elif BMI < 25: result ...
true
9cd8f10f326504cf9a46d47048fcf3c25d2df827
chaithra-yenikapati/python-code
/question_08.py
1,356
4.21875
4
__author__ = 'Chaithra' notes = """ This is to make you familiar with linked list structures usage in python see the listutils.py module for some helper functions """ from listutils import * #Given sorted list with one sublist reversed, #find the reversed sublist and correct it #Ex: 1->2->5->4->6-...
true
c18b622285056b2305b06fa34624e566826b2f19
asbabiy/programming-2021-19fpl
/shapes/reuleaux_triangle.py
1,435
4.1875
4
""" Programming for linguists Implementation of the class ReuleauxTriangle """ import math from shapes.shape import Shape class ReuleauxTriangle(Shape): """ A class for Reuleaux triangles """ def __init__(self, uid: int, width: int): super().__init__(uid) self.width = width def...
true
95058a6355a18b7a0ce81c9671e8e102ce194ac0
bhanugudheniya/Python-Program-Directory
/CWH_Program_Practice_DIR/CH6_ConditionalExpression_PositiveIntegerCheck.py
229
4.28125
4
userInput = int(input("Enter Number: ")) if userInput > 0: print(userInput, "is a positive integer") elif userInput < 0: print(userInput, "is a negative integer") else: print("Nor Positive and Nor Negative Integer, it's Zero")
true
f4eb7877a49cca45074124096ace75dd5e89b72f
bhanugudheniya/Python-Program-Directory
/CWH_Program_Practice_DIR/CH5_DictionaryAndSets_DeclarationAndInitialization.py
499
4.15625
4
student = { "name" : "bhanu", "marks" : 99, "subject" : "CS", # "marks" : 98 # always print last updated value } print(student) # print whole dictionary print(student["name"]) # print value of key "name" print(len(student)) # print dictionary length print(type(student)) # data types # Access Dicti...
true
a528a47e1d7c6c1c861e9128c43db7a6645ff453
bhanugudheniya/Python-Program-Directory
/PythonHome/Input/UserInput_JTP.py
705
4.25
4
name = input("Enter name of student : ") print("Student name is : ", name) # 'name' is variable which store value are stored by user # 'input()' is function which is helps to take user input and string are written in this which is as it is show on screen # -------------------------------------------------------------...
true
141b1eafcfbdbd8324b7f5004774ea9c3a2986e8
gmaldona/Turtles
/runGame.py
2,561
4.21875
4
import turtle import random from tkinter import * import time ### Class for each player object class Player: ## Starting y coordinate y = -250 ## Initialing variables def __init__(self, vMin, vMax, color): self.player = turtle.Turtle() self.player.showturtle() self.pla...
true
0aa3a7fddbe66a9fb10a00f251c5bc0519267e19
Code-Law/Ex
/BYFassess.py
2,097
4.15625
4
def Student(): Student_num = int(input("please input your student number:")) while Student_num < 4990 or Student_num > 5200: Student_num = int(input("your student number is out of range, please input again!")) while Student_num in Student_Numbers: Student_num = int(input("this student number...
true
43624ddb794cc122bf493cbb055169b042824d1b
michaelmnicholl/reimagined-train
/module_grade_program.py
555
4.21875
4
marks = [0,55,47,67] lowest = marks[0] mean = 0 if len(marks) < 3: print("Fail") print("Your score is below the threshold and you have failed the course") exit() for item in marks: if item < lowest: lowest = item for item in marks: mean = mean + item mean = mean - lowest mean ...
true
41e9ae805b19463cf2a5dbdf4cbce27f54d2fdcb
JeanAlmenar/HolaMundo
/controlDeFlujo.py
819
4.28125
4
if 2 < 5: print("2 es menor que 5") # a == b # a < b # a > b # a != b # a <= b # a >= b if 2 == 2: print("2 es igual a 2") if 2 == 3: print("2 no es igual a 3, y no se ve") if 2 > 5: print("2 no es mayor y no se ve") if 5 > 2: print("Este si es mayor y se ve") if 2 !=2: ...
false
1b5f0832809513821db10e2be39737d60209ea5f
braxtonphillips/SDEV140
/PhillipsBraxtonM02_Ch3Ex12.py
2,041
4.46875
4
#Braxton Phillips #SDEV 140 #M02 Chapter 3 Exercise 12 #This purpuse of this program is to calculate the amount a discount, # if any, based on quantity of packages being purchased. print('Hello, this progam will read user input to determine if a discount is applicable based on order quantity.') packageQuantity ...
true
4e31d151c7d8d2246a42e286263ae5af2cd87cb4
nanihari/regular-expressions
/lower with __.py
394
4.40625
4
#program to find sequences of lowercase letters joined with a underscore. import re def lower_with__(text): patterns="^[a-z]+_[a-z]+$" if re.search(patterns,text): return ("found match") else: return ("no match") print(lower_with__("aab_hari")) print(lower_with__("hari_krishna")) p...
true
e15765c217cc41d624aa18e1fb54d7490fde49ff
nanihari/regular-expressions
/replace_space_capital.py
270
4.1875
4
#program to insert spaces between words starting with capital letters. import re def replace_spaceC(text): return re.sub(r"(\w)([A-Z])", r"\1 \2", text) print(replace_spaceC("HariKrishna")) print(replace_spaceC("AnAimInTheLifeIsTheOnlyFortuneWorthFinding"))
true
809214d38526ab39fa2026b0c05525ae34aaebde
nanihari/regular-expressions
/remove numbers.py
278
4.375
4
##program to check for a number at the end of a string. import re def check_number(string): search=re.compile(r".*[0-9]$") if search.match(string): return True else: return False print(check_number("haari00")) print(check_number("hari"))
true
80bcae00e491919c7f627182755948c19115cedf
nanihari/regular-expressions
/snake to camel convertion.py
282
4.25
4
##program to convert snake case string to camel case string. import re def snake_camel(text): return ''.join(x.capitalize() or '_' for x in text.split('_')) print(snake_camel("harikrishna")) print(snake_camel("hari__KRISHNA")) print(snake_camel("HARI_krishna!!!@###"))
false
50929ea4cbf1a0ca13d4a9054c577055e71bb196
ar1ndamg/algo_practice
/3.sorting_algos.py
1,533
4.5
4
def insertion_sort(arr: list): """ Takes an list and sorts it using insertion sort algorithm """ l = len(arr) #print(f"length: {l}") for i in range(1, l): key = arr[i] j = i-1 while j >= 0: if key < arr[j]: # slide the elements what are greater than th...
true
0c6e89d23d913a1234d8bcd95de548b6a5bd6a62
hariprasadraja/python-workspace
/MoshTutorial/basics.py
2,268
4.28125
4
import math """ Tutorial: https://www.youtube.com/watch?v=_uQrJ0TkZlc&t=7729s """ course = 'Python learning tutorial' print(course[0:-3]) print("Another variable: ") another = course[:] print(another) # works only on python > 3.6 # formated_string = (f'this is an another course') # print(formated_string) print(le...
true
ba785abefc90c1d15878514b9d93be99c7383f4f
Ankush-Chander/euler-project
/9SpecialPythagoreanTriplet.py
539
4.28125
4
''' A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. ''' import sys import os if len(sys.argv) != 2: print("Usage: python " + sys...
true
187d5213a7f6cf3019875728f382186dbdf4d2e1
fedor9ka/python_basic_07_04_20
/lesson1/task5.py
1,451
4.15625
4
"""Запросите у пользователя значения выручки и издержек фирмы. Определите, с каким финансовым результатом работает фирма (прибыль — выручка больше издержек, или убыток — издержки больше выручки). Выведите соответствующее сообщение. Если фирма отработала с прибылью, вычислите рентабельность выручки (соотношение прибыл...
false
1df7dca01c15594555d5b19f63c50049229a4b05
rudrasingh21/Python---Using-Examples
/27. Dict - Given Key Exists in a Dictionary or Not.py
247
4.125
4
# Given Key Exist in a Dictionary or Not d={'A':1,'B':2,'C':3} k = input("Enter Key which you want to search:- ") if k in d.keys(): print("Value is present and value for the Key is:- ", d[k]) else: print("Key is not present")
true
6958f52980d417abfb01324cebe6f4b6cf452eb3
rudrasingh21/Python---Using-Examples
/11.Count the Number of Digits in a Number.py
271
4.125
4
#Count the Number of Digits in a Number ''' n=int(input("Enter number: ")) s = len(str(n)) print(s) ''' n=int(input("Enter number: ")) count = 0 while(n>0): count=count+1 n=n//10 print("The number of digits in the number are: ",count)
true
26ecc9df30d13fbeabe16387bfcf5dd79b3ee02d
rudrasingh21/Python---Using-Examples
/25. Dict - Add a Key-Value Pair to the Dictionary.py
278
4.25
4
#Add a Key-Value Pair to the Dictionary n = int(input("Enter number of Element you want in Dictionary:- ")) d = {} for i in range(1,n+1): Key = input("Enter Key : ") Value = input("Enter Value : ") d.update({Key:Value}) print("Updated Dictonary is: ",d)
true
f0689ed643caf94fccd0fbe9cec7ddad49d7b43b
Onawa33/IDF-Class
/Python/Exercises1/BMI.py
211
4.21875
4
weight = float(input("Enter weight in pounds: ")) height = float(input("Enter height in inches: ")) kg = weight * .45359237 meters = height * .0254 BMI = kg / (meters**2) print("Your BMI is: %.2f" %(BMI))
false
d063654808224d54d7ee8c41d6019dab24b458ac
arjun-krishna1/leetcode-grind
/mergeIntervals.py
2,766
4.34375
4
''' GIVEN INPUT intervals: intervals[i] = [start of i'th interval, end of i'th interval] merge all overlapping intervals OUTPUT return an array of the non-overlapping intervals that cover all the intervals in the input EXAMPLE 1: intervals = [[1, 3], [2, 6], [8, 10], [15, 18]] already sorted the end of intervals[0] i...
true
826a3993e35aece4c19e88969dd44439fc86b969
ericdasse28/graph-algorithms-implementation
/depth-first-search.py
1,334
4.3125
4
""" Python3 program to print DFS traversal from a given graph """ from collections import defaultdict # This class represents a directed graph using # adjacency list representation class Graph: def __init__(self): # Default dictionary to store graph self.graph = defaultdict(list) def add_ed...
true