blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
45b478964a6b1eed948b37b0cd865d6e1274efd6
YLTsai0609/algorithm
/yulong/linear_search.py
494
4.15625
4
''' most stupid way and best start way! Time Complexity : O(N) Space Complexity : O(1) ''' def linear_search(value_you_want: float, input_list: list) -> int: for idx, element in enumerate(input_list): if element == value_you_want: return idx return -1 if __name__ == "__main__": inp...
true
2287a8df1d7b42a52ca6a6107cb43e6989eb2c07
OlhaVolynets/OlhaVolynets_Python
/homework/classwork0705.py
2,808
4.15625
4
# -------------------------1---------------------- # def arithmetic_mean(first, *args): # """This function calculates the arithmetic mean""" # for arith in args: # return first + sum(args) / (1 + len(args)) # # print(arithmetic_mean(4, 40, 12, 25)) # print(arithmetic_mean.__doc__) # -------------------...
true
c9b57773a70a39150b2919e4ab054e6079985e86
mjmacarty/CS230-SU2021
/program_files/0714_reaction.py
936
4.25
4
# reaction time tester """ Improvements added: 1. Add randomness to prompt 2. Use time and sleep 3. give the user 5 tries 4. display reaction time with 3 decimals 5. after fifth try display average time """ from time import time, sleep from random import random print("Welcome to the reaction time tester!") print("You...
true
d462d951d443fd138efaea2eb4148e16de2d376b
OshadaAdithya/git-test
/new.py
308
4.25
4
print("Hello Sri Lanka") the_text=input("Enter some text.\n") #print-version1 print('This is what you entered:') print(the_text) #print-version print('This is what you entered:',the_text) #print-version3- to supress printing of a new line,use end='' print('This is what you entered:',end='') print(the_text)
true
5be748493c07626efb56a1cb09c7a9ac96c23fbe
BladeF/Python-Fundamentals
/lesson-12/functions-example.py
314
4.21875
4
def add_two_numbers(leftSide, rightSide): result = leftSide + rightSide return result for i in range(1): num1 = int(input("Please enter a number: ")) num2 = int(input("Please enter another number: ")) answer = add_two_numbers(num1, num2) print("The result of your math is: ", answer)
true
abc7a25cce2b500bf27fbe54a34900dc8a06211a
SwappyTheBeast/Garg
/FIBONACCI SERIES.py
366
4.21875
4
r=1 while r==1: print(""" Welcome to another program by swapnil garg, This program will display the first few numbers of the Fibonacci series""") a,b=0,1 n=int(input("How many numbers do you wish to see?")) x=0 while x<n: print(a) a,b=b,a+b x=x+1 r=int(input("...
true
3fcd27a9e5ec5a184ced38d19fa28a4be44d18f2
rajaramesh226/goodname
/pelo programing/new1.py
302
4.28125
4
num = int(input("Enter a number: ")) fact= 1 if num < 0: print("Sorry, factorial does not exist for negative numbers") elif num == 0: print("The factorial of 0 = 1") else: for i in range(1,num + 1): fact = fact*i print("The factorial of",num,"is",fact)
true
03621b53ac09c39c6652a24a0b0118c6875a2e8f
ChenhaoJiang/LeetCode-Solution
/101-150/116_populating_next_right_pointers_in_each_node.py
2,455
4.125
4
""" You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right node. If there is no next right nod...
true
5e9ecef663a8a33a7fd5ddde07b905182e7504a6
ChenhaoJiang/LeetCode-Solution
/51-100/55_jump_game.py
1,458
4.1875
4
""" Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. Example 1: Input: nums = [2,3,1,1,4] Output: true Explanation: Jump 1 step from in...
true
9837b324511fe269478ac24a46feb5de2cae10ba
Vishad89/heyjude
/Python/interview_questions/majority_element.py
431
4.25
4
""" Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exist in the array. Example 1: Input: [3,2,3] Output: 3 Example 2: Input: [2,2,1,1,1,2,2] Output: 2 """ def ...
true
20e77a37d3b06e99473aea817f6e1f8f17d4691e
Vishad89/heyjude
/Python/interview_questions/two pointers/reverse_words_in_sentence.py
597
4.625
5
#!/usr/bin/python """ Reverse the order of words in a given sentence (an array of characters) example: The "Hello World" string reversed should be "World Hello". """ import re def reverse_words1(str): words = re.findall('\w+|[! : , . ? ` ~ " ]', str) special_char = '!:,.?`~"' i = 0 j = len(words) - 1 ...
true
dff9eeb11479454c566406ed654c6405ebd7e4a4
Vishad89/heyjude
/Python/interview_questions/two pointers/reverse_words_in_sentence2.py
1,294
4.28125
4
""" Reverse the order of words in a given sentence (an array of characters) example: The "Hello World" string reversed should be "World Hello". In This approach, I am trying to reverse the string completely (including punctuations) first and then reverse them back word by word. """ import re import sys def str_rev...
true
20cc59e64bc68fc547a6109bfb5d430320e1d55f
Vishad89/heyjude
/Python/interview_questions/sliding window/max_product_subarray.py
1,042
4.3125
4
#!/usr/bin/python3 """ Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: Input: [2,3,-2,4] Output: 6 Explanation: [2,3] has the largest product 6. Example 2: Input: [-2,0,-1] Output: 0 Explanation: The result cannot ...
true
b7707459ab13c769c4ec7c7a8f10d992f9c93c03
luizaes/machine-learning
/Neural Networks/Logic Operations/main.py
1,102
4.15625
4
''' Python implementation of a simple 2 layer Neural Network that given an input [x, y, z] where x, y and z are either 0 or 1 outputs the result of the corresponding logic operation especified on Y. X Y |0, 0, 0| | 0 | |0, 1, 0| | 0 | |1, 0, 0| = | 0 | (AND) |1, 1, 1| | 1 | ...
true
23d15865bf4a4a1e7fc1333c780d4cb80a2dd5e7
carloswm85/2020-cs241-survey-OOP-and-data-structures
/CS241 w11/prove11.py
1,462
4.34375
4
""" Purpose: This file is a starting point to help you practice list comprehensions. """ def get_part1_list(): """ Returns a list of the squares of the numbers [0-99], e.g., 0, 1, 4, 9, 16, 25 ...] """ # TODO: Change this line to be a list comprehension numbers = list_1 = [n ** 2 for n in range(10...
true
d391934633bc88e0df5109277a7f96a5eb94d0b0
carloswm85/2020-cs241-survey-OOP-and-data-structures
/CS241 w06/ta06_solution.py
1,132
4.34375
4
""" File: ta06-solution.py Author: Br. Burton This program demonstrates inheritance to define a circle that inherits from a point. """ class Point: """ A Point has an x and y coordinate. """ def __init__(self): self.x = 0 self.y = 0 def prompt_for_point(self): self.x = flo...
true
72e0e2e16a3300061e212c053113252d124cb35b
carloswm85/2020-cs241-survey-OOP-and-data-structures
/CS241 w10/check10/check10a.py
1,447
4.375
4
""" File: sorting.py Original Author: Br. Burton, designed to be completed by others. Sorts a list of numbers. """ def sort(numbers): """ Fill in this method to sort the list of numbers # BUBBLE SORT METHOD """ for number_pass in range(len(numbers) - 1, 0, -1): # start: 9 - 1 = 8 ...
true
6e656ee9c19d1cc1d0595945e4a2fc05f42f1f5f
carloswm85/2020-cs241-survey-OOP-and-data-structures
/CS241 w10/prove10.py
1,728
4.3125
4
numbers = [12, 18, 128, 48, 2348, 21, 18, 3, 2, 42, 96, 11, 42, 12, 18] print(numbers) # Insert the number 5 to the beginning of the list. numbers.insert(0, 5) print(numbers) # Remove the number 2348 based on its value (as opposed to a hard-coded index of 4) from the list. numbers.remove(2348) print(numbers) # Creat...
true
c839c5b90635140bada4c9a2101ddcd2b1a626ab
osayi/python_intro
/inputs/restaurant_seat.py
289
4.28125
4
#restaurant seating, ideal for less than 5 people group = input("How many people would you like to seat?: ") group = int(group) if group >= 5: print("I'm sorry but we'll need a moment to find a table large enough for your group.") else: print("Great, follow me down to your table.")
true
008d8ac8f8bb5ff3087fe77fbeb0dc0ac62cc81b
prabhuyellina/Assignments_Python
/assignments/Avarage_word_length.py
460
4.28125
4
''' Write a program that will calculate the average word length of a text stored in a file (i.e the sum of all the lengths of the word tokens in the text, divided by the number of word tokens)''' fp=open('test.txt','r') word_count=1 char_count=0 for line in fp.readlines(): char_count+=len(line) for data in lin...
true
1bd67be4132551e99506f114b2d0b91a06c489fd
kelsi2/cloud_native_devops_bootcamp
/Week2_Scripting/Python/s3bucket.py
2,224
4.28125
4
"""Create an S3 bucket in a specified region ​ If a region is not specified, the bucket is created in the S3 default region (us-east-1). ​ :param bucket_name: Bucket to create :param region: String region to create bucket in, e.g., 'us-west-2' :print: Prints the bucket name that was created """ ...
true
5e82aef87d881cd3d51fc6338376a67fab042d6e
CardiffMathematicsCodeClub/elbow
/elbow/games/game.py
2,546
4.40625
4
"""Base class for a game""" import shlex class Game(object): """ Base class for a game from which other games inherit. Inheriting games must override the following attributes/methods: Attributes: - answer: The player must enter this to "win" - prompt: This will be displayed to the playe...
true
95d51aee1cb3522df8035c3d8269d40f5378e9f8
frosty1112/STM
/8.4.py
251
4.15625
4
fname = input("Enter file name: ") #open file in read mode file = open(fname,"r") #read 1st line line=file.readline() #read line by line and print in upper case while line: print(line.upper()) line = file.readline() file.close()
true
ec3fc378c2ca19fcc5ebfbb0e8d46612bb17af54
silvioedu/TechSeries-Daily-Interview
/day06/Solution.py
1,134
4.3125
4
class ListNode(object): def __init__(self, x): self.val = x self.next = None # Function to print the list def printList(self): node = self output = '' while node is not None: output += str(node.val) output += " " node =...
true
6774a798bb6bfd967b084581f2400768aed2e2ee
puneet4840/Numpy
/Creating numpy array using array fn.py
387
4.15625
4
# Array() function to create numpy array. from numpy import array ## 0-D array. a1=array(100) print(a1) ## 1-D array # using list in array function. a2=array([1,2,3,4,5]) print(a2) # using tuple in array function. a3=array((1,2,3,4,5)) print(a3) ## 2-D array a4=array([[1,2,3],[4,5,6]]) print(a4) ## 3-D array...
true
2773a2370739813438bcf5b2622561737085be6f
foorenxiang/notes
/Python Design Patterns/Ch02/02_02/factory_final.py
876
4.4375
4
class Dog: """A simple dog class""" def __init__(self, name): self._name = name def speak(self): return "Woof!" class Cat: """A simple dog class""" def __init__(self, name): self._name = name def speak(self): return "Meow!" def get_pet(pet="dog"): "...
true
7f31808cd611b111465dc2c514df8a1795a82ef7
dylv/CP1404Practicals
/prac_02/vowels.py
296
4.21875
4
def get_vowels(string): count = 0 for letter in string: if letter.islower() in "aeiou": count += 1 return count user_word = str(input("Enter word: ")) num_vowels = get_vowels(user_word) print("The number of vowels in your word is {}".format(num_vowels))
true
9b589cbd4f84ea580f7d53295d93910fa2c1fdd6
McKenzieGary/LearningPython
/learning-python-the-hard-way/ex22.py
1,574
4.1875
4
print() # this prints a string print(f"") # this prints formatted variables in a string '' # contains a string "" # contains a string """""" # three quotes allows you to write strings that take up multiple lines * # this multiplies # #this comments things out - # this subtracts / #this divides % #this is modul...
true
324dbdc1e80ccfcbed95cb37234ee4227d51ede4
McKenzieGary/LearningPython
/learning-python-the-hard-way/ex19.py
2,134
4.40625
4
amount_of_cheese = 10 # this sets the parameter of cheeses to 10 amount_of_crackers = 50 # this sets the parameter of crackers to 50 def cheese_and_crackers(cheese_count, boxes_of_crackers):#this defines the function cheese_and_crackers and sets the parameters to cheese_count and boxes_of_crackers print(f"You ...
true
4f732bb0a16104e1cf7858c0dd44aebb1c05ad21
bithu30/myRepo
/python_snippets/courseware-btb/solutions/py3/oop/properties_extra.py
2,151
4.40625
4
''' Ohm's law is a simple equation describing electrical circuits. It states that the voltage V through a resistor is equal to the current (I) times the resistance: V = I * R The units of these are volts, ampheres (or "amps"), and ohms, respectively. In real circuits, often R is actually measured in kiloohms (10**3 o...
true
e7ab7ee1205f69cac0ea803bbbaf689090b80728
brittCommit/code_challenges
/contains_dup.py
693
4.25
4
def containsDuplicate(nums): """ Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. >>> containsDuplicate([1,1,1,3,3,4,3,2,4,2]) True ...
true
db14b70b9bc10884e0966f382397e5bdfad6f619
brittCommit/code_challenges
/three_cons_odds.py
575
4.3125
4
def threeConsecutiveOdds(arr): """ Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false. >>> threeConsecutiveOdds([1,2,34,3,4,5,7,23,12]) True >>> threeConsecutiveOdds([2,6,4,1]) False """ for i in range(l...
true
22504ce2745a8afd5aac7d0b755c567f36c1d9ca
brittCommit/code_challenges
/add_digits.py
383
4.25
4
def addDigits(num): """ Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. >>> addDigits(38) 2 """ while num > 9: num = sum([int(x) for x in str(num)]) return num if __name__ == '__main__': import doctest if doctest.te...
true
00780893611a05952661fb3602f064ae86e5d329
brittCommit/code_challenges
/distance_val.py
752
4.40625
4
def findTheDistanceValue(arr1, arr2, d): """ Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays. The distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d. >>> fi...
true
9bf606b2f7176ace24a5e20dd8fdb3911004aead
lsiepman/BeginnerProjectSolutions
/menu_calculator.py
2,867
4.53125
5
# -*- coding: utf-8 -*- """ Created on Sun Mar 8 21:00:13 2020. Menu Calculator @author: laura Goals: - To quickly take orders, your program should allow the user to type in a string of numbers and then it should calculate the cost of the order. - Also, make sure that the program loops so the user ...
true
296e034224e5cd91993a34a963d98b1bc6437ecf
rubend824/ny
/foobar/classes/foobar.py
2,029
4.46875
4
""" Classes for the FooBar exercise """ class Multiple: """ This is a class that determines whether a number is a multiple of another or not """ @staticmethod def is_multiple(number: int, multiple: int): """ Determines whether a number is multiple of another or n...
true
cc37cc7ed4aca77fa67a2313f9df438756f2be89
TheMoonMoth/Learn-Python-The-Hard-Way
/ex7.py
591
4.15625
4
print "Mary had a little lamb." print "Its fleece was white as %s." % 'snow' print "And everywhere that Mary %s." % 'went' print "." * 10 #what does this do?! end1 = "C" end2 = "h" end3 = "e" end4 = "e" end5 = "s" end6 = "e" end7 = "B" end8 = "u" end9 = "r" end10 = "g" end11 = "e" end12 = "r" #watch...
true
fd74d2d3b95e98f8334b17a2898c38d78660683b
ocornel/Andela
/reverse_string.py
504
4.375
4
def reverse_string(string): reverse = [] #this empty list will hold the reverse of the string i = len(string) while i > 0: reverse.append(string[i - 1]) #Adds the last letter in string to the recent position of reverse i -= 1 #shifts the pointer if string == ...
true
2179f124d17b6d0b7507d0c61111a3f069c2fed6
MarcinGruchala/E-media-png-decoder
/prime_number.py
1,640
4.46875
4
''' File with PrimeNumber class. ''' import random class PrimeNumber: ''' Class generates prime numbers and checks if the number is a prime number. ''' @staticmethod def generate(number_size_in_bits): ''' Method generates a prime number within given bits length. For better p...
true
d9560515f3f35c09c326ab4ebac31723937d5d5b
nikitapotdar/Nested_if_else
/DelCharges.py
1,402
4.1875
4
#program to display delivery charges #problem statement below '''An agency provides parcel services to two countries A and B and charges are according to the weight of the parcel. For Country A – charges are for weight <= 10 then $5, weight > 10 and <= 30 then $ 10 and ...
true
d21585bd5e77fecbbba491d2c8c3f7e294aad3e7
walter2645-cmis/walter2645-cmis-cs2
/program.py
791
4.1875
4
import math def circlecircumference(): radius = int(raw_input("How many units long is the radius?\n")) unit = raw_input("What is the unit of measurment?\n") return "The measurement of the circumference of the circle is " + str(2 * math.pi * radius) + unit + "(s)." def hypotenuseofrighttriangle(): x = in...
true
c043b1111ec04250c91bf8ceded655625ddfb3b4
walter2645-cmis/walter2645-cmis-cs2
/recursive.py
2,115
4.15625
4
def countdown(n): if n <= 0: print "Blastoff!" #Lines 2 and 3 are called the "Base Case" #The other cases where it calls itself is called the "Recursive Case" else: print n countdown(n-1) def countup(n): if n >= 10: print "BOOM!" else: print n countup(n+1...
true
bead66d45b19e235dad189783c38a8a81766d3e0
cogranpm/python_scripts
/inputandoutput.py
2,570
4.125
4
""" input and output """ import math import json print("fancier output formatting") print("formatted literal strings: f'text text {variable} {variable}'") year = 1999 month = "November" print(f"The year was {year} and the month was {month}") myformattedstring = F"The year was {year} and the month was {month}" print(my...
true
9168b760010e87117f1941b9d59d50789a91d11e
aupaprunia/python_problems
/compare_str.py
976
4.15625
4
# stirng a and b contain many strings seperated by , # print no. of words in which frequency of smalled alphabet in string b is greater than # string a # # Example: # string a: abcd,aa,bd # string b: aaa,aa # # output: [3,2] # Explanation: all 3 words in string a have less frequency of their smallest alphabet ...
true
083fb7eea96df2685fa1f479aba29a169a55fa29
namntran/2021_python_principles
/13_digits.py
211
4.21875
4
# digits.py # Print the number of characters in the string that are decimal digits n = 0 str = input("Enter a string: ") for char in str: if '0' <= char <= '9': n += 1 print("Number of digits: ", n)
true
6f919639a2ad8bc48a5101a7d0d55fe4d4f968fd
namntran/2021_python_principles
/workshops/4_busWhileLoop.py
1,047
4.34375
4
#program to calculate passenger and cost to hire bus import math num_teams = int(input('Enter number of teams: ')) passengers = num_teams*15 num_small = int(math.ceil(passengers/10)) #number of small buses # math.ceil(x) returns the smallest integer not less than x. num_large = 0 min_num_small = num_small # to keep t...
true
46019a46a981826d9a0b0bd5a5ab0ff3dcda44a2
auralshin/competetive-code-hacktoberfest
/Arrays/games.0.3.1.py
2,903
4.21875
4
print("Enter the Your name ") player1 = input() print('Press 1 to play rock-paper-scissor or press 2 to play guessing game') x = int(input()) if x == 2: random_number = random.randint(1, 20) guess = None number_try = 1 while True: guess = int(input("Pick a number from 1 to 20: ")) if g...
true
b3e19954038414c4495e862e9c66ddb54d37bfe0
venkatalolla/python-projects
/practice-python/odd-or-even.py
485
4.25
4
# Practice 2 while True: try: user_input = int(input("Enter a number:")) except ValueError: print("Oops! That is not valid number. Enter again") continue break if user_input % 2 == 0 and user_input % 4 == 0: print("The number {0} is even and a multiple of 4".format(user_input))...
true
cde503285c90e608cd2b329a8e8aaf621445385c
kwm94/PythonP
/Practical 1/Practical 1(complete)/Practical 1/kitwm_p01q05.py
293
4.34375
4
# Filename : upper_to_lower # Name : Kit Wei Min # Description : Converts uppercase letter(s) to a lowercase letter(s) # Prompts for uppercase letters letter = input("Type in an uppercase letter(s): ") # Displays it in lowercase print("") print("Displayed in lowercase:") print(letter.lower())
true
fce064d548b920210a00e238263a5b5516101ca8
chaor/py3
/char_image.py
1,632
4.40625
4
""" This scripts convert a color image into a gray image, then replaces each pixel with an ASCII character based on its gray-scale value. In this way, you can see the picture in your text editor or terminal :) Usage: python char_image.py path/to/image_file If the image size is large, zoom out to see the effect! """ i...
true
3e784460c22656bb79ed2ab01ab203e1a2fafef7
ujalapraveen/If_else
/max_between two n0.py
207
4.3125
4
# Write a python program to find maximum between two numbers. num1=int(input("enter a num1 =")) num2=int(input("enter a num2 =")) if num1>num2: print("num1 is maximum =") else: print("nothing =")
true
f331307fae1feffb6ab2e5afb56c2491a9a7061f
ujalapraveen/If_else
/upper_lower.py
244
4.375
4
# Write a python program to check whether a character is uppercase or lowercase alphabet. ch=input("enter a character") if ch>="A" and ch<="Z": print("uppercase") elif ch>="a" and ch<="z": print("lowecase") else: print("digit")
true
34970b8470b12faeb97728a113eba79394874e52
ujalapraveen/If_else
/month.py
430
4.375
4
# Write a python program to input the month number and print the number of days in that month. month=int(input("enter a month number between 1-12: ")) if month==2: print("no of days: 28,29 days") elif month==1 or month==3 or month==5 or month==7 or month==8 or month==11 or month==12: print("No of days : 31...
true
083c20d2a7d0932c36789250554114f3ca8ae0b5
ujalapraveen/If_else
/triangle_valid .py
360
4.40625
4
# Write a python program to input angles of a triangle and check whether triangle is valid or not. first_angle=int(input("enter a first_angle =")) second_angle=int(input("enter a second_angle =")) third_angle=int(input("enter a third_angle =")) sum=first_angle+second_angle+third_angle if sum==180: print("it i...
true
4ffaf5137efa76400a2b4ce065a2f4938a3c1a50
jmjfisher/python-tasks
/Python_Intro/task_1_comments.py
1,037
4.5625
5
# This program calculates the area of a triangle. # Once this script is executed it will display the first string of text followed by a blank line for spacing print "This program finds the area of a triangle." print # this will prompt the user to enter a value for both height and base of the triangle for which they...
true
ec8b64f5e62b73dda052596d49be336a08235251
sychoo/CS-125
/cs125/proj/summer/summer.py
688
4.125
4
# File: summer.py # Author: Simon Chu # Date: 2/8/17 # Purpose: Add up the first n natural numbers. def main(): print() print("Program to add up the first") print("n natural numbers.") print("Written by Simon Chu.") print() value = int(input("Enter a value for n: ")) print() # for turn...
true
2c66cf285e1f8899bc1654302aa84db5baeae1db
lpgaleano/lab-07-conditionals
/reminders02.py
750
4.40625
4
import datetime #user.time = float(input("what hour is it? (0-23)")) now = datetime.datetime.now() print(now.year, now.month, now.day, now.hour, now.minute, now.second) if now.hour <= 5: print("its early you should be sleeping!") elif now.hour <= 7: print("wake up, make coffe, run a mile and get bfest") eli...
true
51a37545beb14d0a8521913c39ad4ffc90002e79
saranshusa/Code-In-Place-Stanford-University
/Assignment 3 Images/Q4 (optional; hard) Warhol Effect/warhol_filter.py
1,503
4.5
4
""" This program generates the Warhol effect based on the original image. """ from simpleimage import SimpleImage N_ROWS = 2 N_COLS = 3 PATCH_SIZE = 222 WIDTH = N_COLS * PATCH_SIZE HEIGHT = N_ROWS * PATCH_SIZE PATCH_NAME = 'images/simba-sq.jpg' def make_recolored_patch(red_scale, green_scale, blue_scale): ''' ...
true
b23c9f35a575fe84c6c33dde90238157195b8bc9
imndaiga/github_workflow_seminar
/multiply.py
579
4.65625
5
def multiply(float1, float2): """ This function performs a multiplication between their two argument. Parameters ---------- float1: float number that will be the left part of the multiplication float2: float number that will be the right part of the multiplication Returns ----...
true
8fa25e2f3ffd2829be22fbb1775319b8570fc88c
madelinecodes/beginner-projects
/rockpaperscissorsgame/rockpaperscissors.py
1,245
4.125
4
import random playing = True score = {'human': 0, 'comp': 0} def get_score(score): return 'Human: {human} - Computer: {comp}'.format(human=score['human'], comp=score['comp']) while playing: roll = input("Type Rock, Paper, Scissors or Q to stop playing: ").capitalize() rnd = random.randint(0, 2) m...
true
320dc3912f1f977a7bd8b1848b362bc433504664
green-fox-academy/tamaskamaras
/1_fundation/week-03/day-03/08position_square.py
450
4.28125
4
# create a square drawing function that takes 2 parameters: # the x and y coordinates of the square's top left corner # and draws a 50x50 square from that point. # draw 3 squares with that function. from tkinter import * my_root = Tk() my_canvas = Canvas(my_root, width = '300', height = '300') my_canvas.pack() def ...
true
fd18eb95f40d61be7c8f12669ecff7fed881df45
green-fox-academy/tamaskamaras
/1_fundation/week-03/day-03/01line_in_the_middle.py
364
4.21875
4
# draw a red horizontal line to the canvas' middle. # draw a green vertical line to the canvas' middle. from tkinter import * basic = Tk() my_canvas = Canvas(basic, width = "300", height = "300") my_canvas.pack() my_line = my_canvas.create_line(0, 150, 300, 150, fill = "red") my_line2 = my_canvas.create_line(150, 0,...
true
5eea82e3e737ca6a8b9d8b508ed7cb13cc8de8d1
XiangLei5833/Python-
/practise5-7.py
683
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 计算面积和体积 from math import pi def square(length): area = length ** 2 return 'The area of square %d' % area def cube(length): volume = length ** 3 return 'The volumn of cube %d' % volumn def circle(radius): area = pi * redius**2 return 'The area ...
true
268340983e189f902a1b9d30b8ea1a12c5d5f323
ArtemEfimov/Checkio
/escher/Compass_Map_and_Spyglass.py
2,011
4.4375
4
""" Your task is to count the sum of the number of steps required to pick up all 3 items - ('C' - compass), ('M' - map), ('S' - spyglass) from your starting position. So the result will be the sum of distance from Y to C, from Y to M and from Y to S (not Y-C-M-S). Note that you can walk in 8 directions - left, right, u...
true
a5b6b3726b9ae95c93e22bb0dba74468b14eabb6
jesprna/python
/decision-making/nested-if.py
367
4.125
4
x = 4 y =4 z = 2 if(x == y & x > z): a = 3 b= 3 if(a == b): print("x and y are equal and x is greater than z and a is equal to b ") else: print("x and y are equal and x is greater than z and a is not equal to b ") elif(x > y): print("x is greater than y") elif(x > z): print(...
true
9f96ae063f65729e3ed7006d26c7154162d24ff2
dharmakannan/Python
/Ex61_Rotated_String.py
629
4.28125
4
#!C:\Python27\python def RotatedString(first_str,validate_str): if len(first_str)!=len(validate_str): return False return validate_str in first_str+first_str def main(): first_str=input("Enter the first string\n") validate_str=input("Enter the second string to check whether its a Rotated String of...
true
152a73b3d12f06e6ac2a914080e49f282c57bc6c
maulikb-emipro/Python-Training
/product.py
2,433
4.3125
4
class product: "It manages inventory of product" quantity = 0 product_name = '' def __init__(self, name="Wood", quantity=quantity): """ func :- Constructure for initializing Product name & quantity. param :- name - string. param :- quantity - it must be an integer. ...
true
70adca66cf3fa01d087a1e501456b9622affdbe8
Ifeadewumi/User-Registration-in-Python
/User Validation.py
1,531
4.125
4
from random import choice from string import ascii_letters print("Welcome to XXX User Registration Portal! Please enter the following details to set up your account.") firstName = input("Please enter your first name: ") lastName = input("Please enter your last name: ") emailId = input("Please enter your email ...
true
0702d1831aa449a0f554f234b91cf0f1e792214b
yse33/exam_01_22
/search_text.py
455
4.125
4
def search_and_replace_text(search_sentence, text): if len(search_sentence) < 2: return "You have to enter 2 or more words in order to search!" elif " ".join(search_sentence) not in text: return "The words you have put in are not found anywhere in the text!" else: search_sente...
true
b22cd150761ee2f398b46d92d63e089b0d4041b8
CSJosh/PythonPractice
/wk1/hw1/loops.py
998
4.125
4
#Exercise 1.8 #1 for x in range(2, 11): print "1/" + str(x) + " ==> " + str(1/float(x)) #2 num = raw_input("Enter a number to count down from: ") num = int(num) while(num > -1): print "Count Down ==>", num num -= 1 #3 print "\nExponent calculation time ==> base^exponent" base = raw_input("Enter the base-->") ...
true
461a70ef9b8f18b6e7b7969246fa78662687a75f
Abhrojit16/python-is-easy
/Simple_Loop.py
1,541
4.625
5
""" You're about to do an assignment called "Fizz Buzz", which is one of the classic programming challenges. It is a favorite for interviewers, and a shocking number of job-applicants can't get it right. But you won't be one of those people. Here are the rules for the assignment (as specified by Imran Gory): Write a p...
true
23ee78d1edcd565bccfb23c6f80bd44938603518
asharkhan1996/Assignment
/assignment.py
1,607
4.34375
4
import sys import datetime from math import pi #QUE 1 #Write a Python program to print the following string in a specific format #(see the output). #Twinkle, twinkle, little star, #How I wonder what you are! #Up above the world so high, #Like a diamond in the sky. #Twinkle, twinkle, little star, #How I wonder what yo...
true
b90fcdaec766af76f6d06bb34b9ab72ee231f04a
Jessica-A-S/Assignments
/prog1.py
645
4.21875
4
def main(): print("This program will calculate your sleep-debt over 5 days.") total_sleep = 0 for count in range(1, 6): sleep_per_day = int(input("Please enter Day {} sleep: ".format(count))) total_sleep += sleep_per_day print("The total hours that you slept were: \n{} hours".forma...
true
429c1fd0bd87da1f83b832fbf2b24081fc7d8fd9
raopg/algorithm-solutions
/MyWorksheet/LinkedLists/mergeSortedLLs.py
1,229
4.3125
4
## Problem: Given two sorted linked lists, merge them into one sorted linked list. ## Do this in constant space ## Solution: Much like merge sort, simply have two pointers for the linked lists. Move each ## pointer along when it is the lower value. ## Use a header linked list for result, since we don't know beforehand...
true
fb15b0061ec3d291c6ea25b414e1fa9fb1b2beb9
raopg/algorithm-solutions
/Python/mergeTrees.py
514
4.25
4
# Question: Given two trees, merge them, in such a way that -> # 1. Return a new tree # 2. Each node will either be a sum of two corresponding nodes if both # exist, or the non-null node. def mergeTrees(t1, t2): if t1 and t2: t1.val += t2.val t1.left, t1.right = mergeTrees(t1.left, t2.left), mergeT...
true
defcee2198374d13a87f2fb2e37d2f7352eb8d57
raopg/algorithm-solutions
/CTCI/Arrays_and_Strings/permutationOfPalindrome.py
1,040
4.1875
4
# Question: Given a string, design an algorithm to find out if it # is a permutation of a palindrome ## Idea: What makes a palindrome a palindrome? We should be able to ## write it backwards and forwards. Hence, almost all chars must appear ## an even number of times. Only one character can appear an odd # number of...
true
8508fc8fefc6c954e71da54467f73afbb867dec7
glennnnng/scripts-1
/python/user_input_script_2.py
252
4.1875
4
# user_input = len(user_input) # print(user_input) # Trying to do the same thing using count instead of len user_input = input("Input a word:") Str1 = user_input Str2 = 'a' Str3 = Str1.count(Str2) print("Total Number of a's in your word is = ", Str3)
true
c0454c4abf08e1f778644ed66386a1c7aeb6804b
indurkhya/Python_PES_Training
/if_cond.py
972
4.25
4
# Write a program to find the biggest of 4 numbers. # a) Read 4 numbers from user using Input statement. # b) extend the above program to find the biggest of 5 numbers. # (PS: Use IF and IF & Else, If and ELIf, and Nested IF) num1 = int(input("Enter first Number: ")) num2 = int(input("Enter first Number: ")) nu...
true
49fee9bafa044972db44adebe8afaeffedc33b49
indurkhya/Python_PES_Training
/Ques48.py
1,592
4.40625
4
# Create a Calculator with the following functions. # a) Addition/subtraction/multiplication and division of two numbers (Note: Create separate function for each operation) # b) Find square root of a given number. (Use keyword arguments in your function) # c) Create a list of sub strings from a given string, such th...
true
82163e0b9f007568873d9fb1d22dd55bb2bf552d
arcturusInk/questionsAskedInInterviews
/fizzBuzz.py
612
4.25
4
#Write a program that prints the numbers from 1 to 15. #But for multiples of three print “Fizz” instead of the #number and for the multiples of five print “Buzz”. #For numbers which are multiples of both three and five print “FizzBuzz def fizzBuzz(low, high): for num in range(low,high): if num % 3 =...
true
9fe9dad0493fdd37a1768c25100efa06f7e5aa82
Trent-Dell/Refresh
/Set1/e.py
1,573
4.40625
4
#%% #!/usr/bin/env python3 # AUTHOR: Trent Brunson # COURSE: ANLY 615 # PROGRAM: Letter e counter # PURPOSE: Count the letter e in a string. # INPUT: user string of characters # PROCESS: treat the input string as a list of characters # OUTPUT: number of e's in the input # HONOR CODE: On my ho...
true
c9d19914ceb25efc090d7728db344f11310fe668
Trent-Dell/Refresh
/Set1/abecedarian.py
2,520
4.1875
4
#%% #!/usr/bin/env python3#!/usr/bin/env python3 # AUTHOR: Trent Brunson # COURSE: ANLY 615 # PROGRAM: Abecedarian # PURPOSE: Determine if the letters of a word are in alphabetical order. # INPUT: user word # PROCESS: treat the input as a list of characters # OUTPUT: yes or no, the word is an...
true
8a0f6113595eeefcb5b4dd925d30120b5bd005e5
jlwgong/hangman
/Python code/isPrime_nested.py
1,740
4.4375
4
# Create a function that calls another function # Task: # Create a function that tells us all the prime numbers up to some number # For example: # Output all the prime numbers up to 10 # Output: 1, 2, 3, 5, 7 def isPrime(number): # this will tell us if the number is prime, set to True automa...
true
8b5bbc6ba1f7316e226a86feffea829fe8256b77
knromaric/Algorithms-and-Data-Structure-in-python
/stack/stack_class.py
1,212
4.15625
4
''' Implementation of a Stack class with all its method : * stack() creates a new stack that is empty. it returns an empty stack * push(item) adds a new item to the top of the stack. it takes the item and returns nothing * pop() removes the top item from teh stack. it needs no parameters and returns the item. ...
true
96e81ceff1457d8690ada7ceaef2fdd6a043a3ea
knromaric/Algorithms-and-Data-Structure-in-python
/reverse string/reverse_string.py
596
4.375
4
''' given a string, return a new string with the reversed order of characters ---- examples reverse('apple') === 'elppa' ''' from functools import reduce def reverse_v0(text): return ''.join(reversed(text)) def reverse_v1(text): return text[::-1] def reverse_v2(text): reversed = '' ...
true
a13a33af5d8bc31b9f0235dd55e4878f4364f13e
knromaric/Algorithms-and-Data-Structure-in-python
/chunk/chunk.py
1,130
4.28125
4
""" --- Directions Given an array and chunk size, divide the array into many subarrays where each subarray is of length size --- examples chunk([1,2,3,4], 2) --> [[1, 2], [3, 4]] chunk([1,2,3,4,5], 2) --> [[1,2], [3, 4], [5]] chunk([1,2,3,4,5,6,7,8], 3) -->[[1,2,3],[4,5,6],[7,8]] chunk([1,2,3,4,5], 4) --> [[1,2,3,4],...
true
b82f3efd950f674d347cec2ee484f33ea53e8e70
Pareek-Pawan/Study
/Sem3/Python/Scripts/Unit 4/tkinterr/Learning-Tkinter/entry.py
396
4.34375
4
from tkinter import * root = Tk() e=Entry(root,width=20,bg="blue",fg="white") e.grid(row=0,column=0) e.insert(0,"Enter your name") def click(): hello = "Hello! "+e.get() mylabel=Label(root,text=hello) mylabel.grid(row=2,column=0) #creating a label button1=Button(root,text="Click me!",padx=50,pady=20,fg="blue",b...
true
c99af7530938d9d0750f8b3506ac7ae3ab2da36d
varlack1021/Coding-Challenge-Solutions
/Cracking_the_Coding_Interview/Arrays and Strings/urlify.py
601
4.375
4
''' Write a method to replace all spaces in a string with '%20: You may assume that the string has sufficient space at the end to hold the additional characters, and that you are given the "true" length of the string. (Note: If implementing in Java, please use a character array so that you can perform this operation...
true
e6d8b0ab8977cbbb0f13ecdf99099c71a130b8e9
BlakeMcMurray/Coding-Problem-Solutions
/Arrays/zeroMatrix.py
842
4.125
4
#if an element in an m x n matrix is 0, it's entire #row and column are set to zero #O(m*n) solution: loops through matrix twice, #first time to find the rows and columns with zeros #in them, and second time to assign each value in those #rows cols to zero def zero_matrix(m): row = {} col = {} for i in ran...
true
a79a74dc2fc55417ae1a8200ea11018e18a700b2
opagani/pytest-2020-sep-13
/count_vowels.py
503
4.25
4
#!/usr/bin/env python3 def count_vowels(s: str) -> int: total = 0 for one_letter in s.lower(): if one_letter in 'aeiou': total += 1 return total # write a function, count_vowels, which takes a string as # an argument and returns an integer count of how many # vowels were in the strin...
true
98c30d337ebb54c8863117a5b0621051d6f37df7
Munuve30/unit-converter
/converter.py
1,284
4.3125
4
name = input('Enter your name: ') welcome_note= ('Welcome ' + name) print(welcome_note) #Kshs -usd #m -km #kgs - g #Hrs - sec # watts - kw operation = input ( ('Choose one of the 5 operations to perform. \n 1. Kshs to USD \n 2. Meters to Kms \n 3. Kgs to Grammes \n 4. Hrs to Seconds \n 5. Kilowatts to watts \n Enter ...
true
d8d5e26d74dc743732a468ff3539b0d0ee31bf1a
pjlorenz/myappsample
/function_exer.py
673
4.21875
4
def computepay(my_hours, my_rate): '''my_hours is number of hours they worked my_rate is standard rate per hour computepay() computes the week's pay given number of hours worked and standard rate ''' if my_hours > 40: ot_rate = .5 * my_rate + my_rate return (my_hours -...
true
f5abebbf3fe8aba4c7690eb5d7855359d1275915
Monirs/TestRepo
/AddTwoNumbers.py
300
4.28125
4
# Store input numbers num1 = input('Enter first number: ') num2 = input('Enter second number: ') num3 = input('Enter third number: ') # Add two numbers sum = float(num1) + float(num2) + float(num3) # Display the sum print('The sum of {0} {1} and {2} is {3}'.format(num1, num2, num3, sum)) print()
true
a4edc36df25203145d83f04e6dadb85fd17d6b8a
parulsharma-121/CodingQuestions
/day_113_TwoSumII.py
984
4.15625
4
''' Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Note: Your returned answers (both inde...
true
bd36fdab1fe2e747e28d8bd9a716e7182e3990c4
parulsharma-121/CodingQuestions
/day_53_SquareOfSortedArray.py
423
4.1875
4
''' Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1: Input: [-4,-1,0,3,10] Output: [0,1,9,16,100] Example 2: Input: [-7,-3,2,3,11] Output: [4,9,9,49,121] ''' def sortedSquares(A): lst = [] for i in...
true
8e713a4e2066b070f260b4b3d9cc2dcf2b341c14
parulsharma-121/CodingQuestions
/day_63_NumberCompliment.py
678
4.15625
4
''' Given a positive integer num, output its complement number. The complement strategy is to flip the bits of its binary representation. Example 1: Input: num = 5 Output: 2 Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2. Example 2: In...
true
fe11c32fa611230a9fbc26baad1f48b09fb88e07
parulsharma-121/CodingQuestions
/day_178_WaterBottles.py
756
4.40625
4
''' Given numBottles full water bottles, you can exchange numExchange empty water bottles for one full water bottle. The operation of drinking a full water bottle turns it into an empty bottle. Return the maximum number of water bottles you can drink. Input: numBottles = 9, numExchange = 3 Output: 13 Explanation: Yo...
true
b6ebd4d076ad8868b1989cf6017807a072a76efb
parulsharma-121/CodingQuestions
/day_163_RelativeSortArray.py
830
4.40625
4
''' Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that don't appear in arr2 should be placed at the end of arr1 in ascending order. Example 1...
true
3084191ea177144f3d4bbaf0a9424bdc147e388b
parulsharma-121/CodingQuestions
/day_10_replaceMaxFromRight.py
548
4.125
4
''' Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array. Input: arr = [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] ''' from typing import List def replaceElements(arr: List[int]) -> Lis...
true
896b8608e072acc996ea9abcb3e806216bbd6dd8
parulsharma-121/CodingQuestions
/day_127_LongestUncommonSubsequence1.py
1,194
4.25
4
''' Given two strings, you need to find the longest uncommon subsequence of this two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other string. A subsequence is a sequence that can be derived from one s...
true