blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
8a4cc1eaefc4a8ef53c8f6b72e1627d510ed69d6
eduardoimagno/materias-programacao
/materias de programaçao/Algoritmo e estrutura de dados ipg/PROGRAMAÇÃO/Aula10+-+Pesquisa,+ordenação,+expressões+lambda-20191225/examples/ex3lambda.py
2,231
4.78125
5
# Example: More on lambda expressions and higher-level functions. # Copy each statement and execute in INTERACTIVE mode! # JMR 2018 # Lambda expressions may be used to define simple functions: tri = lambda n: n*(n+1)//2 # The lambda expression creates a function, # and we assign it to the tri variable. # Now...
true
4ca8d4395578fd64f880d59061e9cf4ad1e82ffa
moumen-soliman/unscramble-computer-science-problems
/Task1.py
827
4.1875
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 1: How many different telephone nu...
true
ce009ae82e8c4b347e8c78fa3d26395aa5e8cffd
mreboland/pythonFilesExceptions
/numberWriter.py
816
4.53125
5
# Using json.dump() and json.load() # We'll write a short program that stores a set of numbers and another program # that reads these numbers back into memory. The first program will # use json.dump() to store the set of numbers, and the second program will use # json.load(). # json.dump() takes two arguments. A piece...
true
927e239fdd6ae042a9c47b80a4eb21924ded43cf
thaivinhtai/MiniShell
/Builtin/printenv.py
777
4.46875
4
"""This module print the environment.""" from os import environ def print_env(variables): """ print_env(variables) -> print the value of env. This function print the values of the specified environment VARIABLE(s). If no VARIABLE is specified, print name and value pairs for them all. Required...
true
d4f78894b890c3ea44f6237834d7967a981d0c8b
gauravdaunde/training-assignments
/99Problems/List Problems/P24.py
988
4.5
4
''' Lotto: Draw N different random numbers from the set 1..M. The selected numbers shall be returned in a list. Example: * (lotto-select 6 49) (23 1 17 33 21 37) ''' #importingrandint function from random module from random import randint numbers_to_draw = int(input("Enter how many random numbers you ...
true
e7b3bd6ed2590418889aaec301a75ddadec592a4
gauravdaunde/training-assignments
/99Problems/Arithmetic Problems/P31.py
478
4.28125
4
''' Determine whether a given integer number is prime. Example: * (is-prime 7) T ''' #checking number is prime or not def isPrime(number): #checking given number is divisible by any number from 2 to number itself for num in range(2,number): if number == 1 or number % num ==0 and number != num: #if s...
true
527a61c1492fe9b53d424460539e974b788e4992
gauravdaunde/training-assignments
/99Problems/Trees/P56.py
1,533
4.28125
4
''' Symmetric binary trees Let us call a binary tree symmetric if you can draw a vertical line through the root node and then the right subtree is the mirror image of the left subtree. Write a predicate symmetric/1 to check whether a given binary tree is symmetric. Hint: Write a predicate mirror/2 ...
true
f7d243bb27a03d1287c6ef2893480ccfd8f9abae
gauravdaunde/training-assignments
/99Problems/List Problems/P06.py
1,178
4.3125
4
#Find out whether a list is a palindrome. #returning length of list def getLengthofList(list): length_of_list = 0 for item in demo_list: #iterating through all elements and incrementing size counter. length_of_list += 1 return length_of_list #returs reversed string def getReversedList(temp_list): length_of...
true
234a3af68282e92f8e19ae0f4c043e1ee21df256
talhandroid/introduction-to-python
/02Substring.py
759
4.5
4
# Substring -- string[start: end: step] message = "Hello World" # A string print("first example : " + message[0:6]) #Get the first 6 characters of a string print("second example : " + message[6:9]) #Get a substring of length 3 from the 7th character of the string print("third example : " + message[6:]) #Ge...
true
b2e4c04238bb4f62e15b687bf2a337d80109ab7b
DontTouchMyMind/education
/geekbrains/lesson 14/list_ex.py
849
4.15625
4
a = 1 b = a b = 100 print(a) # the result will be 1 a = [1, 2, 3] b = a b[1] = 100 print(a) # the result will be [1, 100, 3] numbers = [1, 2, 3] def change_number_in_list(input_list): input_list[1] = 200 # after call function change_number_in_list(numbers) # the list also change in the main program!!! pri...
true
a6aad8f7f25d373c1fff2475bc6176d304abaef7
sourcery-ai-bot/FAdo
/test_automaton.py
956
4.125
4
#!/usr/bin/python from fa import * from fio import readOneFromFile print print 'The program reads an automaton (in FAdo syntax) from a given file,' print 'and then it keeps reading strings and tells whether each string is' print 'accepted by the automaton. The program terminates if a given string' print 'con...
true
08e89f9252498c5245d6fe38922a4549ec9536bb
apatel2025/File-Processing
/treelist.py
2,642
4.125
4
#------------------------------------------------------------------------------------------------------------------- # Description: This Python script scans through a directory that the user selects and inputs into the command line, # counting the number of files and the file size and printing the contents...
true
f5d7ddf33fc46aa52b9d7abcae2cd4d2f1176153
messi-1020/School-Work
/LAB 03/Lab03-Q2.py
563
4.125
4
# Python Code for Lab 03 Problem 2 room_length = float(input("Enter room length:")) room_width = float(input("Enter room width:")) room_height = float(input("Enter room height:")) room_light = input("Does the room get a lot of sunlight?[y/n]") room_volume = room_length * room_width * room_height btu = room_volume * 3...
true
089af52de65e1319031abf2f9972e3d13bb65880
wafapathan/basicprograms
/comparision.py
481
4.15625
4
def compare_numbers(): a=int(input("Enter the value of a:")) b=int(input("Enter the value of b:")) if a > b: print("a-b") return a-b else: print("b-a") return b-a # if a == b: # print("values are equal") # return 0 # elif a > b: ...
true
145d493cbe25055faf53d3f35c12eb4f6a97d98b
xaroth8088/SystemPanic
/SystemPanic/GamePaks/LevelGenerators/ExampleLevelGenerator1/pak.py
1,183
4.15625
4
from random import randint class Pak: def generate_walls(self): """ Called whenever a new level is started, to generate the walls for the level. :return walls: A list of lists of booleans, to indicate where walls are placed. Like this: walls = [ [ ...
true
46da3806c308973d6f7eccab4ae0db4de7af9bb2
ifegunni/hackerrank
/dynamicArray.py
2,458
4.21875
4
Create a list,seqList , of empty sequences, where each sequence is indexed from to . The elements within each of the sequences also use -indexing. Create an integer, , and initialize it to . The types of queries that can be performed on your list of sequences () are described below: Query: 1 x y Find the sequence, ...
true
6532d1ac0855073ac5707a014385ed9225142b8a
thevarungrovers/Extension-of-files
/Find extension.py
785
4.40625
4
# file name fname = input("Enter Filename:") # spliting the filename extname = list(fname.split(".")) # extracting extension lname = extname[1] #comparing the extension if lname == 'py' or lname == 'PY': print('The extension of the file is python(py).') elif lname == 'html' or lname == 'HTML': ...
true
732cc3d5d9317869ce15169a3fbba2a3ca8a0b30
mdshepard/numseq
/numseq/prime.py
770
4.1875
4
"""this here's a couple functions dealing with prime numbers the first un' goes and prints out all the prime numbers leadin up to n the second un' goes and finds out if the number you enter is prime or it'aint """ """prints a list of prime numbers up to the argument""" def primes(n): result = [] for num in ran...
true
9a1e4bddb431b99dee9c7966bc285e1703cde3c5
Charles702/Visual_Computing_Lab
/07 Python_Intro_Codes/code/4_tuples.py
953
4.59375
5
#Diving into tuples #### difference between list and tuple # http://net-informations.com/python/iq/tup.htm #initializing empty tuples t1 = () # round brackets print (t1) t2 = (1,2,3,4,5) # tuple with number datatype t3 = ("codex" , "iter" , "python") # tuple with string datatype t4 = ("codex" ...
true
9d360f3ca0b71c4b96e314d67c2b14edc7148bf3
jmuganga54/CS50-s-Web-Programming-with-Python-and-JavaScript-
/Python-code/list.py
274
4.34375
4
#Define a list of names names = ["Harry", "Ron", "Hermione","Ginny"] #printing all the values in a list print(names) #adding value to a list names.append("Draco") #Sorting all the names in a list names.sort() #Printing all the values in a list after sorting print(names)
true
e1c4854f47a90be9c5c101650ed8510995f3f284
mrpulsar/pythonTHW
/ex16.py
2,178
4.9375
5
#import argument variable from system module from sys import argv # assign python script and a filename to argument variable (argv) script, filename = argv #Next three prints outline options to user for erasing the passed in file or keeping it as is. print "We're going to erase %r." % filename print "If you don't want ...
true
daa600712a00cae2241f166938bbc766d30e0d7d
mrpulsar/pythonTHW
/ex19.py
2,454
4.25
4
# Defining function "cheese_and_crackers" with arguments "cheese_count" and "boxes_of_crackers delimited by commas def cheese_and_crackers(cheese_count, boxes_of_crackers): # Following print's outputs to console the amount of cheeses and boxes of crackers, and additional information regarding them. print "You have %d...
true
72e02f5a177ba99ae85c255776123c55be6b7c73
mrpulsar/pythonTHW
/ex7.py
1,033
4.15625
4
# Output the followi to console window print "Mary had a little lamb." # Output a formatted string using a %s string format with the string 'snow'. print "Its fleece was white as %s." % 'snow' # Output next line to console. print "And everywhere that Mary went." # Output 10 periods "." to the console. print "." * 10 # ...
true
4bddd8452a34b1066d777e14bea264e8b7fad9b2
evab19/forritun
/Próf 2/size_count.py
1,530
4.25
4
# Create a program that lets the user input an integer, lets call it size. This integer should # denote the size of a list. Next you should let the user input size many values to a list. Next # you should let the user input a value, lets call it target. Next you should count how often the # value target occurs in the l...
true
b96f6c4098675eaea0dfed7e1325d03872c840ad
meghamohan/holbertonschool-higher_level_programming
/0x0B-python-input_output/3-write_file.py
237
4.1875
4
#!/usr/bin/python3 """ function that writes a string to a text file (UTF8) and returns the number of characters written """ def write_file(filename="", text=""): with open(filename, 'w') as file1: return file1.write(text)
true
f834f20992f0973042f38588c68270139ba17248
xysey/ATBS
/regex programs/exclamationPointRemover.py
532
4.3125
4
#! python3 """ A program to search and remove repeated exclamation points. """ import re import pyperclip text = str(pyperclip.paste()) # will search a for a repeated exclamation mark exclamationRegex = re.compile(r"\b(!{2,})") # remove the excess exclamation mark if exclamationRegex.search(text): text = exclamati...
true
3cdc566ef800c75c84542f9b9a0060a81664fe91
uc-aversan/IT3038c-scripts
/python/nameage.py
1,079
4.28125
4
import time start_time = time.time() print('What is your name?') myName = str(input()) #while loop example while myName != "Aaron": if myName == 'your name': print("Not funny, Dad. What's your real name?") myName = input() else: print("You are not authorized to run this.") myN...
true
6383cd14ba00a602a942343d70ecdc141c6f80a9
CyberCoding04/Rock-Paper-Scissor
/main.py
1,119
4.34375
4
import random userpoints = 0 comppoints = 0 while True: userchoice = input("Enter Your Choice(Rock, Paper, Scissor or any Other to EXIT): ").lower() if userchoice == 'rock' or userchoice == 'paper' or userchoice == 'scissor': '''If user enter any of the choice''' compchoice = random.choice(['rock', 'paper', 'sci...
true
79a343f709460d3646ce8201b9c8eec8ceb385fb
anvetsu/anviz
/fibonacci/golden_rectangles.py
2,454
4.28125
4
""" Plot the Fibonacci 'Golden Rectangles' which lead to the Golden curve using matplotlib. """ import matplotlib.pyplot as plt from matplotlib.patches import Rectangle from matplotlib.collections import PatchCollection def fibonacci(n=10): """ Generate fibonacci numbers upto 10 starting with 1,2 ... """ ...
true
0240b4db9745435a7403ad3e73cb30ff5e7ac91c
singhr2/Python101
/basics/ExceptionHandlinginPython.py
1,616
4.34375
4
# ExceptionHandlinginPython.py ''' The code, which harbours the risk of an exception, is embedded in a try block. But whereas in Java exceptions are caught by catch clauses, we have statements introduced by an "except" keyword in Python. It's possible to create "custom-made" exceptions: With the raise statement it's...
true
f1dcab594f91069bd79d9e10679b1007b69cc391
singhr2/Python101
/basics/ClassBooleanTest.py
1,039
4.21875
4
#ClassBooleanTest.py ''' * Boolean Tests: __bool__ and __len__ * When you code classes, you can define what this means for your objects by coding methods that give the True or False values of instances on request. Python first tries __bool__ to obtain a direct Boolean value; if that method is missing, Python tries...
true
0102b2f86f0bc49d5f17f7a9fef78ba7284c514f
DigitalCrafts/gists
/Data_Analytics/python training/user input & string interpolation/multiple-string-interpolation.py
264
4.1875
4
user_input_name = input("Enter a name: ") user_input_place = input("Enter a place: ") # welcome message with multiple values passed to string interpolation welcome_message = "Hello, %s! Welcome to %s!" % (user_input_name, user_input_place) print(welcome_message)
true
8493c5d5de413711ebd5c8eb985947b434ba533e
DigitalCrafts/gists
/Data_Analytics/python training/installing packages/class ecercises/round_towards_zero.py
999
4.34375
4
# import the numpy package and give it the alias np import numpy as np # creata a user defined function called round to zero def round_towards_zero(number): # logical expression for rounding a number towards zero # - if number is less than zero (negative) round "up" towards zero # - otherwise, (if number ...
true
942b118a03db15abc4f28f7bb1d3d37c60eea60c
FadedIllusions/Py3Bootcamp
/code/026_Sets.py
624
4.5625
5
# Sets # Like Formal, Mathematical Sets # Doesn't Not Permit Duplicates # Elements Aren't Ordered (Cannot Use Index To Access) # ex_set {1,2,3,4,} ... ex_set = set({1,2,3,4,5}) nums = {1,2,3,4,5} print("\nAccessing Values In Set With 'FOR' Loop:") for num in nums: print(num) # Example Use-Case Of Sets: # Given mult...
true
1dc7b63c3443b96e9dbcfec0cfc76c5c7368d2b6
PratapSingh13/python-tutorial
/variable_tutorial.py
2,333
4.34375
4
#Variables are containers for storing data values #Unlike other Programming languages, Python has no command for declaring a variable. var1 = 5 var2 = "Yogendra" print(var1) print(var2) var3 = 4 #var3 is of type int var3 = "Pratap" #var3 is now changed and type of str print(var3) #String variables c...
true
dcbea6c9f43769d5975d78f8cad4effe9164b5ee
d1p013/testing
/GeneralPythonCodes/Chapter4_Functions/lambda.py
933
4.375
4
''' Lambda Functions in Python Examples and Playground ''' print("----------------") # Lambda Functions sqr = lambda x: x * x print(sqr) print(sqr(5)) print("----------------") # Lambda and Map on a List num_list = [1, 2, 3, 4, 5] sqr_list = list(map(lambda x: x*x, num_list)) print(sqr_list) print("Squares of", nu...
true
49d7ecb9902e4ece678b5d24c36d1e449253cdc4
rjiang2/tech-savvy
/hello.py
296
4.15625
4
# print('hello, world') # print(2 + 2) name = input('Please enter your name: ') print('Hello,', name) grade = 'A' print(name, 'got a grade', grade) a = 123 print(a) a = 'ABC' # Whatever inside the '' is a string. String is the most used. print(a) x = 10 x = x + 2 print(x) x += 2 print(x)
true
40393b433470a41754cc1626f19a6c8dc37ad724
jiriVFX/data_structures_and_algorithms
/interview_problems/break_palindrome.py
1,350
4.28125
4
# Hackerrank problem # Complete the 'breakPalindrome' function below. # # The function is expected to return a STRING. # The function accepts STRING palindromeStr as parameter. # Return "IMPOSSIBLE" if string can't be created def break_palindrome(palindrome_str): if len(palindrome_str) == 1: return "IMPOS...
true
4eff8b1eee305f5d61e242ed0e845bc4ae3c084e
jiriVFX/data_structures_and_algorithms
/recursion/fibonacci_using_recursion_and_loop.py
1,172
4.375
4
# Return nth number in Fibonacci sequence, n is given index number # O(2^n) exponential time complexity def fibonacci_rec(n): """Fibonacci sequence with recursion. Returns nth element in the sequence.""" if n > 1: return fibonacci_rec(n - 1) + fibonacci_rec(n - 2) return n # O(n) linear time com...
true
aa71fba0f838c8d3896c436af77fd4bac290aeda
aravindhnivas/Learn_Tkinter
/tutorial-6.py
356
4.1875
4
from Tkinter import * root = Tk() def printName(): print("Hey people, My name is Tejas") button1 = Button(root,text="Show me your name!",command=printName) #Command=printName calls the function printName #This is binding the function to widget...
true
4da9ac3264d0de0adde7f4c2cd0104a9039ebd6b
mogaskins/pythonthehardway
/ex20.py
948
4.4375
4
#import the package from sys import argv # need to type the file name and text file to read in script, input_file = argv #Create the print_all file function to print the whole file def print_all(f): print f.read() #define the rewind file function to go to the zero byte of the file def rewind(f): f.seek(0) #f.readlin...
true
b9750aa980c797adcf6d49e6adc6bbc04486f314
CherylXu917/coding_practice
/LeetCode/408. Valid Word Abbreviation.py
1,646
4.28125
4
""" 408. Valid Word Abbreviation Easy 215 914 Add to List Share A string can be abbreviated by replacing any number of non-adjacent substrings with their lengths. For example, a string such as "substitution" could be abbreviated as (but not limited to): "s10n" ("s ubstitutio n") "sub4u4" ("sub stit u tion") "12" (...
true
742415d4c74dd6abbfab321d32a873773ec8ee99
dorrakorman/19.9.21
/targil1.py
402
4.40625
4
# 1. input a number check if it is divided by 10 without reminder # you need to check if it is % 5 and % 2 == 0, if so print ('can be divided by 10') a = int(input('enter number to check: a = ')) if (a % 5 == 0) and (a % 2 == 0): print('can be divided by 10') else: # print('can\'t be divided by 1...
true
779aed25765b756e3a952e7b9317158c10f793b5
atrnh/code-challenges-py
/easy/challenges.py
1,300
4.40625
4
def decode_string(word): """Return the decoded version of a string. Strings are encoded like this: - 'Apple' is 'A1p2l1e1' - 'cottage' is 'c1o1t2a1g1e1' - 'aabbbcca' is 'a2b3c2a1' Example: >>> decode_string('a2b3c2a1') 'aabbbcca' >>> decode_string('a1p2l1e1') 'apple' >>> de...
true
d7323f4eae9ecb48495b84194191b2ffcbc97a5d
RustyRaptor/CS172Labs
/lab_chapter_9a.py
1,090
4.15625
4
class ItemToPurchase: item_name = str() item_price = float() item_quantity = int() def __init__(self, item_name="none", item_price=float(0), item_quantity=int(0)): self.item_name = item_name self.item_price = item_price self.item_quantity = item_quantity def print_item_cost...
true
b84971fb8498691cfb406dd108a2a80c4ca1c77d
BeyondAntares/Automate-the-Boring-Stuff
/Zodiac.py
2,436
4.125
4
''' * Determins a users Zodiac Star Sign from their birth date ~~ Key Dates for consideration ~~ Aries (March 21-April 19) Taurus (April 20 - May 20) Gemini (May 21 - June 20) Cancer (June 21 - July 22) Leo (july 23-August 22) Virgo (August 23 - September 22) Libra (September 23 - October 22) Scorpio(Octo...
true
5b048c9f8fc523846a21eaf1799963f3fe69d141
PVyukov/epam
/Python/task1.py
1,523
4.40625
4
from math import sqrt, pi def print_type(variable): """This function prints the type of supplied variable Args: variable (Any): variable to print type for """ # fill the gaps ... print(type(variable)) def do_action(variable): """Does the action depending on variable's type. (hint: y...
true
fc82d958078b62482f01141f67f4a9401c80e916
sanuragdharme/data_structure
/queue_module.py
2,058
4.1875
4
# Queue - First in First Out from queue import Queue # Built-in Queue print("*** Built-in Queue ***") game = Queue(5) print("This will print object: ", game) game.put("Cricket") game.put("Hockey") game.put("Football") print("Check is Queue is empty or not: ", game.empty()) print("Check is Queue is full or not: ", g...
true
3d64686da97bdfe38d0ff96ed27d59e037425d25
sunil123-anna/demo1
/String/lambda.py
478
4.28125
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 # x = lambda a, b, c, d: a ** 2 + b * 3 + c # print(x(10, 2, 4, 89)) # Python Program to Find Numbers Divisible by Another Number using an...
true
6319957cbdd8c0b628859cd097974ee1de043a21
ish-suarez/afs-210
/week5/merge sort/mergesort.py
1,229
4.3125
4
# Here is my source: https://runestone.academy/runestone/books/published/pythonds/SortSearch/TheMergeSort.html # Merge Sort Function that takes an Array of numbers def mergeSort(alist): print(f'Splitting: {alist}') # if there list is populated run thins if len(alist) > 1: mid = len(alist) // 2 ...
true
fc4bad4ff301f9c8b46a1a4508d5167639bb2874
krskelton/05-circle-area
/circle_area.py
381
4.25
4
# TODO: DEFINE a function using the def keyword called `area_of_circle` # TODO: implement the function to RETURN (NOT PRINT) the area of a circle whose radius is r import math def area_of_circle(r): area = (r ** 2) * math.pi return area def main(): circle = area_of_circle(2.3) print(circle) main() # HINT:...
true
2eb98dfefb8e1a99a38ff1a58102f963367d223b
johnduva/HackerRank
/countingValleys.py
1,552
4.75
5
# An avid hiker keeps meticulous records of their hikes. During the last hike that took exactly 'steps' number of steps, # for every step it was noted if it was an uphill ('U') or a downhill ('D') step. # Hikes always start and end at sea level, and each step up or down represents a unit change in altitude. We defin...
true
85a335506bc0fbb8a70b953085f5384a13e95b1f
AaronTheNerd/Personal-Coding-Projects
/Python/MadLibs/madlib.py
1,124
4.21875
4
def main(): ''' This project is a way to design your own madlib style prompt ''' # Step 1: get paragraph paragraph = getText() # Step 2: remove all adjectives, verbs, nouns mad_lib = removeText(paragraph) # Step 3: Ask user for replacement words based off description new_paragraph = fill_prompt(mad_...
true
b686dd44f0da84018ed26a115c96bf407856451f
SariFink/wd1-20200323
/Class1_Python3/example_00210_operations_integers_with_variables_exercise_solution.py
900
4.125
4
# Task 1 # define 2 variable and give them the values 2 and 10, then calculate the result of the division 2/10. # print the result print("division 2/10: ") # write your code here x = 2.0 y = 10.0 ergebnis = x / y print(ergebnis) print() # Task 2 # save your first name and last name as string, and concat them to 1 ...
true
bc1cf68eacec5ba2f70326cec796851ba154bc52
SariFink/wd1-20200323
/Class2_Python3/example_00610_while_loop_break_exercise.py
282
4.1875
4
# write a while loop # a counter with initial value 0 # gets added 2 on each loop iteration # if the counter is greater than 20 stop the loop # otherwise print the number counter = 0 while True: counter += 2 if counter > 20: break else: print(counter)
true
866bcaa302bb52dcc3b026cb2df3579dd43810bd
Rodrigo-Ruiz1/python2
/largeapp1.py
1,472
4.34375
4
# create Dictionary phonebook = { "Melissa": "584-394-5857", "Alice": "703-493-1834", "Bob": "857-384-1234", } # Loop will continue until user chooses to quit while True: # Show user the prompts print("Electronic Phone Book\n===========\n1. Look up an entry\n2. Set an entry\n3. Delete an entry\n4. Lis...
true
ba60770bd1f16faa7f833175f4111004d3bf0136
wambuic/validation_python
/validation/validation.py
2,113
4.1875
4
data_valid = False while data_valid == False: grade1 = input("Type your first grade:") try: grade1 = float(grade1) except: print ("Invalid input. Only numbers are allowed. Decimals should be separated by a dot. ") continue if (grade1 < 0 or grade1 >10): print("Grade should be between 1 and 10...
true
02d40cae5bf49cb9d96429dd356831b49218f8c2
clever-marcus/my-portfolio
/index operator.py
317
4.25
4
#index operator[] = it gives to a sequence's element (str, list, tuples) name = "smart Developer!" """if(name[0].islower()): name = name.capitalize()""" first_name = name[:5].upper() last_name = name[5:].lower() last_character = name[-1] print(first_name) print(last_name) print(last_character)
true
b2f6939929ec0f6b3c405bcdddb2df71912e8359
clever-marcus/my-portfolio
/filter() function.py
511
4.25
4
#filter() => creates a collection of elements from an iterable for which a function returns true #filter(function, iterable) friends = [("Dan", 21), ("Pato", 25), ("Zena", 19), ("jared", 23), ("Josie", 20), ("Betty", 19), ("Doti", 17), ...
true
33adf35d85ad639d0fbe4a5b6de4b486c67e1a85
clever-marcus/my-portfolio
/Abstract class.py
889
4.4375
4
#Prevents a user from creating an object of that class # it compiles a user to override abstract methods in a child class #abstract class = a class which contains one or more abstract methods. #abstract method = a method that has a declaration but does not have an implementation. from abc import ABC, abstractme...
true
17108f1b33b54b976523378952179a3b20095702
clever-marcus/my-portfolio
/tuples.py
374
4.1875
4
#tuple => this is a collection which is ordered and unchangeable # => they are used to group together related data student = ("marcus", 21, "male", "Epic_programming") print(student.count("marcus")) print(student.index("Epic_programming")) for x in student: print(x) if "marcus" in student: p...
true
458619ac87bbb707787faeb1bc24924a416cb8c8
ChulwooKim-AI/ctci-6th-edition
/Chapter1_ArraysAndStrings/06.StringCompression.py
952
4.53125
5
"""Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2b1c5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string. You can assume the string has only up...
true
a0f17d908a206d91a85b83896a8a349a32adb773
ChulwooKim-AI/ctci-6th-edition
/Chapter1_ArraysAndStrings/09.StringRotation.py
1,535
4.125
4
"""String Rotation 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"). """ def is_roatation1(s1, s2): ret...
true
bfacfc67a05533af6e37132fd99af8d0bf3f6797
siegfred14/zuri
/19_functions.py
2,821
4.625
5
# FUNCTIONS # A function is a block of codes which only runs when called def simple_function(): print('This is my first function!') # to call the function simple_function() # parameters are added to the function, then called as arguments # def simple_function(name): # print(f"Hello {name}") # # name_input =...
true
64e1f38c1c0ad3d419e68b4eaff6eed25474574f
Nicholas-Graziano/ICS3U-Assignment4b-Python
/uppercase_lowercase.py
548
4.21875
4
#!/usr/bin/env python3 # Created by: Nicholas Graziano # Created on: November 2020 # This program checks if u got the right random number def main(): # this program checks if a letter is uppercase or lowercase # input letter = input("Enter a Letter :") # process if(letter >= 'A' and letter <= 'Z...
true
df490e421045e5b47a839dc1574be5b8d6cb683c
Davidsaemund/max_int
/max_int.py
376
4.375
4
num_int = int(input("Input a number: ")) # Do not change this line max_int = 0 # While num_int er positive number ask again while num_int >= 0 : # If max_int is less than num_int, set max_int == num_int if num_int >= max_int : max_int = num_int num_int = int(input("Input a number: ")) print(...
true
dcaae6a879f02619d31297a17750dc7ca2cd9340
La-Shallot/python-class
/Mastermind.py
1,754
4.125
4
#setting up variables range=5 import random answer1=random.randint(1,range) answer2=random.randint(1,range) while answer1==answer2: answer2=random.randint(1,range) # the funtions def intro(): print("Welcome to mastermind........avec le numerique.") print("I have two numbers raging from 1 to 10...
true
618982c403e0bdef2303e4f036a9648aee465672
SaileshRokaya/PracticalTaskWeek-1
/exe3.py
536
4.25
4
'''3. Write a python program to swap the values of 3 variables.''' # Taking values from the user x = input("Enter first number: ") y = input("Enter second number: ") z = input("Enter third number: ") # Display the values print('The value of x is: ', int(x)) print('The value of y is: ', int(y)) print('The value of z i...
true
08373fa721c5db2f8de75cc714b3aca2c9a0a9ba
MustSeeMelons/py-euler
/problem_1.py
412
4.3125
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. import platform print("Using: " + platform.python_version()) limit = input("Please enter limit: ") sum = 0 for i in range(int(l...
true
c37e33bd92b7da4fd0296ff6919a3ba642df3cb3
vpytlik/Calculator
/calculator.py
1,401
4.125
4
from Addition import Addition from Subtraction import Subtraction from Multiplication import Multiplication from Division import Division my_add = Addition() my_sub = Subtraction() my_mult = Multiplication() my_div = Division() def main(): while True: print("Welcome! Select operation:") print("1....
true
ba60f49a38c7f06f2549c9acf37d878947cdd7b5
cwal7887/cti110
/P3HW2_Walker.py
1,648
4.28125
4
#Christian Walker #10/1/2019 #P3HW2 - Meal, Tip and Tax Calculator #---------------------------Pseudcode-------------------------# ##Ask user the price of the meal #Display Enter price of meal #Input meal ##Ask user would they like to tip 16, 18, or 20 percent #if tip is 16 multiply meal by 0.16 #if tip is 1...
true
e101711a7a27ca13270aa9b10de464e399063f90
wibrvallejoma/location-haversine
/Location.py
1,478
4.21875
4
class Location: """A location from Earth. We are storing the location([latitude, longitude]).""" def __init__(self, location): if type(location) not in [list]: raise ValueError("The location must be a list with two values [latitude, longitude].") if len(location) != 2: raise ValueError("The lo...
true
46f23afc7e53ae1a84c9a9a97728620eec7bc69b
MALLICHARANSAI/DSP-LAB
/array append.py
271
4.1875
4
import numpy as np a=input('Enter any array:') b=input('Enter array to append:') c=a d=b x=np.array(c) y=np.array(d) e=np.append(x,y) print(e) for i in range(0,len(b)): a.append(b[i]) print('The appended array using for loop:',a)
true
8675bb981b8c6c1f3a75c4f46ac06d483102f42f
HaylsDpy/Python---Udacity
/3.13 - Pandas groupby.py
1,658
4.40625
4
# Task: group the subway data by a variable of your choice - day of the week/ hour of the day/ whether it was raining or not. Then, find the mean subway ridership for # each different value and either, produce a plot showing the results, or, simply print out the numbers, if that makes more sense. %pylab inline import ...
true
03063eb54838aa484dcef0f7527170a0c501d60c
HaylsDpy/Python---Udacity
/3.11 - Adding a dataframe to a series.py
1,323
4.625
5
# In Pandas, you can use vectorised operations to add two DataFrames together, just like you can add two Series together # It is also possible to add a DataFrame to a Series # Have a look at the following code and try to figure out what happens when you try to do this import pandas as pd # Adding a Series to a square...
true
2938aa8d40c395d10b6cc7846077efef84b08a24
mohamad-ali-nasser/Sprint-Challenge--Data-Structures-Python
/reverse/reverse.py
1,847
4.1875
4
class Node: def __init__(self, value=None, next_node=None): # the value at this linked list node self.value = value # reference to the next node in the list self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.next_node def set_next(self, n...
true
66baa2435bc41f974def4a748423cd993753a6b8
dpettas/CustomizeMatplotlib
/my_mpl_template/linestyle/LineStyle_class.py
2,037
4.15625
4
class LineStyle(): """ arguments: linewidth, dashes, color, alpha """ def __init__(self,linewidth,dashes,color, symbol = 'o', size=10, alpha = 1.0, dashDot = [1,1]): """ Arguments: """ # variables related with the plot self.linewidth = ...
true
d3534b18913ddc61b493e743c35820c79037a9ef
sana990/PyScripts
/Scripts/ListComprehension.py
259
4.15625
4
n = int(input("Enter a number as a range: ")) print("A list of numbers of squares up to the given number is:") print([x**2 for x in range(n)]) print("Converting the list of numbers till the given number to string data type:") print([str(x) for x in range(n)])
true
43aa8f85d93aaf7c19757c5534b6ea21e9e80dda
eyspahn/interview_practice
/udacity_interviewing_course/binary_search.py
1,206
4.15625
4
"""You're going to write a binary search function. You should use an iterative approach - meaning using loops. Your function should take two inputs: a Python list to search through, and the value you're searching for. Assume the list only has distinct elements, meaning there are no repeated values, and elements are in ...
true
71523e74f3385be70ec472d29f69c30354ba3d0c
eyspahn/interview_practice
/udacity_interviewing_course/fibonacci.py
330
4.1875
4
"""Implement a function recursively to get the desired Fibonacci sequence value. Your code should have the same input/output as the iterative code in the instructions.""" def get_fib(position): if (position==0) or (position==1): return position else: return get_fib(position-1) + get_fib(positio...
true
e6c18fd46af502328fb291d55ffb4209b01730c6
soumadiptya/OOP-in-Python
/Chapter1_Classes_and_Instances.py
822
4.25
4
# Python Object Oriented programming class Employee: def __init__(self, fname, lname, pay): self.fname = fname self.lname = lname self.pay = pay self.email = self.fname + '.' + self.lname + '@company.com' # Class Methods def fullname(self): '''Returns the fullname of an employee''' fullname = self.fnam...
true
3b26e6098800043fc75d3fdcb2b0574aa7f9a124
russlarge256/Python210-W19
/students/RussellLarge/RussellLarge-A04/dict_lab.py
2,611
4.1875
4
#-------------------------------------------------# # Title: List Lab # Dev: Rlarge # Date: 1/31/2019 # ChangeLog: (Who, When, What) # RLarge, 02/02/2019, Created Script #-------------------------------------------------# #!/usr/bin/env python3 # $ chmod +x dict_lab.py #Create a dictionary containing “name”, ...
true
8b8bb0dc309272de7f19e1a99102e724dd5f8388
PythonCharmer1/-United-States-of-America-Computing-Olympiad-USACO-Prep
/Vowels.py
532
4.34375
4
# By Yusuf Ali # This is a very basic program # It takes any string for this case the string is "aexiretretergfddxvdshbewrerevwrwvou" # What this program does is that it takes the string an returns the number of vowels in this program string = "aexiretretergfddxvdshbewrerevwrwvou" def Vowels(string): coun...
true
85926a529fc7a868771fbce991ed7b39a6769699
cyberbono3/amazon-oa-python
/25_fav_genres.py
2,624
4.15625
4
""" Given a map Map<String, List<String>> userSongs with user names as keys and a list of all the songs that the user has listened to as values. Also given a map Map<String, List<String>> songGenres, with song genre as keys and a list of all the songs within that genre as values. The song can only belong to only one...
true
fed6a4b6daacd0490fc16b3de52ca73d4a6fc866
domiee13/dungcaythuattoan
/Codewars/highest_rank.py
671
4.1875
4
# Complete the method which returns the number which is most frequent in the given input array. If there is a tie for most frequent number, return the largest number among them. # Note: no empty arrays will be given. # Examples # [12, 10, 8, 12, 7, 6, 4, 10, 12] --> 12 # [12, 10, 8, 12, 7, 6, 4, 10, 12,...
true
7b2a8a52a79350b1185b1437d689e4601290339a
domiee13/dungcaythuattoan
/CodeSignal/sortByHeight.py
594
4.15625
4
# Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a non-descending order without moving the trees. People can be very tall! # Example # For a = [-1, 150, 190, 170, -1, -1, 160, 180], the output should be # sortBy...
true
9e4b00013149e1fee616041787c94bf11c815acf
domiee13/dungcaythuattoan
/Codeforces/helpfulMaths.py
769
4.25
4
# Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation. # The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough fo...
true
bf9e7ab96631c0b6d72cc4c8424e317b3457003d
apshah007/learnpython
/ex20.py
1,181
4.375
4
# imports the module argv from sys import argv # asks for arguments when the program is started script, input_file = argv # defines a function def print_all(f): print(f.read()) # defines a function def rewind(f): f.seek(0) # defines a function def print_a_line(line_count, f): print(line_count, f.readline())...
true
f0bf9494c4ed94f11080db4d15fbc021222cfbf6
apshah007/learnpython
/ex16.py
1,189
4.40625
4
# imports the argv module from sys import argv # asks for the 2 arguments when the program is started script, filename = argv # prints to the screen certain commands print (f"We're going to erase {filename}.") print ("if you dont want that, hit CTRL-C (^C).") print ("if you do want that, hit RETURN.") # asks for an in...
true
2a6a86ff4a2859abd3e01ffae9b168292db56b0b
skhurana852/Math
/LinkedList.py
833
4.4375
4
#A Single List list code class Node: # Function to initialize the node def __init__(self,data): self.data = data #Assign Data self.next = None #Intialize next as null #Linked List Class class LinkedList: #Function to intialize the Linked list object def __init__(self): s...
true
f5f2c74d54a76e8682e3d0d30d9ef69eaedd7b77
vthaver/pythonfordatascience
/learnpython_hard/ex20_Functions_Files.py
1,193
4.34375
4
#Exercise 20 LPTHW: Functions and Files #This script explores the use of functions in reading and printing pars of a file from sys import argv #argv is a system function that lets vales be passed through the command line when initiating the script script, input_file = argv #This line unpacks the variable argv that i...
true
1be0a9939f90199abd706ce1fd11b3c2bd1657cd
vthaver/pythonfordatascience
/learnpython_hard/ex14_Reading_Files.py
623
4.375
4
#Exercise 15 LPTHW: Reading Files #This code shows two ways we can open anther file specified by input from the user from sys import argv script, filename = argv #Pass the first argument as the filename to be opened txt = open(filename) #Before reading a file, you must open it into a variable print(f"Here's your f...
true
a8d5170330dfe5128b163445803e856b05c7c925
OmarMuhammedAli/Algorithms
/algorithms/Python/StringToToken/str_tok.py
377
4.625
5
# Input the string string = input("Enter the desired string: ") # Input the delimiter delimiter = input("Enter the desired delimiter: ") # If delimiter is not set, make it a space by default if(delimiter == ""): delimiter = " " # Split the string based on the delimiter tokenList = string.split(delimiter) # Prin...
true
6d86903625d876b9d80171993da5d1481fd67fe1
MAHESH9598/bytearray
/bytearray.py
566
4.15625
4
"""---> bytearray is one of the class, treated as Sequence Type datatype --> The purpose of this data type is to organize the data in the range of 0 to 256 --> mutable --> To convert specified range of values into bytearray datatype we use a predifined function called bytearray() """ a = [10, 20, 30, 40] b = bytearr...
true
ff1112f3e40cc8b73ab0260a521ad0a2081fb17a
andrsj/Python-Edu
/python/itertool.py
685
4.1875
4
# itertools from itertools import product, permutations letters = ("A", "B") print(list(product(letters, range(2)))) print(list(permutations(letters))) OUT: [('A', 0), ('A', 1), ('B', 0), ('B', 1)] [('A', 'B'), ('B', 'A')] # The function count counts up infinitely from a value. # The function cycle infinit...
true
6e6bc8a4335c1f1201653a894858361a5ba987af
peaudann/OS-Library
/assignment8_1.py
1,601
4.375
4
import os # Gather file name and location from user def file_info(): print("WARNING: If a text file exists with the name you enter it will be overwritten.") file_name = input("What would you like to name the file: ") file_location = input("Where would you like to save the file(ex. C:\*insert folder path he...
true
6b382f2528601ece9a61290e1e333bf6e12c4946
carolynemilgo/100daysofpython
/weekday_name.py
541
4.4375
4
#Return the weekday name based on the day of week passed in. def weekday_name(day_of_week): if day_of_week == 1: return "Monday" elif day_of_week == 2: return "Tuesday" elif day_of_week == 3: return "Wednesday" elif day_of_week == 4: return "Thursday" elif day_of_wee...
true
386c89356be692c5ddd51553c93e66a75770d21e
Undka14/WEP_class
/student_C6/6.1_function.py
630
4.40625
4
# this code demonstrates defining and calling a function # we define a function with 'def <YOUR NAME>:' and then an indented block # functions end with a return to send the value from a call def add_two_numbers(x, y): """ this function adds x and y """ z = x + y return z # a function is called by...
true
cc4b6aa5e7194829036c6dac2eae1702d483c837
Vchenhailong/my-notes-on-python
/basic_rules/chapter_3/string_action.py
1,091
4.125
4
#! /usr/bin/python # coding:utf-8 from math import pi class StringFormat: @staticmethod def string_format(): string = 'Hey, %s. %s enough for ya?' values = ('guys', 'Hot') # This is simple-format # 简单字符串格式化方法 print(string % values) # This is standard format ...
true
f0b5d6b8043aff1d39bc237dae819c5d7d2ffe3c
FrankieZhen/Lookoop
/LeetCode/python/20_simple_Valid Parenthese.py
1,022
4.1875
4
''' Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid. Exa...
true