blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0386e038ae62402589ae44a7ef8c9d434880e1ae
Jaxwood/daily
/problems/problem024.py
1,584
4.125
4
class Node: """Implement locking in a binary tree. A binary tree node can be locked or unlocked only if all of its descendants or ancestors are not locked.""" def __init__(self, val, locked = False, left = None, right = None): self.parent = None self.val = val self.left = left ...
true
d7d83bb0e912c85f43c022214fd1b4338cbc23cc
Jaxwood/daily
/problems/problem012.py
359
4.25
4
async def stairs(n): """There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters.""" if n == 0: return 1 if n < 0: return...
true
88080bc935b83b5f0deab2215c11f45fc56dcb50
Danielhsuuu/LearnPythonTheHardWay
/ex7.py
1,185
4.3125
4
#prints "Mary had a little lamb." print("Mary had a little lamb.") #prints "Its fleece was white as snow." print("Its fleece was white as {}.".format('snow')) #prints "And everywhere that Mary went." print("And everywhere that Mary went.") #prints ten "." print("." * 10) # what'd that do? #declares a string named end...
true
9cede981b050c5c706877d0ab880c27e5a3fac49
Danielhsuuu/LearnPythonTheHardWay
/ex19.py
2,820
4.40625
4
#defines a functioin named cheese_and_crackers that takes two arguments named cheese_count and boxes_of_crackers def cheese_and_crackers(cheese_count, boxes_of_crackers): #prints "You have {cheese_count} cheeses!" print("You have %d cheeses!" % cheese_count) #prints "You have {boxes of crakers} boxes of cr...
true
0254475998b38e1c71803b8b1a5bb713d6141185
Danielhsuuu/LearnPythonTheHardWay
/ex8.py
586
4.28125
4
#declares a string that contains four {} that can each take in strings and display them formatter = "{} {} {} {}" #prints 1 2 3 4 print(formatter.format(1, 2, 3, 4)) #prints one two three four print(formatter.format("one", "two", "three", "four")) #prints True False False True print(formatter.format(True, False, False,...
true
08d073f705b5d82654fa8af1d268f947a6d5ab3c
schoenij/MyCookbook
/Basics/Input_and_Output_Methods/output_a_table.py
607
4.4375
4
# Example of str.rjust() for x in range(1, 11): print(repr(x).rjust(2), repr(x*x).rjust(3), repr(x*x*x).rjust(4)) # Example of str.ljust() for x in range(1, 11): print(repr(x).ljust(2), repr(x*x).ljust(3), repr(x*x*x).ljust(4)) # Example of str.center() for x in range(1, 11): print(repr(x).center(2), repr...
true
88ce7680b92de473749a6f51000875a101d13ff7
cerjakt/SENG3110GeometryCalculator
/cuboid.py
1,287
4.59375
5
################### # # Name: Jake Cermak # # Program Name: Finding Volume and Surface Area of a Cuboid # # Program Description: A simple program that asks for the length, # width, and height to find the surface area, volume, and lateral # surface area of a cuboid. # ################### import math def pro...
true
2aa99b2f5fe639a1b531e0fbced13b95326d04e8
cerjakt/SENG3110GeometryCalculator
/equilateral_triangle.py
1,295
4.4375
4
################### # # Name: Jake Cermak # # Program Name: Finding Area and Perimeter of an Equilateral Triangle # # Program Description: A simple program that asks for the length of # any side of an equilateral triangle to find the area, perimeter, # semi perimeter, and altitude. # ################### imp...
true
c1579b25bd4cdefac7db2097ca174252129f0b24
nika02/cp2019
/p3/q6_display_matrix.py
407
4.4375
4
# Write a function print_matrix(n) that displays an n by n matrix, # where n is a positive integer entered by the user. # Each element is 0 or 1, which is generated randomly. # A 3 by 3 matrix may look like this: # 0 1 0 # 0 0 0 # 1 1 1 import random n = int(input()) for i in range(n): a = str(random.randint(0, ...
true
5bd16a04f5bbdb888aeb00749e8de080dfbeadf6
nika02/cp2019
/p1/q1_fahrenheit_to_celsius.py
403
4.4375
4
# Write a program q1_fahrenheit_to_celsius.py that reads a Fahrenheit degree # in double (floating point / decimal) from standard input, then converts # it to Celsius and displays the result in standard output. # The formula for the conversion is as follows: celsius = (5/9) * (fahrenheit - 32) Fahrenheit = int(input("...
true
b31db5a2cee1efafc5bf7b6f48a72f090db61e82
waghmarenihal/PythonTrainingProjects
/TrainingProjects/LoopingProjects/FileOperations.py
400
4.1875
4
file1=open("file1.txt","a") file2=open("file2.txt","a") file3=open("file3.txt","w") print("Enter text for file 1:") file1.write(input(">")+"\n") print("Enter text for file 2:") file2.write(input(">")+"\n") file1=open("file1.txt","r") file2=open("file2.txt","r") file3.write(file1.read()+file2.read()) print("\nOutput...
true
14128b2c7c9da1ba89f96436b68b340ec9a8eaa9
aethersg/daily-coding-problem
/problem_3.py
1,398
4.1875
4
''' Good morning! Here's your coding interview problem for today. This problem was asked by Google. Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree. For example, given the following Node class ...
true
dd506c24a461b3abe75734f1896630912c93109c
Nirkan/Basic-Python-Projects
/Largest-array/Largest_array.py
272
4.21875
4
str_array = input().split(' ') arr = [int(num) for num in str_array] n = len(arr) def max(arr, n): max = arr[0] for i in range(1, n): if arr[i] > max: max = arr[i] return max Result = max(arr, n) print("The biggest number in the given array is ", Result)
true
fd5f407df472ead3a92f7245b9536cbd86ebb403
tahir-za/mypackage
/mypackage/sorting.py
1,791
4.21875
4
def bubble_sort(items): '''Return array of items, sorted in ascending order''' if len(items) < 1: return ('No items to sort') else: n = len(items) for i in range(n): for j in range(0, n-i-1): if items[j] > items[j+1]: items[j], items ...
true
b4468298ee22a3edd904f22876a8d9fae9620c84
alexsg4/udacity-python
/lesson3.py
2,679
4.25
4
# Data structures # Lists # We can create lists of objects of various types # Indexing is 0 based but we've got Matlab style slices my_list = ['stuff', 3.14, 'LLama', 25] print(my_list[1:2]) # We can also index from the end of the list print(my_list[-3]) print(my_list[2:]) # Membership operators print('LLama' in...
true
c14ca28db5b4998364160944226ab7bb6b9df59d
barrenec/katas
/fundamentals/geometric_progression.py
911
4.34375
4
''' In your class, you have started lessons about geometric progression. Since you are also a programmer, you have decided to write a function that will print first 'n' elements of the sequence with the given constant 'r' and first element 'a'. Result should be separated by comma and space Example: geometric_seque...
true
f02e5f15a8f7a370c1374c9336a345a60ecd4c11
barrenec/katas
/fundamentals/actually_really_good.py
2,027
4.1875
4
''' http://xkcd.com/1609/ Task: Given an array containing a list of good foods, return a string containing the assertion that any two of the individually good foods are really good when combined. eg: "You know what's actually really good? Pancakes and relish." Examples: Good_foods = ["Ice cream", "Ham", "Relish",...
true
5ad973ba537570cc6e2f27bc49da1ac6dd20d82c
RSTZZZ/SQL-Encryption-Decryption
/reading.py
1,649
4.21875
4
# Functions for reading tables and databases import glob from database import * # a table is a dict of {str:list of str}. # The keys are column names and the values are the values # in the column, from top row to bottom row. # A database is a dict of {str:table}, # where the keys are table names and values...
true
72dde58dc547aee3ef98a99727ec2aa9dbdb2481
okrrooo/Tournoi_P4
/View/round_view.py
505
4.15625
4
#! Python3 # coding: utf-8 """View to ask to the user to enter score at the end of the match""" def enter_score(match): print("Match's score :") print( f"player 1 :\t {match.player1.name} ({match.player1.id_player}), score:{match.player1.score}" ) print( f"player 2 :\t {match.player2...
true
d19828f197224872e076e70ae37e47df9e99fb9e
2RMalinowski/algorithms-and-katas
/balanced_brackets.py
971
4.28125
4
""" Generate a string with N opening brackets ("[") and N closing brackets ("]"), in some arbitrary order. Determine whether the generated string is balanced; that is, whether it consists entirely of pairs of opening/closing brackets (in that order), none of which mis-nest. Examples: [] OK ][ NOT OK []...
true
66533f995419ad20555e784c17b0135edf24740a
dominiquecuevas/cracking-the-coding-interview
/01-arrays-and-strings/string-rotation.py
699
4.375
4
''' Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring (e.g., "waterbottle" is a rotation of "erbottlewat") ''' ''' s1 and s2 should be same length to be rotation - edg...
true
b0a7a0b05d1e56e543f7a8da45825c1fdbf5be5d
prasadbylapudi/PythonProgramming
/sets/set_comparasion.py
398
4.125
4
Days1 = {"Monday", "Tuesday", "Wednesday", "Thursday"} Days2 = {"Monday", "Tuesday"} Days3 = {"Monday", "Tuesday", "Friday"} #Days1 is the superset of Days2 hence it will print true. print (Days1>Days2) #prints false since Days1 is not the subset of Days2 print (Days1<Days2) #prints...
true
2eddeff8c82acee534c2293da058f9d1db2685de
prasadbylapudi/PythonProgramming
/built-in-string_functions/find_method.py
375
4.25
4
#Python find() method finds substring in the whole string and returns index of the first match. It returns -1 if substring does not match. str1="word robe word hello everyonen "; str2=str1.find("rd"); print(str2) #we can also specify the starting index and ending index. """ Parameters sub : substring start : st...
true
a571622118dc496a4b542327af695f796093b4e6
prasadbylapudi/PythonProgramming
/sets/discard vs remove.py
858
4.125
4
Months = set(["January","February", "March", "April", "May", "June"]) print("\nprinting the original set ... ") print(Months) print("\nRemoving items through discard() method..."); Months.discard("Feb"); #will not give an error although the key feb is not available in the set print("\nprinting the modifi...
true
f05bb199fec10b9913357b6ec8047e8e8db5ba41
prasadbylapudi/PythonProgramming
/Functions/keyword_argument_mixed_parameters.py
476
4.3125
4
def fun(name1,message,name2): print("printing the message with",name1,message,name2); fun("john",message="hello",name2="david"); """ The python allows us to provide the mix of the required arguments and keyword arguments at the time of function call. However, the required argument must not be given after th...
true
ea5afc39307640ebf7d5e8c8ddff39c3263c8763
prasadbylapudi/PythonProgramming
/Functions/call_by_reference.py
663
4.25
4
def List(List1): List1.append(20); List1.append(30); print("list inside function",List1); List1=[10,40,50,60] #calling the function List(List1); print("list out side the function=",List1); """ In python, all the functions are called by reference, i.e., all the changes made to the refere...
true
7510326833eeb4e1122e81f42dc3fd239006f0bb
amanhans306/python_Programmingtask
/5_Strings.py
578
4.25
4
# Author Name # Creation Date # Use what you know about the print() function to print out the phrase "Hello World". Make sure your capitalization and spacing mathches # Write a string index that returns just the letter 'r' from "Hello World" # Use string slicing to grab the word 'ink' from inside "tinker" # Grab ever...
true
eb4eada04414c64d66024daa75469b37467aa5ae
nonnikb/Forritun-Vor-nn
/Verkefni_1/loan.py
767
4.125
4
loan = float(input("Input the cost of the item in $: ")) payment = 50.0 months = 1 interest = 0 if loan > 2499: print("Loan too high!") loan = 0.0 elif loan <= 1000: interest_rate = 0.015 else: interest_rate = 0.020 while loan > 0: tax = loan * interest_rate interest += tax if payment > l...
true
81811f5f7cb59e906c468d70a15fb22f967deefa
LarsonLL/Code
/Python/Basic Example/If_Syntax/toppings.py
1,212
4.15625
4
requested_topping = 'mushrooms' if requested_topping != 'anchovies': print("Hold the anchovies !") requested_toppings = ['mushrooms', 'green peppers', 'extra cheese'] for requested_topping in requested_toppings: if requested_topping == 'green peppers': print("Sorry, we are out of green peppers right now .") els...
true
cba1bde530f9c92d59824ad22fbe76c36b0c927e
hankazajicova/Py-code-challenge
/src/pp_13_fibonacci.py
520
4.46875
4
def get_fibonacci(count_numbers: int) -> list: """get fibonacci sequence of input count of numbers Args: count_numbers (int): user input count of numbers Returns: list: fibonacci sequence """ fibonacci = [0, 1] for _ in range(0, count_numbers - 2): sum_last_two = sum(fi...
true
4b46e456b0689c0873f4f2542149f1b2bdcdbf6e
IvanTheGr8pe/Misc-School-Projects
/student.py
705
4.375
4
''' This class will define a student with three attributes: - Name - Midterm grade - Final grade ''' class Student: # the initialization method def __init__(self, n="", midG=0, finalG=0): self.name = n self.midterm = midG self.finalGrade = finalG # set the attribute n...
true
05b0ae9f6d260610b037d7ae33634cd50dbd7a19
muh-nasiruit/programming-fundamentals
/PF 05 Problems/pf4.py
541
4.3125
4
''' 4. Write a function which will check either the giving string is Palindrome or not. Palindrome is a string when we reverse the string it will generate the original string. Example CIVIC, MOM, 010, 1001, etc. So if you enter the word which is Palindrome it will say yes your string is Palindrome otherwise it will gen...
true
cb3b686767f1709cc0b49be023a7eae45b244e3b
muh-nasiruit/programming-fundamentals
/PF 05 Problems/pf10.py
508
4.21875
4
''' 10. Write a function which will generate a table of sin(), cos(), tan() with user defined range. ''' def ang_table(): i_val = int(input("Enter the final angle: ")) f_val = int(input("Enter the initial angle: ")) for i in range(i_val, f_val): import math rad_i = math.pi * i_val / 180 ...
true
f8c69046ea2b4e7ca1ca5144e5230eb35ec84cbc
artorious/kalculator
/scripts/travelling_salesman.py
787
4.1875
4
#!/usr/bin/env python3 '''A simple calculator for the travelling salesman problem.''' __author__ = 'Arthur Ngondo' __version__ = '$Version: 1.0.0 $' from math import factorial def routes_possible(): '''prompts user for a the number of cities for the traveling salesman problem, and displays the total number ...
true
597cbbcea3fcb00149af59ba3e78141d4c7a65ef
RLain/python_training_2019
/Getting Started with Python/week_5/ex_01.py
787
4.3125
4
#3.1 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. #Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. #Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). #You should u...
true
78aff1e68e4fa0618a9b753f087c36591184611a
sanjayramalings/Learning-Python
/Ch2/functions_start.py
771
4.4375
4
# # Example file for working with functions # # define a basic function def fun1(): print("I am a function") #it doesnt return a value # function that takes arguments def fun2(arg1,arg2): print(arg1," ",arg2) # function that returns a value def cube(x): return x+x+x # function with default ...
true
8af39feba0d8215817e88c27bf26e37a915b74fd
lezakkaz/Python-workshop
/Examples/example_3.py
403
4.21875
4
# Python workshop Part 3 by Khiati Zakaria # Example 3 (Functions) # a function that takes 2 integers as input and return their multiplication def multiplication(x, y): result = x*y return result # few examples a = multiplication(5, 5) print("5 * 5 = " + str(a)) b = multiplication(10, 3) prin...
true
a67a1a68f805c2e7c12be484aef482c4348d404d
henicorhina/PopGen
/ProbDetectAllele.py
1,147
4.25
4
#! /usr/bin/env python """ @author: henicorhina """ import math import random import matplotlib.pyplot as plt # crap, this can be broken down to p = b^n # Question 2 print "Lets calculate range of percent probability of detecting an allele" print "using the equation: p = (n!/s!t!)(a^s)(b^t)" print "given a = 0.05"...
true
6f68ab3247ecf0c032856890e82a18faa15a1f6b
awuorm/Sprint-Challenge--Algorithms
/recursive_count_th/count_th.py
858
4.125
4
''' Your function should take in a single parameter (a string `word`) Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters. Your function must utilize recursion. It cannot contain any loops. ''' def count_th(word, count=0): word_list = list(word) if len(wo...
true
acea888076792fe27eff0eedf653e78de4470fea
Yifan127/LearnPythonTheHardWay
/ex35_drills.py
460
4.25
4
while True: s = input("Please input a number: ") # string.isdigit - Return true if all characters in the string # are digits and there is at least one character, false otherwise. if s.isdigit(): s = int(s) break else: print("%s is not a number." % s) while True: try: ...
true
1afcea8594f758fd19cf351eecd245bb0d0dedb0
kynants/Time_Calculator
/src.py
990
4.34375
4
''' Design a program that asks the user to enter a number of seconds, and works as follows: - There are 60 seconds in a minutes. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. - There are 3,600 seconds i...
true
6bb88bc2aa0ae57deaefe459fa5c3e101432783c
yuriy-sm/100-Days-Of-Python
/day_1.py
1,305
4.4375
4
#learning print # print('Day 1 - Python Print Function') # print('The function is declared like this:') # print("print('what to print')") #string parameters in python #new line # print("Hello world! \nHello World\n") #concatinate # print("Hello" + " " + "Yurii") #debuging exercise # print("Day 1 - String Manipulatio...
true
2e35f20b42444da06894aa4897d07a0b039330a8
Caimingzhu/Managing_Your_Biological_Data_with_Python_3
/04-parsing_data/4.4.2_read_fasta_to_list.py
606
4.1875
4
''' Example for parsing a text file. Reads all AC numbers from the deflines of a FASTA file. ----------------------------------------------------------- (c) 2013 Allegra Via and Kristian Rother Licensed under the conditions of the Python License This code appears in section 4.4.2 of the book "Managing Bio...
true
6f6b62b9c7c300c03445b9f7ce59f6c1fad8095b
chiptus/cs50x-solutions
/pset6/crypt/caesar/caesar.py
1,193
4.125
4
from sys import argv from cs50 import get_string def main(): """Main Method""" if len(argv) != 2: print("Number of supplied arguments is illegal") exit(1) is_number, key = is_number_string(argv[1]) if not is_number: print("Key is not a number") exit(1) plaintext = g...
true
146fb4d6539d29252862a95881ab6c1da24818c3
asiasharif/Functions-ProblemSolving
/Functions/problemsolving/functionsproblem.py
1,536
4.25
4
#lesser of two evens, write a function that returns the lesser of two given fucntions if both numbers are even #but returns the greater if one or btoh are odd # lesser_of_two_evens(2,4) ---> 2 # lesser_of_two_evens(2,5) ---> 5 # def lesser_of_two_evens(a,b): # # if a%2 == 0 and b%2 == 0: # #both numbers are e...
true
ece63e923b9128a095ffff82295a90f4cd4f15a4
Tquran/Python-Code-Samples
/M7P4TQ.py
625
4.375
4
# Tamer Quran # 8/24/2021 # This program Takes an input of the year from the user and tells them if it is a leap year # Also if it is divisible by 4 its is good, if divisible by 100 it is not good, but divisible by 400 is good. year = int(input("What year would you like to check?")) def leap(year): if year % ...
true
def53c33a41fb92bac0462c756393b1ca2872e4c
Tquran/Python-Code-Samples
/M4P2BTQ.py
307
4.25
4
# Tamer Quran # 7/29/2021 # This program prints each number and its square on a new line # 12, 10, 32, 3, 66, 17, 42, 99, 20 myList = [12, 10, 32, 3, 66, 17, 42, 99, 20] for i in myList: print(i ** 2) # I squared each item on the list by using ** and the program did the rest by going down the list.
true
1adad533c9ebfc05bfca0ebd5980e78d02e8e098
Tquran/Python-Code-Samples
/M4P4TQ.py
725
4.625
5
# Tamer Quran # 7/29/2021 # This gives a list from 1 to 50. The numbers that aren't divisible by 3,5,or both they are left alone. # if they are divisible then it replaces the number and says what it is divisible by. for i in range(1, 51): if i % 3 == 0 and i % 5 != 0: print("Divisible by three") ...
true
df7018d22f0f7724abb9c9e50d04b35cb110131e
jvcano/python
/day-10/calculador/calculator-1.2.py
1,990
4.28125
4
from art import logo def add(n1, n2): """[this is the sum of 2 numbers] Args: n1 ([int]): [first number] n2 ([int]): [second number] Returns: [int]: [result of the sum] """ return n1+n2 def substraction(n1, n2): """[this is the subtraccion of two numbers only positi...
true
d3da576d5768e4d072ac49b1b345f5ae8dec6ae2
aitorlb/Udacity-Free-Courses
/Introduction to Python Programming/Lesson_2_Data_Types_and_Operators/Type and Type Conversion.py
701
4.4375
4
# Calculate and print the total sales for the week from the data provided. # Print out a string of the form "This week's total sales: xxx", where xxx will # be the actual total of all the numbers. You’ll need to change the type of the # input data in order to calculate that total. mon_sales = "121" tues_sales = "105" w...
true
8dcee1feac1d019e9e66b98dc2403ead9e1f2a81
aitorlb/Udacity-Free-Courses
/Programming Foundations with Python/Lesson_3_Usa_ classes_Draw_Turtles/Circle of Squares.py
639
4.3125
4
import turtle def draw_square(some_turtle): for i in range(1,5): some_turtle.forward(100) some_turtle.right(90) def draw_circle(some_turtle): while True: draw_square(some_turtle) some_turtle.right(11) def draw_circle_of_squares(): # Creates the window window = turtle....
true
69f175257125cc1b57bf3a20427e513acb8e7ea3
joshua-shockley/Graphs
/projects/ancestor/ancestor.py
1,742
4.15625
4
# need to create a graph and utilize bfs? # but upon adding new current only add the smallest of the "parents" aka neighbors # need to setup so tha as making the dict for verticies makes all the verticies # but sets up so that the "neighbors" are the parents of the vertices to use in # that similar manner as our graph...
true
5159590e145695a92843507fba5352b645fb23ab
shiumachi/playground
/python/expert_python_programming/generator_test.py
496
4.1875
4
#!/usr/bin/python def power(values): for value in values: print "powering %s" % (value) yield value def adder(values): for value in values: print "adding to %s" % (value) if value % 2 == 0: yield value + 3 else: yield value + 2 elements = [1, 4, ...
true
6b1982bb820024da609f51623fea9e144fcfa180
DevonHastings/Sandbox
/Sand.py
1,393
4.1875
4
import matplotlib.pyplot as plt def average(data): ''' A simple averaging function for a list. :param data: The list of numbers. :return: The average of the list of numbers. ''' return sum(data)/len(data) def seven_day_average(data): ''' Calculates the moving average of calendar data....
true
2069d7db7c2c1c9d8940ed6799ff400a8ecfab75
reidemeister94/knowledge
/Software_Engineer/tree/binary_tree_diameter.py
1,454
4.34375
4
"""Write a function that takes in a Binary Tree and returns its diameter. The diameter of a binary tree is defined as the length of its longest path, even if that path doesn't pass through the root of the tree. A path is a collection of connected nodes in a tree, where no node is connected to more than two other node...
true
0bc0bc17a36b0c635882e91a0b8d0ee4f530f77f
KingHxnry/Learning-Tkinter
/01_Grids.py
272
4.1875
4
from tkinter import * root = Tk() #Creating Label Widgets myLabel1 = Label(root, text = "Hello World!") myLabel2 = Label(root, text = "My Name Is Henry") #putting onto screen myLabel1.grid(row=0, column=0) myLabel2.grid(row=1, column=0) root.mainloop()
true
24aa7d0ba180448c81d9b232e307246db14a34af
starlc/PythonStardy
/.vscode/function/func_doc.py
301
4.28125
4
#!/usr/bin/python # Filename: func_doc.py def printMax(x,y): '''Print the max of two numbers. The two values must be integers''' x = int(x) y = int(y) if x>y: print(x,'x is the max one') else: print(y,'y is the max one') printMax(3,5) print(printMax.__doc__)
true
c8e7498a73352be3738ac5631b960e3369738d8e
alexandru-calinoiu/exercism
/python/collatz-conjecture/collatz_conjecture.py
771
4.40625
4
"""Just a recursion to show the number of steps for collatz conjecture Learn about this exercise here https://exercism.org/tracks/python/exercises/currency-exchange """ def steps(number): """ :param number: int - a positive integer to get us started. :return: int - the number of steps it takes to get us...
true
e3a5426031aa1a0488fcdf6ef2e2ddf5cd09fd44
lukaszszura/pythontraining
/bmicalc.py
363
4.3125
4
# input height and weight height = input("enter your height in m: ") weight = input("enter your weight in kg: ") #Specify data type for height and wight weight_as_int = float(weight) height_as_float = float(height) # BMI calculation bmi = weight_as_int / height_as_float ** 2 # saved bmi as integer bmi_as_int = int(b...
true
4758bd01b7a1ce2b416eb38acf3839242119432e
michaelfromyeg/ctci
/python/1-arrays-and-strings/1-4.py
1,257
4.28125
4
# Palindrome Permutation: check if string has a permutation that is a palindrome # TODO: solve this to perform the operation in place? def permutate_to_palindrome(s: str) -> bool: """ A palindrome is really just any string where each character is represented twice, and optionally there is a character in the m...
true
f8fa88900589c9a7255629e224b7ce5c49e1b4eb
michaelfromyeg/ctci
/python/2-linked-lists/2-6.py
770
4.25
4
# Palindrome: write a method to determine if a linked list is a palindrome from LinkedList import LinkedList, Node def is_palindrome(l: LinkedList) -> bool: """ Returns whether or not a LinkedList is a palindrome (same forwards and backwards) -- check if reverse == forward """ original = str(l) p...
true
11297812b9976063cd8621aa112b9490e1898c61
mraines4/Python_wk1
/prompt_for_number.py
286
4.375
4
# prompt user for a number then multiply that number by itself and print the results # prompt the user for a number user_input = int(input("Enter a number: ")) print(type(user_input)) # multiply that number by itself result = user_input * user_input # print the result print(result)
true
df028efffa0c68a9809f54abe566d389571920ff
Maadaan/IW-Assignment2
/python2/2nd.py
211
4.46875
4
""" 2. Write an if statement to determine whether a variable holding a year is a leap year. """ year = 1948 year = 1949 if (year % 4 == 0): print('it is leap year') else: print('it is not leap year')
true
c259023bcf6b214e6b77d4487b396c8051fd7a6b
Maadaan/IW-Assignment2
/python2/3rd.py
322
4.15625
4
""" 3. Write code that will print out the anagrams (words that use the same letters) from a paragraph of text. """ def func(word1 , word2): list1 = list(word1) list1.sort() list2 = list(word2) list2.sort() return(list1 == list2) print(func('listen', 'silent')) print(func('cat', 'rat')) ...
true
06eadd293c7696d11c63f6f007538d5ac8313b70
ElizabethRhoten/Python-Exercises
/DwarfGame.py
1,300
4.1875
4
dwarves=[] guessedNames=[] def addnames(): name=input("Enter the Name of a Dwarf or type quit to stop: ") while name != "quit": dwarves.append(name) name=input("Enter the name of a Dwarf or type quit to stop: ") print(dwarves) def guessingGame(): ans="Y" while ans==...
true
a0c3582b7b438b8938793897385530725c1c2181
Arwers/ProjectEulerExercisesPython3
/Problems/10001_prime.py
1,114
4.125
4
# Exercise 7: 10001 prime # First, we need to make function that will help us check if number is prime def is_prime(number): int(number) prime = True # True = prime, False = not prime # All of numbers below and equal to 1 are not prime if number <= 1: return False else: # Prime n...
true
98150b7e9e1376ff51c1bf86bb1433e5217615fb
njcarsearcher/practicepython
/06_palindrom.py
327
4.15625
4
#!/cygdrive/c/Users/njcar/Anaconda3/python inputstr = input("Input the string to check for palindrome: ") print('Checking {0} for palindrome'.format(inputstr)) rvsinputstr = inputstr[::-1] if inputstr == rvsinputstr: print('{0} is a palindrome'.format(inputstr)) else: print('{0} is not a palindrome'.format(inputst...
true
ccdaa4a6f79872b68567d63ed8b1b1fe281503ad
Tony-DongyiLuo/leetcode-python
/557-reverse_words_in_a_string3.py
627
4.375
4
#python3 ''' Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc" Note: In the string, each word is separated by single space and there w...
true
2ed32e55c19cad0772a5f195490665e816a60ba2
Tony-DongyiLuo/leetcode-python
/257-binary_tree_paths.py
1,057
4.15625
4
#python3 ''' Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: ["1->2->5", "1->3"] ''' # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # se...
true
329adb9776e27fcd7a4d1172d0a2888b5dfcacfd
Tony-DongyiLuo/leetcode-python
/628-maximum_product_of_three_numbers.py
635
4.34375
4
#python3 ''' Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output: 6 Example 2: Input: [1,2,3,4] Output: 24 Note: The length of the given array will be in range [3,104] and all elements are in the range [-1000, 1000]. Multiplication of any...
true
de6b7223e19d00036745adac3cb4b280990cb1ee
Tony-DongyiLuo/leetcode-python
/258-add_digits.py
559
4.21875
4
#python3 ''' Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. Follow up: Could you do it without any loop/recursion in O(1) runtime? Hint: A naive impl...
true
407d13489bb9498c91475503eff230748e691bfb
kamrulhasan0101/learn_python
/set.py
607
4.46875
4
fruits = {"apple", "banana", "lemon", "orange", "mango"} # checking type of fruits variable print(type(fruits)) # checking item is in the set or not print("banana" in fruits) # printing whole set as a loop for x in fruits: print(x) # Adding new items into set fruits.add("added") print(fruits) # adding multiple item...
true
927751eb4c4f02070516b012d7efe0a02efed428
ifrost2/Homework-Projects
/hw5/rod.py
1,872
4.125
4
############################################################ #********************Rod Class***************************** ############################################################ """ Abstraction representing a single game rod. Disks are stored as integers (larger disks are larger integers). Disks are stored in list...
true
8ce4c0cb3b53d741477ab22c0c620d9e9a50dd42
anis-byanjankar/python-leetcode
/balanced-binary-tree.py
1,183
4.28125
4
# Given a binary tree, determine if it is height-balanced. # For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of # every node never differ by more than 1. # Definition for a binary tree node # class TreeNode: # def __init__(self, x): # se...
true
a17a34260ed8e3c6c82f9782c7ff7233fca7ae22
OperaPRiNCE/PRiNCE
/15155151.py
227
4.15625
4
def factorial(n): if n==0 or n==1: return 1 else: return n*factorial(n-1) num=int(input("Enter fast number=")) if num<0: print("Enter positive number") else: print("Result=",factorial(num))
true
573220bcbaaca37a160611a46177598e29b08449
arvin1384/Arvin
/Arvin_2/problem-input.py
332
4.21875
4
first_input = input("Enter your number") input_list = [] while(first_input): input_list.append(int(first_input)) first_input = input("Enter your number") total = 0 for number in input_list: total += number count = len(input_list) average = total/count print(f"Sum of my numbers: {total}") pr...
true
260f070e6e69baa2121a95fb8c371d2fb1313fad
EmmaTrann/Matrix-Multiplication
/matrix_mult.py
1,167
4.3125
4
import numpy as np def matrixmultiply(a, b, result): for i in range(len(a)): for j in range(len(b[0])): for k in range(len(b)): result[i][j] += a[i][k] * b[k][j] return result import time def main(): print("Please enter same number for ") row_a = int(input("Enter t...
true
164e57f9e7d411f809255cfe2fc42a2d60b828da
quodeabc/Demo
/act2.py
225
4.1875
4
"""Coding Activity 2: Integer Input from keyboard** Print 'Enter a Number' Take integer input from the keyboard and Store it in a variable num Print 'The number you entered is' and value in the container num Code Below """
true
6ac4ae87f6a381b27e1a6b372b6a62a32c79e3f2
agzsoftsi/holbertonschool-web_back_end
/0x05-personal_data/encrypt_password.py
1,084
4.21875
4
#!/usr/bin/env python3 ''' 5. Encrypting passwords 6. Check valid password ''' import bcrypt def hash_password(password: str) -> bytes: ''' Description: Implement a hash_password function that expects one string argument name password and returns a salted, hashed pa...
true
d15521f8c65a698063b84db552169060b23f6b4c
ergarrity/Markov-Chains
/markov.py
2,463
4.125
4
"""Generate Markov text from text files.""" from random import choice import sys file_name = sys.argv[1] words_list = [] def open_and_read_file(file_path): """Take file path as string; return text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text....
true
169bd2b60ef17ab4731797bde107d712035a0b2f
sharlenechen0113/sc-projects
/stanCode Projects/boggle_game_solver/largest_digit.py
1,480
4.71875
5
""" File: largest_digit.py Name: Sharlene Chen ---------------------------------- This file recursively prints the biggest digit in 5 different integers, 12345, 281, 6, -111, -9453 If your implementation is correct, you should see 5, 8, 6, 1, 9 on Console. """ def main(): print(find_largest_digit(12345)) # 5 p...
true
bbf7f1dce30c150127d1b1f129f4fb7e92c27e03
Spacha/SuperClient
/doc/assignment/template.py
2,137
4.125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # The modules required import sys import socket ''' This is a template that can be used in order to get started. It takes 3 commandline arguments and calls function send_and_receive_tcp. in haapa7 you can execute this file with the command: python3 CourseWorkTemplate.py <i...
true
140369335313ecaf6f7afd16dd14d63d4cb7e084
gvu0110/learningPython
/learning_python/1.python_basics/functions.py
762
4.25
4
# # Example file for working with functions # # Define a basic function def function1(): print("I am a function") function1() print(function1()) # Function that takes arguments def function2(arg1, arg2): print(arg1, " and ", arg2) function2(10, 20) print(function2(10, 20)) # Function that returns a value d...
true
fe5bf71f371b6570303e0136d40b315dfa64afa5
gvu0110/learningPython
/python_essential_training/6.loops/while.py
464
4.125
4
#!/usr/bin/env python3 secret = 'admin' password = '' auth = False count = 0 max_attemp = 5 while password != secret: count += 1 if count == 3: continue if count > max_attemp: break password = input(f"{count}: What's the secret word? ") else: # not "else" statement. This "else" exec...
true
9e4845039d9c0424c8d60419abfc8c09f1292d2f
Amartya-Srivastav/Python-Basic-programs
/BasicProgram/Factorial.py
259
4.1875
4
num1 = int(input("Enter First Number = ")) fact = 1 if num1 == 0: print("Enter Positive value") elif num1 == 1: print("Factorial of 1 is 0") else: for i in range(1, num1+1): fact = fact * i print("The Factorial of", num1, "is", fact)
true
7d99b5e1d976ce9b8152be08c29bc5675b23b66d
Amartya-Srivastav/Python-Basic-programs
/String_Program/adding_something_at_end.py
435
4.5625
5
# Write a Python program to add 'ing' at the end of a given string (length should be at least 3). # If the given string already ends with 'ing' then add 'ly' instead. # If the string length of the given string is less than 3, leave it unchanged string = input("Enter String = ") length = len(string) if length > 2: ...
true
1a3372ce63e3e5a6a9e4b339fec73dd4060a29b6
RMWarner9/CIS-1101
/RachelWarnerCopyFile.py
665
4.4375
4
""" Rachel Warner November 27th, 2020 Program Name: Copy File Program Purpose: Write a script that will ask the user for two txt files. The script will then take the input from one txt file and output it to the other as a copy. Inputs: file name Outputs: A copy of the file """ # Open a file for txt input ...
true
a13824dea243b4d3939f8b578492bc690752a9c1
mannygomez19/tic-tac-toe-C
/car_dealer.py
2,054
4.34375
4
car = {'honda':4000, 'toyota':3000, 'ford': 2000, 'acura': 7000} print car class account: def __init__(self, balance=0): self.balance = balance def withdraw(self, amount): self.balance -= amount my_account = account(3500)# Object called my_account is = to the class called account where p...
true
efb985141e6acbdccb59ea18d9c192afc6ca8ab1
ozthegnp/ozthegnp
/1 - python/areaCalculator.py
884
4.40625
4
#This program is intended to calculate the area of circle or triangle. #The shape and dimensions are defined by the input of a user from bash print """ Welcome to Area calculator This program will calculate the area of a shape of your choice. """ option = raw_input('Enter C for Circle or T for Triangle: ') option = ...
true
bd572b4b916cf6449a18a41b7ac7cbefa163e2b8
harinjoshi/MyPythonPrograms
/PythonPrograms/firstandlast.py
249
4.1875
4
#program to exchange first and last character of string def firstlast(string): print(string [-1:]) print(string [1:-1]) print(string [:1]) return string [-1:] + string [1:-1] + string [:1] string = input() print(firstlast(string))
true
45b4b135be7b050f402ad2604c7d000a5f1d0a79
rachel619/paths-to-cs-public
/m4/enumerate.py
400
4.15625
4
foods = ['peaches', 'apples', 'grapes'] def print_foods1(): index = 0 for food in foods: print str(index) + ": " + food index = index + 1 def print_foods2(): index = 0 for food in foods: print str(index) + ": " + food index += 1 def print_foods3(): for index, fo...
true
143281c06e46bb4f1e4bff644974a1959b9ab1b9
mmononen/Director-Ranking-Tool
/directors.py
2,207
4.21875
4
# Director Ranking Tool # by Mikko Mononen # Analyzes ratings.csv exported from IMDb.com and prints out the list of user's favorite movie directors. # Usage: python directors.py >output.csv # Import output.csv in Excel or equivalent and sort by weighted rating import csv # opens a csv file and returns it as a list ...
true
d37eadd05db0f1beff6bd10f26d480b6e291b7f8
dattnguyen/Intro-to-Python
/Python for everyone/def_compute_pay.py
656
4.125
4
while True: try : hours = float ( input ('please enter hours:')) rate = float ( input ('please enter rate:')) except ValueError : print ('please enter a number') continue if hours < 0: print ('please enter hours as a positive number') if ...
true
fb731bcf25c227996390b25bad857ba5c8b357e0
SDasman/Python_Learning
/GamesNChallenges/Factorial.py
709
4.25
4
import time def factorial_iterative(n): f = 1 while n>0: f = f * n n -= 1 return f #Factorial here is done iteratively. #To do this recursively def factorial_recursive(n): if n < 2: return 1 return n * factorial_recursive(n-1) times = 10000 factorial_value = 900 before_ti...
true
4c4d46462b0a3654b2aea5375f3c3923be2a967b
SDasman/Python_Learning
/GamesNChallenges/Calculator.py
973
4.34375
4
x = int(input('Please enter x: ')) y = int(input('Please enter y: ')) operator = input('Do you want to add(+), subtract(-), multiply(*), or divide(/)?: ') add = lambda x, y: x+y subtract = lambda x, y: x - y multiply = lambda x, y: x * y divide = lambda x, y: x / y # Now that we have defined our relative functions...
true
7e43d4a09d5940f161e7176476bbccad73a42a6f
mohitsaroha03/The-Py-Algorithms
/src/3.9Stringalgorithms/number-subsequences-form-ai-bj-ck.py
1,860
4.375
4
# Link: https://www.geeksforgeeks.org/number-subsequences-form-ai-bj-ck/ # IsDone: 0 # Python 3 program to count # subsequences of the form # a ^ i b ^ j c ^ k # Returns count of subsequences # of the form a ^ i b ^ j c ^ k def countSubsequences(s): # Initialize counts of different # subsequences caused by d...
true
ca250e5e65cc9c3368011afd6360b84659057fc1
mohitsaroha03/The-Py-Algorithms
/src/3.1Array/check for pair in A[] with sum as x.py
597
4.15625
4
# Link: https://www.geeksforgeeks.org/given-an-array-a-and-a-number-x-check-for-pair-in-a-with-sum-as-x/ # Python program to find if there are # two elements wtih given sum # function to check for the given sum # in the array def printPairs(arr, arr_size, sum): # Create an empty hash set s = set() for i ...
true
98cf403c752a89276c8d0ba58d3c0a52b8459bfa
mohitsaroha03/The-Py-Algorithms
/src/5.2Graphs/CountConnectedComponentsWithDFS.py
1,323
4.34375
4
# Link: https://www.geeksforgeeks.org/connected-components-in-an-undirected-graph/ # IsDone: 0 # Python program to print connected # components in an undirected graph class Graph: # init function to declare class variables def __init__(self, V): self.V = V self.adj = [[] for i in range(V)] def DFSUtil(self, ...
true
5305b5d0f62fdcffc1e747ff6202428e8b81497f
mohitsaroha03/The-Py-Algorithms
/src/3.9Stringalgorithms/zig-zag-string-form-in-n-rows.py
1,151
4.5625
5
# Link: https://www.geeksforgeeks.org/print-concatenation-of-zig-zag-string-form-in-n-rows/ # IsDone: 0 # Python 3 program to print # string obtained by # concatenation of different # rows of Zig-Zag fashion # Prints concatenation of all # rows of str's Zig-Zag fasion def printZigZagConcat(str, n): # Corner ...
true
e551b4f06f2eb3cf46cad940ea0100f7ede6ac43
mohitsaroha03/The-Py-Algorithms
/src/3.4Stacks/prefix-postfix-conversion.py
674
4.1875
4
# Link: https://www.geeksforgeeks.org/prefix-postfix-conversion/ # IsDone: 0 # Write Python3 code here # -*- coding: utf-8 -*- # Example Input s = "*-A/BC-/AKL" # Stack for storing operands stack = [] operators = set(['+', '-', '*', '/', '^']) # Reversing the order s = s[::-1] # iterating through indiv...
true