blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
5d4fa6aaab3cc50ab1b67c9ab5add9ca49d2f25a
Ryandalion/Python
/Decision Structures and Boolean Logic/Roman Numeral Converter/Roman Numeral Converter/Roman_Numeral_Converter.py
1,269
4.21875
4
# Function converts a number to a roman numeral userNum = int(input('Please enter a literal number between 1 ~ 10 you wish to convert to a Roman numeral: ')); if userNum < 0 or userNum > 10: print('Please enter a number between 1 and 10'); else: if userNum == 1: print('I'); else: if userNu...
true
2b7ac8c5047791e80d7078a9f678b27c0c79d997
Ryandalion/Python
/Lists and Tuples/Larger than N/Larger than N/Larger_than_N.py
1,752
4.3125
4
# Program generates a list via random generation and compares it to a user input number n which will determine if the elements within the last are greater than the number import random; # Import the random module to generate a random integer def main(): randNum = [0] * 10; # Intialize list with 10 elements of zer...
true
daee14c84fcbbe19529eae9f874083297fc67493
run-fourest-run/PythonDataStructures-Algos
/Chapter 3 - Python Data Types and Structures/Sets.py
2,216
4.125
4
''' Sets are unordered collection of unique items. Sets are mutable, but the elements inside of them are immutable. * Important distinctions is that the cannot contain duplicate keys * Sets are typically used to perform mathmatical operations such as intersection, union, difference and complement. Unlike sequence ty...
true
90e9a6e867b5601d2ce5fc2ed648d980eb904b17
PWalis/Intro-Python-I
/src/10_functions.py
495
4.28125
4
# Write a function is_even that will return true if the passed-in number is even. # YOUR CODE HERE def is_even(n): if n % 2 == 0: return True else: return False print(is_even(6)) # Read a number from the keyboard num = input("Your number here") num = int(num) # Print out "Even!" if the numbe...
true
ad0017b73937ba9313620bfc23101a2502707321
Sumanthsjoshi/capstone-python-projects
/src/get_prime_number.py
728
4.125
4
# This program prints next prime number until user chooses to stop # Problem statement: Have the program find prime numbers until the user chooses # to stop asking for the next one. # Define a generator function def get_prime(): num = 3 yield 2 while True: is_prime = True for j in range(3,...
true
8c99ba43d3481a6190df22b51b93d2d94358f68c
abhic55555/Python
/Assignments/Assignment2/Assignment2_3.py
440
4.15625
4
def factorial(value1): if value1 > 0: factorial = 1 for i in range(1,value1 + 1): factorial = factorial*i print("The factorial of {} is {}".format(value1,factorial)) elif value1==0: print("The factorial of 0 is 1 ") else:- print("Invalid number") ...
true
6b89934c7911e7f1c24db7c739b46eb26050297c
Tyler668/Code-Challenges
/twoSum.py
1,018
4.1875
4
# # Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. # # (i.e., [0, 1, 2, 4, 5, 6, 7] might become[4, 5, 6, 7, 0, 1, 2]). # # You are given a target value to search. If found in the array return its index, otherwise return -1. # # You may assume no duplicate exists in th...
true
15be302b0b417de9eb462b731ad20a0d78e448d8
SaiJyothiGudibandi/Python_CS5590-490-0001
/ICE/ICE1/2/Reverse.py
328
4.21875
4
num = int(input('Enter the number:')) #Taking nput from the user Reverse = 0 while(num > 0): #loop to check whether the number is > 0 Reminder = num%10 # finding the reminder for number Reverse = (Reverse * 10) + Reminder num = num // 10 print('Reverse for the Entered number is:%d' %Reverse) ...
true
684dba9a9265b5867782ca23dd12e646972bf8b8
lorinatsumi/lista3
/ex2.py
496
4.1875
4
#1 Escreva um algoritmo que permita a leitura das notas de uma turma de 5 alunos, armazenando os dados numa lista. Depois calcule a média da turma e conte quantos alunos obtiveram nota acima desta média calculada. Escrever a média da turma e o resultado da contagem. notas = [] for i in range(5): nota=int(input("Di...
false
bb0b85fbe5e9fe5c3e05dfb28f35feba48e2d0d7
jarturomora/learningpython
/ex16bis.py
834
4.28125
4
from sys import argv script, filename = argv # Opening the file in "read-write" mode. my_file = open(filename, "rw+") # We show the current contents of the file passed in filename. print "This is the current content of the file %r." % filename print my_file.read() print "Do you want to create new content for this f...
true
8e81b8f7d46c6257d8a6dbabfd677297149148be
jarturomora/learningpython
/ex44e.py
863
4.15625
4
class Other(object): def override(self): print "OTHER override()" def implicit(self): print "OTHER implicit()" def altered(self): print "OTHER altered()" class Child(object): def __init__(self): self.other = Other() # The composition begins here ...
true
01ce27d5d65b55566cccded488d1c99d2fd848b0
dablackwood/my_scripts_project_euler
/specific_solutions/project_euler_019.py
1,079
4.1875
4
""" You are given the following information, but you may prefer to do some research for yourself. * 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 le...
true
159b7422dc21ca5c01cec91b1c27ee3a88b08ca1
dablackwood/my_scripts_project_euler
/specific_solutions/project_euler_029a.py
759
4.15625
4
""" Consider all integer combinations of a^(b) for 2<=a<=5 and 2<=b<=5: 2^(2)=4, 2^(3)=8, 2^(4)=16, 2^(5)=32 3^(2)=9, 3^(3)=27, 3^(4)=81, 3^(5)=243 4^(2)=16, 4^(3)=64, 4^(4)=256, 4^(5)=1024 5^(2)=25, 5^(3)=125, 5^(4)=625, 5^(5)=3125 If they are then placed in numerical order, with any repeats removed,...
true
627e26b857e77b466da042acef1737e3d0816d1e
shaziya21/PYTHON
/zip.py
349
4.25
4
# if we want to join two list or tuple or set or dict we'll use zip names = ('shaz','naaz','chiku') comps = ('apple','hp','asus') zipped = list(zip(names,comps)) print(zipped) # or we can use loop to iterate like names = ('shaz','naaz','chiku') comps = ('apple','hp','asus') zipped = list(zip(names,comps)) for (a,...
false
73980da3c813213a81f11db877458ff72c0a47b7
shaziya21/PYTHON
/constructor_in_inheritance.py
732
4.1875
4
class A: # Parent class / Super class def __init__(self): # Constructor of parent class A print("in A init") def feature1(self): print("feature1 is working") def feature2(self): print("feature2 is working") class B(A): def __init__(self): super().__init__() # jum...
true
6ffafcc1da316699df44275889ffab8ba957265f
shaziya21/PYTHON
/MRO.py
1,004
4.4375
4
class A: # Parent class / Super class def __init__(self): # Constructor of parent class A print("in A init") def feature1(self): print("feature 1-A is working") def feature2(self): print("feature2 is working") class B: def __init__(self): # Constructor of class B ...
true
1e870f6429ff8f0b0cde4f40b7d0f3e148242257
JoshiDivya/PythonExam
/Pelindrome.py
354
4.3125
4
def is_pelindrome(word): word=word.lower() word1=word new_str='' while len(word1)>0: new_str=new_str+ word1[-1] word1=word1[:-1] print(new_str) if (new_str== word): return True else: return False if is_pelindrome(input("Enter String >>>")): print("yes,this is pelindrome") else: pri...
true
2dd93300d7ede7b2fd78a925eeea3d912ae55c51
dhaffner/pycon-africa
/example1.py
408
4.53125
5
# Example #1: Currying with inner functions # Given a function, f(x, y)... def f(x, y): return x ** 2 + y ** 2 # ...currying constructs a new function, h(x), that takes an argument # from X and returns a function that maps Y to Z. # # f(x, y) = h(x)(y) # def h(x): def curried(y): return f(x, y) r...
true
b86300067afe20ac6d3661a4d8a6b85446b57512
Yaambs18/python-bootcamp
/Day3/Ineheritance.py
1,251
4.15625
4
#Multilevel Inheritance class Base(): def __init__(self, name): self.name = name def getName(self): return self.name class Child(Base): def __init__(self, name, age): Base.__init__(self, name) self.age = age def getAge(self): return self.age class GrandChild(Child): def __init__(self, name, ag...
false
a93f8e9ac02ba81adbd2b0ead5aa0a2af11d6011
egill12/pythongrogramming
/P3_question4.py
842
4.625
5
''' Write a program that asks the user for a long string containing multiple words. Echo back to the user the same string, except with the words in backwards order. For example, say we type the string: My name is Michele Then we would expect to see the string: Michele is name My ''' def reverse_str(string): ''' ...
true
fc044bef4295e8e85313366be4a89689938756c2
BjornChrisnach/Basics_of_Computing_and_Programming
/days_traveled.py
233
4.125
4
print("Please enter the number of days you traveled") days_traveled = int(input()) full_weeks = days_traveled // 7 remaining_days = days_traveled % 7 print(days_traveled, "days are", full_weeks, "weeks and",\ remaining_days,"days")
true
386917245b7e7130aa3a96abccf9ca35842e1904
getachew67/UW-Python-AI-Coursework-Projects
/Advanced Data Programming/hw2/hw2_pandas.py
2,159
4.1875
4
""" Khoa Tran CSE 163 AB This program performs analysis on a given Pokemon data file, giving various information like average attack levels for a particular type or number of species and much more. This program immplements the panda library in order to compute the statistics. """ def species_count(data): """ ...
true
5d01d82bfd16634be636cce2cf2e1d31ea7208b1
Razorro/Leetcode
/88. Merge Sorted Array.py
1,353
4.28125
4
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. Example: I...
true
2cd13056f72eaf8f16e342bacde6c9b17bd43d3b
Razorro/Leetcode
/49. Group Anagrams.py
863
4.125
4
""" Description: Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat","tan"], ["bat"] ] Note: All inputs will be in lowercase. The order of your output does not matter. Runtime: 152 ms, faster than 39.32% of Pytho...
true
d2d6f21556955a4b8ec8893b8bf03e7478032b68
Razorro/Leetcode
/7. Reverse Integer.py
817
4.15625
4
""" Description: Given a 32-bit signed integer, reverse digits of an integer. Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overfl...
true
92b2ac96f202ac222ccd4b9572595602abf0a459
jrahman1988/PythonSandbox
/myDataStruct_CreateDictionaryByFilteringOutKeys.py
677
4.34375
4
''' A dictionary is like an address-book where we can find the address or contact details of a person by knowing only his/her name i.e. we associate keys (name) with values Dictionary is represented by dict class. Pair of keys and values are specified in dictionary using the notation d = {key1 : value1, key2 : value2 }...
true
1a4d781b35cfbb98acbc1b8b9fad8aa9a78c51ac
jrahman1988/PythonSandbox
/myPandas_DescriptiveStatistics.py
1,754
4.40625
4
''' A large number of methods collectively compute descriptive statistics and other related operations on DataFrame. Most of these are aggregations like sum(), mean(), but some of them, like sumsum(), produce an object of the same size. Generally speaking, these methods take an axis argument, just like ndarray.{sum, st...
true
f45471a04eef4398d02bbe12151a6b031b394452
jrahman1988/PythonSandbox
/myFunction_printMultipleTimes.py
427
4.3125
4
''' Functions are reusable pieces of programs. They allow us to give a name to a block of statements, allowing us to run that block using the specified name anywhere in your program and any number of times. This is known as calling the function. ''' def printMultipleTimes(message:str, time:int): print(message * tim...
true
b2965c970bce71eee39841548b95ab6edf37d99b
jrahman1988/PythonSandbox
/myLambdaFunction.py
1,212
4.125
4
''' A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression. Syntax lambda arguments : expression ''' #define the lambda function sentence = "I bought a bike, from a bike store, she bought a bike from amazon, they bought a bike from bike sto...
true
76e7dc6bfa340596459f1a535e4e2e191ea483bc
jrahman1988/PythonSandbox
/myOOPclass3.py
2,017
4.46875
4
''' There is way of organizing a software program which is to combine data and functionality and wrap it inside something called an object. This is called the object oriented programming paradigm. In this program we'll explore Class, behaviour and attributes of a class ''' #Declaring a class named Mail and its methods...
true
cf3158ef73377ac7fe644d4637c21ae1501d804b
jrahman1988/PythonSandbox
/myStringFormatPrint.py
551
4.25
4
#Ways to format and print age: int = 20 name: str = "Shelley" #Style 1 where format uses indexed parameters print('{0} was graduated from Wayne State University in Michigan USA when she was {1}'.format(name,age)) #Style 2 where 'f' is used as f-string print(f'{name} was graduated from Wayne State University in Michi...
true
34653fdfffaacb579ad87ee2d590c6ae37c5bb71
mimipeshy/pramp-solutions
/code/drone_flight_planner.py
1,903
4.34375
4
""" Drone Flight Planner You’re an engineer at a disruptive drone delivery startup and your CTO asks you to come up with an efficient algorithm that calculates the minimum amount of energy required for the company’s drone to complete its flight. You know that the drone burns 1 kWh (kilowatt-hour is an energy unit) f...
true
dd9c666ab17a5afeb3e6c0fa1bdd1b27bb7f78ce
CSC1-1101-TTh9-S21/lab-week3
/perimeter.py
594
4.3125
4
# Starter code for week 3 lab, parts 1 and 2 # perimeter.py # Prof. Prud'hommeaux # Get some input from the user. a=int(input("Enter the length of one side of the rectangle: ")) b=int(input("Enter the length of the other side of the rectangle: ")) # Print out the perimeter of the rectangle c = a + a + b + b print("Th...
true
abdff8d3bf6c1e1cc39a24519587e5760294bdc6
arkiz/py
/lab1-4.py
413
4.125
4
studentName = raw_input('Enter student name.') creditsDegree = input('Enter credits required for degree.') creditsTaken = input('Enter credits taken so far.') degreeName = raw_input('Enter degree name.') creditsLeft = (creditsDegree - creditsTaken) print 'The student\'s name is', studentName, ' and the degree name...
true
517f231a66c9d977bc5a34eaa92b6ad986a8e340
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-3/3-1-2-12-Python-loops-else-The-while-loop-and-the-else-branch.py
356
4.15625
4
#!/usr/bin/python3 """ Both loops, while and for, have one interesting (and rarely used) feature. As you may have suspected, loops may have the else branch too, like ifs. The loop's else branch is always executed once, regardless of whether the loop has entered its body or not. """ i = 1 while i < 5: print(i) ...
true
6920b44453655be0855b3977c12f2ed33bdb0bc3
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-4/4-1-3-10-LAB-Converting-fuel-consumption.py
1,432
4.4375
4
#!/usr/bin/python3 """ A car's fuel consumption may be expressed in many different ways. For example, in Europe, it is shown as the amount of fuel consumed per 100 kilometers. In the USA, it is shown as the number of miles traveled by a car using one gallon of fuel. Your task is to write a pair of functions convertin...
true
c9bedff4032b89fbd4054b4f03093af06a3d01d0
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-2/2-1-4-10-LAB-Operators-and-expressions.py
567
4.5625
5
#!/usr/bin/python3 """ Take a look at the code in the editor: it reads a float value, puts it into a variable named x, and prints the value of a variable named y. Your task is to complete the code in order to evaluate the following expression: 3x3 - 2x2 + 3x - 1 The result should be assigned to y. """ x = 0 x = floa...
true
fd86bac9750e54714b1fe65d050d336dba9399ca
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-4/4-1-3-9-LAB-Prime-numbers-how-to-find-them.py
1,302
4.28125
4
#!/usr/bin/python3 """ A natural number is prime if it is greater than 1 and has no divisors other than 1 and itself. Complicated? Not at all. For example, 8 isn't a prime number, as you can divide it by 2 and 4 (we can't use divisors equal to 1 and 8, as the definition prohibits this). On the other hand, 7 is a prim...
true
3e7b84ff790a508534c03cdc878f6abdf2e32a53
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-3/3-1-6-1-Operations-on-lists-The-inner-life-of-lists.py
1,345
4.375
4
#!/usr/bin/python3 """ The inner life of lists Now we want to show you one important, and very surprising, feature of lists, which strongly distinguishes them from ordinary variables. We want you to memorize it - it may affect your future programs, and cause severe problems if forgotten or overlooked. Take a look at...
true
946ec887e106dde979717832e603732ef85a750c
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-4/4-1-2-2-How-functions-communicate-with-their-environment-Parametrized-functions.py
1,358
4.375
4
#!/usr/bin/python3 """ It's legal, and possible, to have a variable named the same as a function's parameter. The snippet illustrates the phenomenon: def message(number): print("Enter a number:", number) number = 1234 message(1) print(number) A situation like this activates a mechanism called shadowing: pa...
true
b6732e8d49b943a0391fe3d6521bdf29d2f840ee
rolandoquiroz/CISCO_PCAP-Programming-Essentials-In-Python
/Module-3/3-1-1-11-LAB-Comparison-operators-and-conditional-execution.py
1,014
4.46875
4
#!/usr/bin/python3 """ Spathiphyllum, more commonly known as a peace lily or white sail plant, is one of the most popular indoor houseplants that filters out harmful toxins from the air. Some of the toxins that it neutralizes include benzene, formaldehyde, and ammonia. Imagine that your computer program loves these pl...
true
ad07c957de435974775396e4cc0b8a793ffe4141
michellecby/learning_python
/week7/checklist.py
788
4.1875
4
#!/usr/bin/env python3 # Write a program that compares two files of names to find: # Names unique to file 1 # Names unique to file 2 # Names shared in both files import sys import biotools file1 = sys.argv[1] file2 = sys.argv[2] def mkdictionary(filename): names = {} with open(filename) as fp: for name in fp.r...
true
2f8d761707c15cef64f9e8b49aae03c733959d00
leetuckert10/CrashCourse
/chapter_9/exercise_9-6.py
1,668
4.375
4
# Exercise 9-6: Ice Cream Stand # Write a class that inherits the Restaurant class. Add and an attribute # called flavors that stores a list of ice cream flavors. Add a method that # displays the flavors. Call the class IceCreamStand. from restaurant import Restaurant class IceCreamStand(Restaurant): def __ini...
true
df70e46cceaa083c3a0545af8eb83463295b0b40
leetuckert10/CrashCourse
/chapter_11/test_cities.py
1,339
4.3125
4
# Exercise 11-1: City, Country # # Create a file called test_city.py that tests the function you just wrote. # Write a method called test_city_country() in the class you create for testing # the function. Make sure it passes the test. # # Remember to import unittest and the function you are testing. Remember that # the...
true
f4f669c12f07d0320e5d9a01fec7542e249d4962
leetuckert10/CrashCourse
/chapter_4/exercise_4-10.py
539
4.5625
5
# Slices # Use list splicing to print various parts of a list. cubes = [value**3 for value in range(1, 11)] # list comprehension print("The entire list:") for value in cubes: # check out this syntax for suppressing a new line. print(value, " ", end="") print('\n') # display first 3 items print(f"The first three item...
true
1897ec6770bca8f6e0dc72abbcdcd70644e6f182
leetuckert10/CrashCourse
/chapter_8/exercise_8-14.py
764
4.3125
4
# Exercise 8-13: Cars # Define a function that creates a list of key-value pairs for all the # arbitrary arguments. The syntax **user_info tell Python to create a # dictionary out of the arbitrary parameters. def make_car(manufacturer, model, **car): """ Make a car using a couple positional parameters and and a...
true
997df0520551de4bfb67665932840b09fa1a6d5a
leetuckert10/CrashCourse
/chapter_6/exercise_6-9.py
1,229
4.21875
4
# Favorite Places: # Make a dictionary of favorite places with the persons name as the kep. # Create a list as one of the items in the dictionary that contains one or # more favorite places. favorite_places = { 'terry': ['wild cat rock', 'mount mitchell', 'grandfather mountain'], 'carlee': ['blue ridge parkway...
true
ab6b62451de82d2c52b1b994cfabab7893c4f64e
leetuckert10/CrashCourse
/chapter_8/exercise_8-3.py
541
4.125
4
# Exercise 8-3: T-Shirt # Write a function called make_shirt() that accepts a size and a string for # the text to be printed on the shirt. Call the function twice: once with # positional arguments and once with keyword arguments. def make_shirt(text, size): print(f"Making a {size.title()} T-Shirt with the text ...
true
928d97a0023a0a64773fb1df4c1e59bc20f01123
algorithms-21-devs/Interview_problems
/weekly_interview_questions/IQ_4/Q4_emmanuelcodev/Q4Medium_N.py
1,840
4.25
4
import node as n ''' Time complexity: O(n) Algorithm iterates through link list once only. It adds memory location as a key to a dictionary. As it iterates it checks if the current node memory matches any in the dictionary in O(1) time. If it does a cycle must be present. ''' def cycle(head_node): #must be a linke...
true
4374c169c241a96ef6fc26f74a3c514f4cc216ed
algorithms-21-devs/Interview_problems
/weekly_interview_questions/IQ_2/Q2_Emmanuelcodev/Q2Medium_Nsquared.py
2,634
4.1875
4
def unique_pairs(int_list, target_sum): #check for None ''' Time complexity: O(n^2). 1) This is because I have a nested for loop. I search through int_list, and for each element in int_list I search through int_list again. N for the outer and n^2 with the inner. 2) The...
true
21b935d316daacdd26b6ee02b1bcf5d4b449e462
serafdev/codewars
/merged_string_checker/code.py
440
4.125
4
def is_merge(s, part1, part2): return merge(s, part1, part2) or merge(s, part2, part1) def merge(s, part1, part2): if (s == '' and part1 == '' and part2 == ''): return True elif (s != '' and part1 != '' and s[0] == part1[0]): return is_merge(s[1:], part1[1:], part2) elif (s != '...
false
f587e8614825a2d013715057bf7cffc0ed0cf287
Earazahc/exam2
/derekeaton_exam2_p2.py
1,032
4.25
4
#!/usr/bin/env python3 """ Python Exam Problem 5 A program that reads in two files and prints out all words that are common to both in sorted order """ from __future__ import print_function def fileset(filename): """ Takes the name of a file and opens it. Read all words and add them to a set. Args: ...
true
b2c24fe1f3d4f3474b70461b608a2c14e9d44e9b
viralsir/python_saket
/if_demo.py
1,045
4.15625
4
''' control structure if syntax : if condition : statement else : statement relational operator operator symbol greater than > less than < equal to == not equal to != gr...
true
0bdb3507ea776a6b421a6e8dfda6c3e47f2c38bd
viralsir/python_saket
/def_demo3.py
354
4.1875
4
def prime(no): is_prime=True for i in range(2,no): if no % i == 0 : is_prime=False return is_prime def factorial(no): fact=1 for i in range(1,no+1): fact=fact*i return fact # no=int(input("enter No:")) # # if prime(no): # print(no," is a prime no") # else : # ...
true
8da0b1dd8e0dd6024cff4612ab35a83a3cfc95d2
Gallawander/Small_Python_Programs
/Caesar cipher.py
991
4.3125
4
rot = int(input("Input the key: ")) action = input("Do you want to [e]ncrypt or [d]ecrypt?: ") data = input("Input text: ") if action == "e" or action == "encrypt": text = "" for char in data: char_ord = ord(char) if 32 <= char_ord <= 126: char_ord -= 32 char_o...
false
2a0ffb39c845e7827d3a841c9f0475f42e8a5838
kalyan-dev/Python_Projects_01
/demo/oop/except_demo2.py
927
4.25
4
# - Accept numbers from user until zero is given and display SUM of the numbers; handle Invalid Numbers; # program should not crash, but should continue; def is_integer(n): try: return float(n).is_integer() except ValueError: return False def is_integer_num(n): if isinstance(...
true
9b6a117c5d2ae6e591bc31dfd1ba748b84079710
tejaboggula/gocloud
/fact.py
332
4.28125
4
def fact(num): if num == 1: return num else: return num*fact(num-1) num = int(input("enter the number to find the factorial:")) if num<0: print("factorial is not allowed for negative numbers") elif num == 0: print("factorial of the number 0 is 1") else: print("factorial of",num, "is:...
true
0fa7e809c7f4a8c7b0815a855cbc482abf600a77
dimpy-chhabra/Artificial-Intelligence
/Python_Basics/ques1.py
254
4.34375
4
#Write a program that takes three numbers as input from command line and outputs #the largest among them. #Question 02 import sys s = 0 list = [] for arg in sys.argv[1:]: list.append(int(arg)) #arg1 = sys.argv[1] list.sort() print list[len(list)-1]
true
e8e83ac29ce59ebb1051bbe6457e3d5bd8ade162
snail15/AlgorithmPractice
/Udacity/BasicAlgorithm/binarySearch.py
1,127
4.3125
4
def binary_search(array, target): '''Write a function that implements the binary search algorithm using iteration args: array: a sorted array of items of the same type target: the element you're searching for returns: int: the index of the target, if found, in the source -1: ...
true
460d75a61550f0ae818f06ad46a9c210fe0d254e
lyderX05/DS-Graph-Algorithms
/python/BubbleSort/bubble_sort_for.py
911
4.34375
4
# Bubble Sort For Loop # @author: Shubham Heda # Email: hedashubham5@gmail.com def main(): print("**NOTE**: Elements should be less then 25 as alogrithm work best on that only") print("Enter Bubble Sort elements sepreated by (',') Comma: ") input_string = input() array = [int(each) for each in input_st...
true
eb1a3b4a62c74a8d53416c6e5a5f48a2ab4c2e67
yaroslavche/python_learn
/1 week/1.12.5.py
1,034
4.15625
4
# Напишите программу, которая получает на вход три целых числа, по одному числу в строке, и выводит на консоль в три # строки сначала максимальное, потом минимальное, после чего оставшееся число. # На ввод могут подаваться и повторяющиеся числа. # Sample Input 1: # 8 # 2 # 14 # Sample Output 1: # 14 # 2 # 8 # Sample In...
false
208303bdec3be5362ce314eb632da444fed96f2c
yaroslavche/python_learn
/2 week/2.1.11.py
504
4.21875
4
# Напишите программу, которая считывает со стандартного ввода целые числа, по одному числу в строке, и после первого # введенного нуля выводит сумму полученных на вход чисел. # Sample Input 1: # 5 # -3 # 8 # 4 # 0 # Sample Output 1: # 14 # Sample Input 2: # 0 # Sample Output 2: # 0 s = 0 i = int(input()) while i != 0:...
false
8674d8f7e11eae360e63b470b7b2310f7170c5cc
zeusumit/JenkinsProject
/hello.py
1,348
4.40625
4
print('Hello') print("Hello") print() print('This is an example of "Single and double"') print("This is an example of 'Single and double'") print("This is an example of \"Single and double\"") seperator='***'*5 fruit="apple" print(fruit) print(fruit[0]) print(fruit[3]) fruit_len=len(fruit) print(fruit_len) ...
true
33553f9506dc46c9c05101074116c5254af7d0e9
EderVs/hacker-rank
/30_days_of_code/day_8.py
311
4.125
4
""" Day 8: Dictionaries and Maps! """ n = input() phones_dict = {} for i in range(n): name = raw_input() phone = raw_input() phones_dict[name] = phone for i in range(n): name = raw_input() phone = phones_dict.get(name, "Not found") if phone != "Not found": print name + "=" + phone else: print phone
true
6784ec88c6088dfcd462a124bc657be9a4c51c3c
asmitaborude/21-Days-Programming-Challenge-ACES
/generator.py
1,177
4.34375
4
# A simple generator function def my_gen(): n = 1 print('This is printed first') # Generator function contains yield statements yield n n += 1 print('This is printed second') yield n n += 1 print('This is printed at last') yield n # Using for loop for item in...
true
46a7b9c9a436f4620dac591ed193a09c9b164478
asmitaborude/21-Days-Programming-Challenge-ACES
/python_set.py
2,244
4.65625
5
# Different types of sets in Python # set of integers my_set = {1, 2, 3} print(my_set) # set of mixed datatypes my_set = {1.0, "Hello", (1, 2, 3)} print(my_set) # set cannot have duplicates # Output: {1, 2, 3, 4} my_set = {1, 2, 3, 4, 3, 2} print(my_set) # we can make set from a list # Output: {1, 2, ...
true
1a87238ebb8b333148d1c2b4b094370f21fd230b
asmitaborude/21-Days-Programming-Challenge-ACES
/listsort.py
677
4.4375
4
#python list sort () #example 1:Sort a given list # vowels list vowels = ['e', 'a', 'u', 'o', 'i'] # sort the vowels vowels.sort() # print vowels print('Sorted list:', vowels) #Example 2: Sort the list in Descending order # vowels list vowels = ['e', 'a', 'u', 'o', 'i'] # sort the vowels vowels.sort...
true
6346a452b77b895e2e686c5846553687459798ca
asmitaborude/21-Days-Programming-Challenge-ACES
/dictionary.py
2,840
4.375
4
#Creating Python Dictionary # empty dictionary my_dict = {} # dictionary with integer keys my_dict = {1: 'apple', 2: 'ball'} # dictionary with mixed keys my_dict = {'name': 'John', 1: [2, 4, 3]} # using dict() my_dict = dict({1:'apple', 2:'ball'}) # from sequence having each item as a pair my_dict = d...
true
f1e73874c9d09a51aa7b9c4a5890fe3cb34f5622
parth-sp02911/My-Projects
/Parth Patel J2 2019 problem.py
1,161
4.125
4
#Parth Patel #797708 #ICS4UOA #J2 problem 2019 - Time to Decompress #Mr.Veera #September 6 2019 num_of_lines = int(input("Enter the number of lines: ")) #asks the user how many lines they want and turns that into an integer output_list = [] #creates a list which will hold the values of the message th...
true
4783c951d8caaf9c5c43fb57694cfb8d60d466b7
marcinosypka/learn-python-the-hard-way
/ex30.py
1,691
4.125
4
#this line assigns int value to people variable people = 30 #this line assigns int value to cars variable cars = 30 #this line assigns int value to trucks variable trucks = 30 #this line starts compound statemet, if statemets executes suite below if satement after if is true if cars > people: #this line belongs to sui...
true
1b59b6f971ce37b62f3ed7eb6cc5d94ed8b2df44
felcygrace/fy-py
/currency.py
852
4.21875
4
def convert_currency(amount_needed_inr,current_currency_name): current_currency_amount=0 Euro=0.01417 British_Pound=0.0100 Australian_Dollar=0.02140 Canadian_Dollar=0.02027 if current_currency_name=="Euro": current_currency_amount=amount_needed_inr*Euro elif current_currency_name=="B...
false
c5d852ead39ef70ee91f26778f4a7874e38466cf
bohdi2/euler
/208/directions.py
792
4.125
4
#!/usr/bin/env python3 import collections import itertools from math import factorial import sys def choose(n, k): return factorial(n) // (factorial(k) * factorial(n-k)) def all_choices(n, step): return sum([choose(n, k) for k in range(0, n+1, step)]) def main(args): f = factorial expected = {'1'...
true
656d28880463fdd9742a9e2c6c33c2c247f01fbf
andylws/SNU_Lecture_Computing-for-Data-Science
/HW3/P3.py
590
4.15625
4
""" #Practical programming Chapter 9 Exercise 3 **Instruction** Write a function that uses for loop to add 1 to all the values from input list and return the new list. The input list shouldn’t be modified. Assume each element of input list is always number. Complete P3 function P3([5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, ...
true
b4a85cfa138df5113411b2ce9f52360a3066342d
ScaredTuna/Python
/Results2.py
455
4.125
4
name = input("Enter Name:") phy = int(input("Enter Physics Marks:")) che = int(input("Enter Chemistry Marks:")) mat = int(input("Enter Mathematics Marks:")) tot = phy + che + mat per = tot * 100 / 450 print("-------------------------------------") print("Name:", name) print("Total Marks:", tot) print("Percentage:", per...
false
69e6a29d952a0a5faaceed45e30bf78c5120c070
TommyWongww/killingCodes
/Daily Temperatures.py
1,025
4.25
4
# @Time : 2019/4/22 22:54 # @Author : shakespere # @FileName: Daily Temperatures.py ''' 739. Daily Temperatures Medium Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future da...
true
1ae82daf01b528df650bd7e72a69107cdf686a82
TommyWongww/killingCodes
/Invert Binary Tree.py
1,251
4.125
4
# @Time : 2019/4/25 23:51 # @Author : shakespere # @FileName: Invert Binary Tree.py ''' 226. Invert Binary Tree Easy Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was i...
true
9befa8049cd7c31fd959b6ad7ca652c4e1435d00
jillgower/pyapi
/sqldb/db_challeng.py
2,819
4.21875
4
#!/usr/bin/env python3 import sqlite3 def create_table(): conn = sqlite3.connect('test.db') conn.execute('''CREATE TABLE IF NOT EXISTS EMPLOYEES (ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL);''') print(...
false
048cc584eda064b0d148fea8d69843bb26051ed1
thalessahd/udemy-tasks
/python/ListaExercicios1/ex5.py
637
4.15625
4
# -*- coding: utf-8 -*- """ Escreva um programa que receba dois números e um sinal, e faça a operação matemática definida pelo sinal. """ print("Digite o primeiro número:") num1 = float(input()) print("Digite o segundo número:") num2 = float(input()) print("Digite o sinal:") sinal = input() if sinal=="+": resu = ...
false
202bd0898352102599f6e4addccaec7a60b46a8f
amymhaddad/exercises_for_programmers_2019
/flask_product_search/products.py
1,454
4.15625
4
import json #convert json file into python object def convert_json_data(file): """Read in the data from a json file and convert it to a Python object""" with open (file, mode='r') as json_object: data = json_object.read() return json.loads(data) #set json data that's now a python object to pro...
true
6d3c6b5362c47d16b3916607be2896033e321e71
disha111/Python_Beginners
/Assignment 3.9/que2.py
552
4.1875
4
import pandas as pd from pandas.core.indexes.base import Index student = { 'name': ['DJ', 'RJ', 'YP'], 'eno': ['19SOECE13021', '18SOECE11001', '19SOECE11011'], 'email': ['dvaghela001@rku.ac.in', 'xyz@email.com', 'pqr@email.com'], 'year':[2019,2018,2019] } df = pd.DataFrame(student,index=[10,23,13]) p...
false
6ef4e9543d7c7c20bdbb1ffa4976b8c3b6e9b0f5
disha111/Python_Beginners
/extra/scope.py
672
4.15625
4
#global variable a = 10 b = 9 c = 11 print("Global Variables A =",a,", B =",b,", C =",c) print("ID of var B :",id(b)) def something(): global a a = 15 b = 5 #local variable globals()['c'] = 16 #changing the global value. x = globals()['b'] print("\nLocal Variables A =",a,", B =",b,", C =",c,",...
false
e323a0fe8e50ad7df9ecf1ce4ffe5ccd5aa5aa9b
tonnekarlos/aula-pec-2021
/T1-Ex04.py
249
4.28125
4
def verifica(caractere): # ord retorna um número inteiro representa o código Unicode desse caractere. digito = ord(caractere) # 0 é 48 e 9 é 57 return 48 <= digito <= 57 print(verifica(input("Digite um caractere: ".strip())))
false
9c0cd7be7ad5ad32f43d66d7ccceb2ddfe673a12
Smirt1/Clase-Python-Abril
/IfElifElse.py
611
4.15625
4
#if elif else tienes_llave = input ("Tienes una llave?: ") if tienes_llave == "si": forma = input ("Que forma tiene la llave?: ") color = input ("Que color tiene la llave?: ") if tienes_llave != "si": print ("Si no tienes llaves no entras") if forma == "cuadrada" and color =="roja":...
false
ab06ae955363b0ac7fcdfd22f35e9ea6e698d5c3
LakshayLakhani/my_learnings
/programs/binary_search/bs1.py
484
4.125
4
# given a sorted arrray with repititions, find left most index of an element. arr = [2, 3, 3, 3, 3] l = 0 h = len(arr) search = 3 def binary_search(arr, l, h, search): mid = l+h//2 if search == arr[mid] and (mid == 0 or arr[mid-1] != search): return mid elif search <= arr[mid]: return bina...
true
99f8aed5acd78c31b9885eba4b830807459383be
chenp0088/git
/number.py
288
4.375
4
#!/usr/bin/env python # coding=utf-8 number = input("If you input a number ,I will tell you if the number is multiplier of ten! Please input the number: ") number = int(number) if number%10 == 0: print("It`s the multiplier of ten!") else: print("It`s not the multiplier of ten!")
true
a01c02e5227267010b7bf6ddb54c2502797bb3c6
Akshay7591/Caesar-Cipher-and-Types
/ROT13/ROT13encrypt.py
270
4.1875
4
a=str(input("Enter text to encrypt:")) key=13 enc="" for i in range (len(a)): char=a[i] if(char.isupper()): enc += chr((ord(char) + key-65) % 26 + 65) else: enc += chr((ord(char) + key-97) % 26 + 97) print("Encrypted Text is:") print(enc)
false
08e48ae76c18320e948ec941e0be4b598720feeb
nkarasovd/Python-projects
/Data Structures and Algorithms Specialization/Algorithms on Strings/week2/4_suffix_array/suffix_array.py
632
4.1875
4
# python3 import sys def build_suffix_array(text): """ Build suffix array of the string text and return a list result of the same length as the text such that the value result[i] is the index (0-based) in text where the i-th lexicographically smallest suffix of text starts. """ ...
true
de7f2d2afcb130e6d5484bdbad0795fbf54bdf2f
Moloch540394/machine-learning-hw
/linear-regression/driver.py
1,398
4.3125
4
"""Computes the linear regression on a homework provided data set.""" __author__="Jesse Lord" __date__="January 8, 2015" import numpy as np import matplotlib.pyplot as plot from computeCost import computeCost from gradientDescent import gradientDescent from featureNormalization import featureNormalization import read...
true
1248d4aa0f0fcdb613782972fba43d20df509d96
elvispy/PiensaPython
/1operaciones.py
2,279
4.125
4
''' Existen varios tipos de operaciones en Python. El primero, y mas comun es el de la adicion. ''' x, y, z = 3, 9, '4' a = 'String' b = [1, 2, 'lol'] ''' La siguiente linea de codigo imprimira el resultado de sumar x con yield ''' print(x+y) ''' Debemos recordar que es imposible en la gran mayoria de los casos...
false
1a3bd1022273e086eeeb742ebace201d1aceceae
tmoraru/python-tasks
/less9.py
434
4.1875
4
#Print out the slice ['b', 'c', 'd'] of the letters list. letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] print(letters[1:4]) #Print out the slice ['a', 'b', 'c'] of the letters list letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] print(letters[0:3]) #Print out the slice ['e', 'f', 'g'] of the letters lis...
true
d4076402594b83189895f19cdc4730f9bd5e9072
liginv/LP3THW
/exercise11-20/ex15.py
547
4.15625
4
# Importing the function/module argv from sys library in python from sys import argv # Assigning the varable script & filename to argv function script, filename = argv # Saving the open function result to a variable txt. # Open function is the file .txt file. txt = open(filename) # Printing the file name. print(f"Here'...
true
8aaab09f3b60c92e1b2ffa700e991086cdaf24d2
liweicai990/learnpython
/Code/Leetcode/top-interview-questions-easy/String33.py
1,141
4.21875
4
''' 功能:整数反转 来源:https://leetcode-cn.com/explore/featured/card/top-interview-questions-easy/5/strings/33/ 重点:整数逆序算法 作者:薛景 最后修改于:2019/07/19 ''' # 本题需要分成正数和负数两种情况讨论,所以我们用sign存下该数的符号,然后对其求绝 # 对值,再统一进行正整数的逆序算法,以化简问题难度 # 该方案战胜 88.27 % 的 python3 提交记录 class Solution: def reverse(self, x: int) -> int: sign = 1 if x>...
false
7106600daa9540e96be998446e8e199ffd56ec28
rhino9686/DataStructures
/mergesort.py
2,524
4.25
4
def mergesort(arr): start = 0 end = len(arr) - 1 mergesort_inner(arr, start, end) return arr def mergesort_inner(arr, start, end): ## base case if (start >= end): return middle = (start + end)//2 # all recursively on two halves mergesort_inner(arr, middle + 1, end) ...
true
8b54f8006c98b5e88b7dd655e8338bb4fe3ba02c
CyberSamurai/Test-Project-List
/count_words.py
574
4.4375
4
""" -=Mega Project List=- 5. Count Words in a String - Counts the number of individual words in a string. For added complexity read these strings in from a text file and generate a summary. """ import os.path def count_words(string): words = string.split() return len(words) def main(file): filename = os...
true
f5f862e7bc7179f1e9831fe65d20d4513106e764
AhmedMohamedEid/Python_For_Everybody
/Data_Stracture/ex_10.02/ex_10.02.py
1,079
4.125
4
# 10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon. # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008...
true
14fd0afadadb85ccffb9e5cb447fa155874479ea
thienkyo/pycoding
/quick_tut/basic_oop.py
657
4.46875
4
class Animal(object): """ This is the animal class, an abstract one. """ def __init__(self, name): self.name = name def talk(self): print(self.name) a = Animal('What is sound of Animal?') a.talk() # What is sound of Animal? class Cat(Animal): def talk(self): print(...
true
d0ac9c79bc132a70a1542d97018838a58e7d7835
OlegLeva/udemypython
/72 Бесконечный генератор/get_current.py
788
4.21875
4
# def get_current_day(): # week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] # i = 0 # while True: # if i >= len(week): # i = 0 # yield week[i] # i += 1 # # # amount_day = int(input('Введите количество дней ')) # current_day = get_curre...
false
4f330c0fdbe5a6cc49b506011b88c610ef1abc60
Jules-Boogie/controllingProgramFlow
/SearchAStringFunction/func.py
1,087
4.21875
4
""" A function to find all instances of a substring. This function is not unlike a 'find-all' option that you might see in a text editor. Author: Juliet George Date: 8/5/2020 """ import introcs def findall(text,sub): """ Returns the tuple of all positions of substring sub in text. If sub does not appea...
true
b1185e9c9738f772857051ae03af54a4fb20487e
Jules-Boogie/controllingProgramFlow
/FirstVowel-2/func.py
976
4.15625
4
""" A function to search for the first vowel position Author: Juliet George Date: 7/30/2020 """ import introcs def first_vowel(s): """ Returns the position of the first vowel in s; it returns -1 if there are no vowels. We define the vowels to be the letters 'a','e','i','o', and 'u'. The letter 'y' ...
true
b7d990539a50faef24a02f8325342f385f518101
github0282/PythonExercise
/Abhilash/Exercise2.py
1,141
4.34375
4
# replace all occurrences of ‘a’ with $ in a String text1 = str(input("Enter a string: ")) print("The string is:", text1) search = text1.find("a") if(search == -1): print("Character a not present in string") else: text1 = text1.replace("a","$") print(text1) # Take a string and replace every blank space wi...
true