blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
9a4e405ebe747fddfe15e0a2acbe727acad875b5
smi7hy96/python
/python/Exercises/109_bizzuuuu_OOP/109_bizzuuu.py
2,107
4.1875
4
# Write a bizz and zzuu game ##project # as a user I should be able prompted for a number, as the program will print all the number up to and inclusing said number while following the constraints / specs. (bizz and buzz for multiples or 3 and 5) # As a user I should be able to keep giving the program different number...
true
eeea04b824760487be3cfc09254e981758c4f88a
smi7hy96/python
/python/LearningObjectives/data_types_&_operator.py
2,011
4.375
4
# STRINGS # QUOTATIONS # single_quotes = ' Look! Single Quotes' # cannot use apostrophe as it ends string # print(single_quotes) # # double_quotes = " It's Double quotes" # can use apostrophe without issue # print(double_quotes) # # single_apost = ' I said \'Wow!\'' # backslash escapes string to use apostrophe wit...
true
bd443f92a996161f2dd94b7ccfc746c925a6e332
sravi97/D590-Intro-to-Python
/Module 11/A11_Q3.py
999
4.15625
4
#Sreeti Ravi #11/8/2020 #Question 3 #Use numpy and matplotlib to produce a plot of the function f(x) = e−x/p sin(πx) #over the interval [0, 10], for the values of the parameter p = 1, 2, 5. Include #name of the plot, labels for the x- and y-axes, and a legend that identifies #the lines by their color. import m...
true
c0da2797be002339dec299b221daf43aa2589678
sravi97/D590-Intro-to-Python
/Module 11/A11_Q2.py
714
4.15625
4
#Sreeti Ravi #11/8/2020 #Question 2 #Use Pandas and matplotlib to produce a scatter plot of weights versus heights. #Include the name of the plot and labels for the horizontal and vertical axes import matplotlib.pyplot as plt import pandas as pd def main(): #read the Excel file xls_file = pd.ExcelF...
true
6415d9678859dafeaef9a7cbdc2e78469fc0df76
sravi97/D590-Intro-to-Python
/Module 4/Assignment 4/question_1.py
559
4.28125
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 19 15:31:21 2020 @author: sreet """ #Sreeti Ravi #9/19/2020 #Question 1 #Write a program that takes an input string from the user and prints the string #in a reverse order def main(): print("The program prints a string in a reverse order") s...
true
c04244e607b08d334cdeef7a5747945e08aa8aa6
sravi97/D590-Intro-to-Python
/Module 2/Assignment 2/question1.py
472
4.21875
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 3 00:34:25 2020 @author: sreet """ #Sreeti Ravi #9-3-2020 #Question 1 #Write a program that prompts the user for the distance in kilometers, converts #and prints the distance in miles. One km is ~0.62 miles. def main(): print("The program converts kil...
true
d9b9d04d8c72512f7f0dcf15a4328ef8af2ecf0f
scascar/hadoop
/exercise.py
1,602
4.15625
4
#!/usr/bin/python #implementation of the map function def map(rowIndex,line): returnDic = {} # the return pairs (k,v) elements = line.split(',') #we split the line into elements by ',' separator (from the csv file) #iterate through each element of the line (the row) #the key will be the index of the ...
true
153d07215fa1ff93081dc493e3b48d8c41102ae9
mandyosuji/ATBS-excersises
/collatzSeq2.py
449
4.40625
4
def collatz(number): if number % 2 == 0: return number // 2 if number % 2 == 1: return 3 * number + 1 gotInt = False while not gotInt: userInput = input("Enter Number:\n") try: userInt = int(userInput) gotInt = True except ValueError: print("You must enter an...
true
60e80088e00f2f1d8c2f07fa501e07481ab5c336
kanhaiya38/ppl_assignment
/1.Python/4.py
821
4.375
4
""" 4. Make a program that randomly chooses a number to guess and then the user will have a few chances to guess the number correctly. In each wrong attempt, the computer will give a hint that the number is greater or smaller than the one you have guessed. """ import random random_num = rando...
true
970fa20854a26d2950f77732251db03c1e8b848c
llekcevi/practicepython.org
/exercise-8.py
1,959
4.15625
4
"""Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game) Remember the rules: Rock beats scissors Scissors beats paper Paper beats rock""" def p...
true
060a2e6f99aac2dafe40f009c205f21d0f71b4ce
prki/Follow_the_white_rabbit
/symbol_prime.py
1,051
4.1875
4
""" Module containing functions which are used as a part of the solution. Contains the mapping between symbols and prime numbers and other relevant functions. """ PRIME_MAPPING = {' ': 1, # Anagram contains whitespace - multiplying by 1 'a': 2, 'b': 3, 'c': 5, ...
true
fc19f9dc8a101675c16ba8a54c5edb436748ff9f
kelvin-muchiri/search-index
/search.py
2,450
4.21875
4
"""Search a value in a collection and return index of first occurrence.""" import unittest ORIGINAL_INDICES = {} def get_list_original_indices(alist): """Store the original array indices.""" for i in range(len(alist)): # Only store the index of the first occurrence if not alist[i] in ORIGINAL...
true
d542b140a89721da6c54e89aac7c83b49c08ba52
isakss/Forritun1_Python
/lower_of_three.py
432
4.40625
4
#This program takes three integers from user input and then states which of them is the largest int_1 = int(input("Enter first number: ")) int_2 = int(input("Enter second number: ")) int_3 = int(input("Enter third number: ")) min_int = 0 if int_1 < int_2 and int_1 < int_3: min_int = int_1 elif int_2 < int_1 and ...
true
13a7919d832fce4e6f34959fc9260401266fd262
isakss/Forritun1_Python
/midterm_list_exercise8.py
996
4.4375
4
""" This program allows the user to create a list of designated size, input size many elements into the list, and then creates a new list without duplicate values. All non numeric values are ignored. """ def populate_list(int_object): new_list = [] while len(new_list) != int_object: try: li...
true
3212d678f279e2ea1e4687d7ef3398d06ddf02d1
isakss/Forritun1_Python
/passwords.py
2,452
4.46875
4
#This program allows users to create passwords until they enter the letter q, the program #should only allow passwords of length 6 to 20 that contain at least one lowercase letter, one uppercase letter and one number #the program counts the total amount of passwords created, how many of them were valid and how many wer...
true
fd671455aae8fae94ce1e0a875e9251e52647d57
isakss/Forritun1_Python
/midterm_list_exercise5.py
948
4.375
4
""" This program allows the user to input as many values into a list as the user dictates and then finds the lowest element from that list. The program ignores values that are not of type int. """ def populate_list(int_object): new_list = [] while len(new_list) != int_object: list_element = input("Ente...
true
b628fa0dbf90fdb9f93983460ebb2b6bc59da954
isakss/Forritun1_Python
/max_int.py
1,156
4.4375
4
#This program takes in a series of positive integers from user input #until a negative integers is entered, at which point the program stops running and outputs the highest integer #Input vatriables from the user num_int = int(input("Input a number: ")) max_int = 0 #we want to create a variable that will store the ...
true
5be817883d54bd198579db86be9aade25b3b1be2
jmperafan/ride-the-bus
/setup.py
1,865
4.3125
4
# Possible answers not_valid = "That's not a valid answer, drink one either way" win = "You were right, choose somebody to drink" lose = "You were wrong, take one sip" # Instructions round1 = """In round 1 you guess if the color of the card is black or red. Simple, right? If you make a typo or answer something else yo...
true
312792f3056f27df694054b1f844f4c73261ce2c
abbott34/FinancialAnalysisProj
/AidanPractice/DominoQuestion.py
816
4.34375
4
''' https://www.youtube.com/watch?v=9Q73ScVu2GI Above is the link to the question. Stop watching the video at 3:30, that is as much as you need to know. If you watch more then I think he gives away the solution but idk, I haven't watched that far lol. Row a is the top half of the domino while row b is the bottom ...
true
b979ae83e370d92d5ce50b1839ea6d8157284026
dlordtemplar/python-projects
/Files/calc.py
2,152
4.125
4
''' Implement a calculator for simple arithmetic expressions in revese polish notation. (4 points) The reverse polish notation notation Reverse Polish notation (RPN) is a mathematical notation in which every operator follows all of its operands. It is also known as postfix notation and does not need any parenthes...
true
188a3e0032a1e123ea112bc8e2685228c60eb011
dlordtemplar/python-projects
/Control Structures/gcd.py
903
4.15625
4
""" Implement the Euclidean algorithm for computing the greatest common divisor of to given numbers m and n, i.e., the largest integer by which both m and n are divisible without remainder. (2 Points) Algorithm: (a) Compute the remainder of m divided by n. (b) In each step: divide divisor of previous step by remain...
true
ebcdb3ad52c242a465134ac122eaf3d16d7f9cce
dlordtemplar/python-projects
/Functions 2/sort.py
1,666
4.375
4
''' Modify the naive implementation (see below) of a sorting algorithm so that the list to be sorted is modified *in place*. (4 Points) Here is the idea: 1. Iterate over all indices i = 0, 1, 2, ... of the input list 2. Find the index j of the smallest element in the rest of the list (from i on) 3. Replace the el...
true
519e372db27ffd905044069fff2117c9943348df
dlordtemplar/python-projects
/Iterators/myEnumerate.py
2,204
4.1875
4
###################################### # Introduction to Python Programming # # WS 2013/2014 # # Iterators # ###################################### ''' EXERCISES 1 Reimplement the builtin "enumerate." Each call of the "next" method should return a pair (tuple) containing...
true
a98a040f1cd75722fc4b1a87052747c45d7ec8e1
Shokir-developer/python_projects_beginner
/Email_Slicer/slicer.py
293
4.1875
4
email = input("Enter your email address: ") if '@' in email and '.com' in email: user_name = email[:email.index('@')] domein_name = email[email.index('@')+1:] print(f"Your user name is {user_name} and your domain name is {domein_name}") else: print("Please enter your email correctly")
true
912084799758ac78c2ffdd2c67549620a89ac9b2
aminuolawale/Data-Structures-and-Algorithms-in-Python-exercises
/Chapter 1 - Python primer/projects/P-1.32__Calculator__.py
1,044
4.59375
5
#Write a Python program that can simulate a simple calculator, using the console as the exclusive input and output device. # That is, each input to the calculator, be it a number, like 12.34 or 1034, or an operator, like + or =, can be done on # a separate line. After each such input, you should output to the Python ...
true
bc0c6af83faeb9060108f25db1187dc61fea846b
aminuolawale/Data-Structures-and-Algorithms-in-Python-exercises
/Chapter 2 - Object Oriented Programming/solutions/projects/P-2.34__CharFrequency__.py
778
4.125
4
#Write a Python program that inputs a document and then outputs a barchart plot of the frequencies of each alphabet # character that appears in that document. import matplotlib.pyplot as plt; plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt def count_char(c, doc): count = 0 for letter in d...
true
250e667c3b97792bca6833ab70c17be7b8572bf4
aminuolawale/Data-Structures-and-Algorithms-in-Python-exercises
/Chapter 1 - Python primer/reinforcement/R-1.3__minMax__.py
536
4.125
4
# Write a short Python function, minmax(data), that takes a sequence of one or more numbers, # and returns the smallest and largest numbers, in the form of a tuple of length two. Do not # use the built-in functions min or max in implementing your solution. def minmax(data): smallest = largest = data[0] for e...
true
04df94dd87b313daa54be42e2d46e0eda1d36758
aminuolawale/Data-Structures-and-Algorithms-in-Python-exercises
/Chapter 1 - Python primer/projects/P-1.30__Divideby2__.py
333
4.28125
4
#Write a Python program that can take a positive integer greater than 2 as input # and write out the number of times one must repeatedly divide this number by 2 before getting a value less than 2. def div_by_two(number): count=0 while number >= 2: number/=2 count+=1 return count print(d...
true
a916b5c579059d347b2f5c5c07d187ae2fc95d09
yipcrystalp/MyExercises
/ex36.py
1,759
4.1875
4
from sys import exit import random food = [['Sushi', 'Japan'], ['Curry', 'India'], ['Currywurst', 'Germany'], ['Peking Duck', 'China'], ['Tom Yum Soup', 'Thailand'], ['Hotdog', 'USA']] food_answered = [] def get_random_food_and_foodco(): randint = random.randint(0, foodCount-1) food = foods[randint][0] ...
true
eebd49957c64d8aa88a56ab3807105fec9a5c713
pkenaudekar/NPTEL_python_course_work
/Assignment-26 Special Character.py
480
4.4375
4
""" Given a string S, check whether it contains any special character or not. Print 'YES' if it does else 'NO'. Input Format: The first line contains the string S Output Format: Print 'YES' or 'NO' Example: Input: Hi$my*name Output: YES """ #CODE: S=input() output='NO' for char in S: if not((char ...
true
6cac1356771a74e3377c365552a37a95f74385a1
maria-shnaider/homeworks
/copy.py
1,823
4.21875
4
def count(elements): element_count = input("Enter the number of elements: ") def wrong_element(): print("Enter any number starting from {}".format(elements)) return count(elements) if not element_count.isdigit(): return wrong_element() else: if int(element_count) < elemen...
true
fc4a544e2990e6df4ae60e22e4cb3799a44f3db1
eckesm/18_python_ds_practice
/09_is_palindrome.py
836
4.1875
4
def is_palindrome(phrase): """Is phrase a palindrome? Return True/False if phrase is a palindrome (same read backwards and forwards). >>> is_palindrome('tacocat') True >>> is_palindrome('noon') True >>> is_palindrome('robert') False Should ignore capi...
true
50597d42b33d938262c2bcc629f4cef3c40ee5f2
michael-mck-doyle/python_v2
/python_fundamentals-master/06_functions/06_01_tasks.py
1,145
4.1875
4
''' Write a script that completes the following tasks. ''' # define a function that determines whether the number is divisible by 4 or 7 and returns a boolean # define a function that determines whether a number is divisible by both 4 and 7 and returns a boolean # take in a number from the user between 1 and 1,000...
true
ba5e9f87f735c0c9e3cf77eef58a3d5267eb5588
michael-mck-doyle/python_v2
/python_fundamentals-master/01_python_fundamentals/01_01_run_it.py
1,176
4.4375
4
''' 1 - Write and execute a script that prints "hello world" to the console. 2 - Using the interpreter, print "hello world!" to the console. 3 - Explore the interpreter. - Execute lines with syntax error and see what the response is. * What happens if you leave out a quotation or parentheses? * How h...
true
824fcdb3edf966da0003354cf2b4e99b7b38d004
michael-mck-doyle/python_v2
/python_fundamentals-master/02_basic_datatypes/1_numbers/02_01_cylinder.py
449
4.25
4
''' Write the necessary code to calculate the volume and surface area of a cylinder with a radius of 3.14 and a height of 5. Print out the result. ''' import math radius = 3.14 height = 5 volume_cylinder = (math.pi * radius**2 * height) surface_area_cylinder = 2 * math.pi * radius * (height+radius) print(("Cylind...
true
30e80fd965ee0927c728270da24ac4cd83526fc9
KyleXiong0913/Fintech
/Q2.py
2,323
4.3125
4
# Solutions as below # 1. we divide the customers into 3 segments, # 2. The reason we have 3 segments are because # we assume customers can be have main goals on House, Travel and Car # based on their HG Time (Months), TG Time (Months) and CG Time (Months) # 3. Use knn (k nearest neighbors) algorithm to do the cla...
true
f81e7e5eb893a1f1080a9e36450957677319835f
svitlnamaks/beetroot_homework
/task2.py
674
4.1875
4
# Task 2 # Exclusive common numbers. # Generate 2 lists with the length of 10 with random integers from 1 to 10, # and make a third list containing the common integers between the 2 initial lists without any duplicates. # onstraints: use only while loop and random module to generate numbers import random as rd list1 =...
true
0e94ecec84a4b477fdb92635bc6a4df340e18c19
sindredl/code_vault
/exercises/example17.py
1,032
4.28125
4
from sys import argv # The normal thing, needs an argument when started script, input_file = argv # A function is defined with the parameter f, which it will read and print. def print_all(f): print f.read() def rewind(f): f.seek(0) def print_a_line(line_count, f): print line_count, f.readline() # The...
true
c9ae7d06d5c74b4456d09d9b5ef9308eb25a7641
hectorlopezmonroy/HackerRank
/Programming Languages/Python/Strings/sWAP cASE/Solution.py
804
4.5
4
# -*- coding: utf-8 -*- # You are given a string and your task is to swap cases. In other words, convert # all lowercase letters to uppercase letters and vice versa. # # Example: # # Www.HackerRank.com -> wWW.hACKERrANK.COM # Pythonist 2 -> pYTHONIST 2 # # Input Format # # A single line containing a string 'S'. # ...
true
94d63b91cd246e8d16c25fb1fe178de326352c53
hectorlopezmonroy/HackerRank
/Programming Languages/Python/Itertools/itertools-product/Solution.py
1,867
4.15625
4
# -*- coding: utf-8 -*- # [itertools.product()](https://docs.python.org/2/library/itertools.html#itertools.product) # # This tool computes the [cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) # of input iterables. # # It is equivalent to nested for-loops. # # For example, product(A, B) returns the ...
true
469ed514aef0171b03f8fedeb7e1a05722a6f154
hectorlopezmonroy/HackerRank
/Programming Languages/Python/Introduction/Write a function/Solution.py
1,517
4.40625
4
# -*- coding: utf-8 -*- # We add a Leap Day on February 29, almost every four years. The leap day is an # extra, or intercalary day and we add it to the shortest month of the year, # February. # # In the Gregorian calendar, three criteria must be taken into account to # identify leap years: # # * The year can be eve...
true
415fd8f02ca9bc2b5da28303a3129e9dfbd9b5f1
Mergimberisha/Python
/Python_variable.py
856
4.15625
4
# print("Hello World") # # # first_name = "Mergim" # last_name = "007" # full_name = first_name + last_name # new_name = full_name # print(full_name) # # # favorite_color = "Red " # favorite_car = "Audi" # Dream_car = favorite_color + favorite_car # print(Dream_car) # print(type(Dream_car)) # # print("What is your firs...
true
b7c39ff5b6d6f307f84156987ac800b5b734619d
sivaramdatta/ProblemSolving
/insert_position.py
1,441
4.21875
4
""" Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. """ class Solution: def searchInsert(self, nums: List[int], target: int) -> int: """ This met...
true
6c552e44b99d2c6bfab94a9e8761ce9ae5e37d6d
shyamshyre/python
/2OPERATORS/3equalityoperators.py
1,337
4.1875
4
# == and != are called Equality Operators # To check the values are qual or not we use equality operators # a=10 # b=20 # print(a==b) # print(a!=b) # Output:: # False # True # print(1==True) # # Output:: True # print(1==1.0) # # Output:: True # print("shyam"=="shyam") # # Output:: True # print(10 == "shyam") # # O...
true
a5d0b07d0b697f1241eb1ec066d065f4be1ef726
ashikurcmt126/python-basic
/OOP/program11.py
808
4.28125
4
# Regular expression import re pattern = "Colour" if re.match(pattern, "Colour is a colour, I love red colour"): print("Match") else: print("Not Matched") if re.search(pattern, "Colour is a colour, I love red colour"): print("Match") else: print("Not Matched") print(re.findall(pattern, "Red is a Colo...
true
928b4e0bb9c54480959aa24a73d32dc1b5e5c8b5
AmyWeiner/think_python
/chapter_10/exercise_10.3.py
213
4.1875
4
# The function middle takes a list, and returns a new list # that contains all but the first and last elements. def middle(list): result = list[1:-1] return result l = [1, 2, 3, 4, 5, 6] print middle(l)
true
5c89c05b290459a5a84604064fb85b33d67ba56f
AmyWeiner/think_python
/chapter_04/exercise_4.2.py
428
4.53125
5
from swampy.TurtleWorld import * world = TurtleWorld() bob = Turtle() print bob # The function square takes a parameter named t, which is a turtle, # and a parameter named length, which is the length of a side. # It uses the turtle to draw a square with a side of length length. def square(t, length): for i in ran...
true
c0a6c75e89ed83519f90f9ff23f37c1da113c133
AmyWeiner/think_python
/chapter_10/exercise_10.5.py
384
4.3125
4
# The function cumulative_sum takes a list of numbers , and # returns the cumulative sum; that is, a new list where the ith # element is the sum of the first i + 1 elements from the original list. def cumulative_sum(list): result = [] sum = 0 for i in list: sum += i result.append(sum) ...
true
578292a03b10f735cc4f8b69621093fa1c39fa5d
raymond234/redi
/lesson_6_oop/l603_more_attributes.py
1,744
4.75
5
# Attributes in different classes are isolated, changing one class does not # affected the other, the same way that changing an object does not modify # another. email = 'contact@redi-school.org' class Student: email = 'student@redi-school.org' def __init__(self, name, birthday, courses): # class p...
true
9c1438a62835dc63df2c321ca4a75332f8d82fae
SeanCCarter/Softdes_Game
/Block_Module.py
1,455
4.125
4
""" This module creates the object type Block, and several subfunctions which generate specific varieties of the Block class. """ import pygame class Block(object): '''Hold all the data about ''' graphics_names = ['tree.png', 'water.png', 'grass.png', 'dirt.png', 'wood.png', 'water.png'] Graphics = {item: pygame...
true
6c700f65cddf7169ad0483dde76abf2b8670bee5
beesmalley/pythonPractice
/madLibs.py
2,557
4.15625
4
#okay, so for funsies lets do a mad libs #first, im going to write up a little story that can have elements replaced #it might go something like: #Dear Jim, Its been a long time since I've seen, I hope you are doing well. I picked up some bread from the bakery #the other day and it was stale when I bought it! I...
true
2616cbd52dedc6c948885dd6bd2608a98c04a205
amitanand/Python-strings
/removencharfromstring.py
318
4.28125
4
# Write a Python program to remove the last character from a nonempty string ? import time str_1=str(input("Please enter a string :")) #n=int(input("Please enter the index no whose character you want to delete :")) x=len(str_1) print("deleting the character ...") time.sleep(1) print("Resulting string :",str_1[:x-1])
true
b7df0db73e94e59088d1b6da9c78719485ae174c
PDXDevCampJuly/michael_devCamp
/python/tokyo_king_testable/monster_class.py
1,864
4.125
4
# Monster with unittest and populated into King of Tokyo game. # https://boardgamegeek.com/boardgame/144790/ANGRY-dice # >>>--------------------------------------------------------> __author__ = 'mw' class Monster(): """ Create a monster based off UML using TDD. """ def __init__(self, name): """ Init...
true
a820b850ca17575e49924cc0bd3e3dfc4a697e8f
harshi93/jupyterNotebooks
/Python-Practice/create-and-instantiate-classes.py
1,171
4.3125
4
# TODO Create Classes class Employee: """ init can be viewed as constructor, we can class instances whatever we want but by convention we should refer them as self Quick Note: pass statement - (the statement is used to simply ignore the code block) instance variable contain data that is unique to...
true
c19d81d4a8e43573e66f207ba7aa2a50c9b2eb33
harshi93/jupyterNotebooks
/Python-Practice/30-days-of-code/day-7-array.py
205
4.21875
4
""" Given an array A print it's elements in reverse order as single line of space separated numbers """ array = [1,2,3,4] #(start, end, step) for i in range(len(array), -1, -1): print(i)
true
000f9865718485ec24dac550e25ceabc2d78191c
mateszegedi/from_spreadsheets_to_pandas
/open_excel_with_skipped_rows.py
1,261
4.25
4
# Loading an excel to pandas, where # only a section of a table has to be loaded # Step 1.) importing libraries to be able to open excel file with Python import pandas as pd import numpy as np # Step 2.) setting the location of excel file. # important: it is generally useful to write it like this r"C:\Users\...." # o...
true
1daec35ee45e1a0f4a4d89d3b71f6a5ee25cf6eb
junkchen/PythonProjects
/HeadFirstPython/Chapter01/PythonList.py
1,583
4.25
4
movies = ["The Holy Grail", "The Life of Brain", "The meaning of Life"] print(movies[1]) cast = ["Cleese", 'Plain', 'Jones', "Idle"] print(cast) print(len(cast)) print(cast[1]) # add date item cast.append("Gilliam") print(cast) # delete last data item cast.pop() print(cast) # 在列表末尾增加一个数据项集合 cast.extend(["Gilliam", ...
true
28dec1bcd48fae7ab1df3c9d5ac2abc24a8eb90a
laohou/Leetcode
/117_Populating Next Right Pointers in Each Node II.py
1,493
4.21875
4
# -*- coding: utf-8 -*- __author__ = 'yghou' """ Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant extra space. For example, Given the following binary tree, 1 ...
true
8dcd84f78646e7873e79e1712b9e14c682981ec6
laohou/Leetcode
/166_Fraction to Recurring Decimal.py
1,504
4.25
4
# -*- coding: utf-8 -*- __author__ = 'yghou' """ Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses. For example, Given numerator = 1, denominator = 2, return "0.5". Given ...
true
254a047927a03dc6315c86be3362171aa6e40fcf
lilongan/Classes
/Wk01'md'py/201014'py/06_user-inputX.py
479
4.25
4
name = input("Name, please:\n") print(f"Hello, {name}.") first_name = input("First name, please:\n") last_name = input("Last name, please:\n") print(f"Hello, '{last_name}' + '{first_name}'.") #needs correction # print('Hi!') # name = input("Name, please: ") # name = input("Name, please:\n") # subject...
true
34f9810d64de2a92c087c978f4fd8d1f4482be1f
MadMerlyn/retirepy
/invest.py
2,012
4.25
4
# -*- coding: utf-8 -*- """ Investment Growth Calculator @author: MadMerlyn """ def Invest(principle, reg_payments, rate, **period): """Principle, + regular (monthly) payments, and rate in APR (eg. 0.08) for period use either 'years=XX' or 'months=XX' --Prints estimated growth schedule based on an...
true
1c618f5b08d19ddc882c38e7a13800353be1738e
pydevsp/classss
/PYTHON_3.8/vs pro/re-2-character class.py
1,941
4.15625
4
# The main intention of Character classes is to search for group of # characters in tarhet string. # EX: # a ----> It will find the match with exactly 'a' # [abc] ----> It will find the match for either a or b or c # [^abc] ---> It will find the match for the elements except a, b anc c. # [a-z] ----> It will find the m...
true
8ee64e01f2e52d626ad6bed05ee361a94e582c68
pydevsp/classss
/PYTHON_3.8/python_class/Operators.py
1,546
4.8125
5
#!/usr/bin/env python # coding: utf-8 # # operators :: # ## Arithmetic Operator:- # # ### + , - , * , ** [Power operator], / , // [Floor Division], % [Modulo] # In[2]: a=10 b=2 print(a) print(b) # In[3]: a+b # In[4]: a-b # In[5]: a*b # In[6]: a/b # In[7]: b/a # In[13]: A=10 B=2 print(...
true
1f328ba08879e29476fb01e75328b4830d0ce048
nixocio/Python
/queue_stdy.py
643
4.125
4
# -*- coding: utf-8 -*- """ Simple study related to Queue """ import queue counter = 0 max_for = 1000 # Example 1 def add_numbers(task_name): global counter for _ in range(0, max_for): print('Executing {}'.format(task_name)) counter += 1 yield if __name__ == '__main__': # Ex...
true
d534d0fb3a11fa6443012df34575949e34b171bd
sokolovdp/netology
/linked_list.py
1,529
4.1875
4
class Element: def __init__(self, data): self.data = data self.next_element = None def get_data(self): return self.data def get_next(self): return self.next_element def set_next(self, new_next): self.next_element = new_next class LinkedList: # but looks lik...
true
1cadaeced2b588792f940f6f1e32a15552970eed
Vinicoreia/AlgoRythm
/python/EPI/advance_by_offsets.py
815
4.25
4
# Suppose you have an array like [3,3,1,0,2,0,1] # every number in the array is the number of steps you can give towards the end of the array # Write a program that returns True if the end can be reached and false if you can not reach the end # In the array of the example [3,3,1,0,2,0,1] you can reach the end by # mov...
true
e1e5644b0cdcae763361cfac7b3c26b367da72a6
nchanay/night-class
/python labs/python practice/practice5.py
674
4.125
4
# Problem 6 # Write a function to move all the elements of a list with value less than 10 to a new list and return it. # # def extract_less_than_ten(nums): # # Problem 7 # Write a function to find all common elements between two lists. # # def common_elements(nums1, nums2): def extract_less_than_ten(nums): return ...
true
4b0e824687ba2cf3b244234fe8e04c0881bb3aed
Lusimba/Math_Python
/Map_Filter_Reduce/map.py
638
4.6875
5
#The map function is used to apply an action to elements in a list or array without #altering the original list, hence resulting in pure functions without side effects. # numbers = [1, 2, 3, 4, 5] # def square (x): # return x**2 # print(list(map(square,numbers))) # print(list(map(lambda x: x**2, numbers))) #We ca...
true
cfa7f04e9c43e16dc6f131793c2164a1d4fa47cd
ASHIQKI/Think-Python
/chapter_14/walks.py
232
4.125
4
''' this function prints name of all the files in a directory ''' import os def walk(dir): for name in os.listdir(dir): path=os.path.join(dir,name) if os.path.isfile(path): print path else: walk(path) walk('ss')
true
57f6f6d9e19c3e870e798fe3e3e02b5c92be05c7
siblackburn/python_bali
/b. lists/recursion.py
766
4.28125
4
''' def print_hello(): for i in range(0,10): print("hello world") print_hello() ''' def print_hello(i): #stopping condition if i == 0: return print("hello world") print_hello(i-1) # here it's then calling itself again. So the first time the function is run it prints with i = 9, a...
true
b5324e46cf7ece9b5debf09d3eaff7d50d84b046
eu-snehagupta/Leetcode
/src/main/easy/valid_parentheses.py
2,307
4.4375
4
# Given a string s 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. # # Example 1: # Input: s = "()" # Output: true # ...
true
884579959fe58d52aa6a7a763e43dc5dcb388764
hicaro/programming-interviews-exposed
/arrays_and_strings/reverse_words.py
861
4.15625
4
""" Write a function that reversts the order of ther words in a string. For example, your function should transform the string "Do or do not, there is no try." to "try. no is there not, do or Do". Assume that all words are space delimeted and treat punctuation the same as letters. """ def reverse_words(sentence): ...
true
b80e682f2b91d2e4c7dbb4f66cdca5e439c55ac1
Cassie07/leetcode1
/3_28_HammingDistance.py
2,114
4.21875
4
'''461. Hamming Distance DescriptionHintsSubmissionsDiscussSolution The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note: 0 ≤ x, y < 231. Example: Input: x = 1, y = 4 Output: 2 Explanat...
true
392a48a87f82d604e8a2371d2b68d303a9b2c550
NilashishC/sorting-algorithms
/QuickSort.py
1,103
4.25
4
#!/usr/bin/python3 """ An implementation of Quick Sort Algorithm with Randomized Pivot in Python 3 =========================================================================== Usage : QuickSort.sort(<sequence>) """ from random import randint class QuickSort: @staticmethod def _...
true
09e2fdeeae0b9f3d5fcea43691959ed5eaf8d17c
gaurav-sharma-113/Practice_problems_HR
/Challenges/Warmup/counting_valleys.py
2,170
4.75
5
# Counting Valleys # # An avid hiker keeps meticulous records of their hikes. # During the last hike that took exactly 'steps' 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 1 unit change # in a...
true
3dc585977c33cbb94638921729878785769e0327
EzequielZapata/CIS2348
/Homework#1/3.18main.py
1,145
4.40625
4
# Ezequiel Zapata PSID: 001863257 # part 1 to prompt to input a wall's height and width and calculate the wall's area. wall_height = input('Enter wall height (feet):\n') wall_width = input('Enter wall width (feet):\n') print('Wall area: {:d} square feet'.format(int(wall_width) * int(wall_height))) # part 2...
true
9129f504f81d05d75562259379a10f71a519ea31
EzequielZapata/CIS2348
/Homework-2/Coding_Problem_2a.py
1,943
4.5
4
# Ezequiel Zapata PSID: 001863257 # We will take input from the user and return date if input date is in correct format, else will return empty string def extract_date(date): correct_date = 0 new_date = "" if date.find(",") != -1: month_day, year = date.split(',') if month_day.find(...
true
1ecfbc8681de8c7d95ffdaac2a2d15a4537753c7
EzequielZapata/CIS2348
/homework-3/10.17main.py
1,288
4.125
4
# Ezequiel Zapata PSID: 001863257 # part 1 creating a class for items to purchase by item name, price, and quantity class ItemToPurchase: def __init__(self): self.item_name = "none" self.item_price = 0 self.item_quantity = 0 def print_item_cost(self): print(self.item_...
true
e141f2cc04bee999f64e9cc1451f821c3f94e261
gkarthiks/python-learning
/string.py
580
4.125
4
name = "GKarthikeyan" print(name[0]) print(name[1:12]) print((name+'\t')*2) print("a" in name) print(r"This is to print \n") a = "String" b = 10 print'%s is the string and %d is the number' % (a,b) print(name[:7]) oldStr = "Old String" newStr = oldStr.replace("Old", "New") print oldStr print newStr oldStr = ol...
true
85d2a7658d81f77ad966cea819946d24fa993437
JChemtai123/training101
/exercise2.py
757
4.25
4
tasklist= [23, "Jane",["Lesson 23",560,{"currency":"KES"}], 987,(76,"John")] print(tasklist) # 1. determine the type of variable tasklist using an inbuilt function # 2. print Kes # 3. print 560 # 4. use a function to determine the length of tasklist # 5. change 987 to 789 using an inbuilt function # 6. change name "Jo...
true
ada02ae081860490a39f25c41bc0a3012a3e2106
JChemtai123/training101
/conditionals.py
447
4.15625
4
# prompts user to enter their marks marks= int(input("Enter your marks ")) # if else # if marks >= 350 : # print("congratulations passed") # else: # print("sorry failed") # grading system average= marks/5 if average >= 80 and average <= 100: print("A") elif average >= 70 and average < 80: print("B") el...
true
27721ace1bf8a129ccb7a303684758c135bca5fc
satyar3/PythonLearning
/PythonPractice/DictionaryConcept.py
857
4.25
4
# Stores data in key value pair # key should be immutable type data = {"name1": "satya", "name2": "peter"} print(data) # getting a value based on key print(data["name1"]) print(data.get("name2")) # if we want to print something when there is not data present for that key print(data.get("name2", "not found")) print(da...
true
5020a34649bd2fa5b7e0299cc4f8a9c5844f139c
satyar3/PythonLearning
/PythonPractice/ToStringConcept.py
574
4.15625
4
#String reprentation of objects class Test: def __init__(self, x, y): self.x = x self.y = y #represenation of object def __repr__(self): return f"value is x is {self.x} and y is {self.y}" #similar to to string def __str__(self): return f"the value is x is {self.x}...
true
44c0ababbf510e980f4bf2d78fd60109c4c90158
satyar3/PythonLearning
/PythonPractice/IfElseConcept.py
358
4.1875
4
#Taking the value during run time x = int(input("Please enter the value of x : ")) print(x) if(x<1): print("x is less than 1") elif(x>2 and x<5): print("x is more than 2 and less than 3") else: print("x is more than 5") #logical opeartions "and" "not" "or" total = 3 print("total : "+str(total)) print(f'{...
true
7b9467779f17594c7a570f3184f7b14a3594bc9c
B-Simms/Python
/Get_Prime_Factors/get_prime_factors
1,498
4.125
4
#!/usr/bin/env python # Created by Blake Simmons # Version 1.0 from typing import List, Any def get_lowest_divisor(num, primes_list=[]): primes = primes_list divisor_range = int((num / 2) + 1) if num != 2: is_divisible = False for divisor in range(2, divisor_range): if num % di...
true
f98015fc8effccc37b8958e5d80fc575372ec460
lfntchagas/python-study
/generator.py
751
4.3125
4
# def create_cubes(n): # result = [] # for x in range(n): # result.append(x**3) # return result # cubes_list = create_cubes(10) # print(cubes_list) #Instead of create a list and hold it in memory, you yield and just see the last number. It's way more efficient. def create_cubes(n): for x ...
true
9914fa4551df0be78d0c9987344a6c0f3b98d21f
shiraz-30/Intro-to-Python
/Python/Python_concepts/forloops.py
571
4.4375
4
# How to use for loops # (start, end, inc) -> start, start + inc, start + 2*inc, ...., end - inc # for loops range means [a, b) for i in range(0,3): print(i) print("for loops += 2") for i in range(0,10,2): print(i) print("for loops with single arg in range") for i in range(9): # it will take start as 0 and end ...
true
cd3f46e6a7c1e9ffaf3130831d7011aed651657a
sunbee/PyHardWay
/chapter_29_ex2.py
937
4.125
4
people = 20 cats = 30 dogs = 15 if people < cats: print "Too many cats! Cull 'em!" if people > cats: print "The world is a bring place. Breed 'em!" if people < dogs: print "There's drool all over. Neuter the punks." if people > dogs: print "Break out beer. Why not?" dogs += 5 if people >= dogs: ...
true
620ffca331f5f11528c09886bca92cc312b7e4af
JenniferWang/PythonPractice
/generator.py
1,704
4.5625
5
# generator/ iterator practice # When the generator function is called, the interpreter will stop # at the yield/return and "return" the value. The next time when # the generator is called, it will start from the last pause spot # and continue interpreting the remaining codes. # 1. try to convert [[1,2],[3,4],[5,6]]...
true
8173779ff68fd700a3ff11813d1620283581af06
VaibhaviRaut/Python
/multiple(512)_bitwise.py
861
4.4375
4
#!C:Users\Vaibhavi Raut\AppData\Local\Programs\Python\Python37 ''' WAP to check whether the given number is a multiple of 512 using bitwise operations. ''' def check(n): if(n&7)==0: return True else: return False def main(): n = eval(input("Enter a number: ")) if(chec...
true
7a88ffd28d5bc1b069421ed670607f0935b695cc
anamendes23/PythonSamples
/Basic Structures/strings.py
2,823
4.375
4
# string: data type used to represent a piece of text name = "Sasha" color = 'gold' print("Name: " + name + ", Favorite color: " + color) print("example"*3) pet = "looooooooooooooong cat" print(len(pet)) # Parts of a string # String indexing name = "Jaylen" print(name[1]) # print last character print(name[len(name)-1...
true
14cd9c48515cb38f3dbe386d29fd608b7e40a059
kkris/amazes
/src/generator/graph.py
2,279
4.15625
4
class Node(object): """ A class representing a node with specific coordinates. """ def __init__(self, x, y, edges=None, value=None): self.x = x self.y = y self.value = value if edges: self.edges = edges else: self.edges = [] def ad...
true
82d6213b153ffacb8109c36274da6d942e80eff3
ravi4all/Python_WE_Jan_2
/PythonBasics/TakingInput.py
358
4.125
4
##num_1 = input("Enter first number : ") ##num_2 = input("Enter second number : ") ## ##result = int(num_1) + int(num_2) ## ##print("Result is",result) first_name = input("Enter first name : ") last_name = input("Enter last name : ") print("Hello " + first_name.capitalize() + " " + last_name.capitalize()) ...
true
968d38a80e510d10555a662cfd210060286a7bc0
arittrosaha/CS_and_Algorithms
/epi_study/6_strings/1.py
1,520
4.34375
4
# Interconvert strings and integers # Prompt: # An integer to string and a string to integer conversion function. # Example: # If input is 314, output is "314" # if input is "314", output is 314 def conversion(input): def string_to_int(string): char_digits = list(string) str_int = { ...
true
4bebc473c5b3814a1660f85a89236b7614d561b6
arittrosaha/CS_and_Algorithms
/epi_study/12_hash_tables/1.py
656
4.1875
4
# Test for Palindromic Permutations # Prompt: # a program to test whether the letters forming a string can be permuted to form a palindrome # Example: # Input - "edified" # Output - true ; "deified" import collections def can_form_palindrome(s): # Time: O(n), n - number of chars ; Space: O(c), c - number of uniqu...
true
34a1030a5bd9135b51bbc861c1c0f433957642dc
khairislama/PythonLittleProjects
/Calculator/calculator.py
631
4.25
4
print(" *** WELCOME TO CALCULATOR *** ") num1=None num2=None while num1==None: try: num1 = float(input("Enter your first number : ")) except: print("Please enter a valid number! ") while num2==None: try: num2 = float(input("Enter your second number : ")) except: print("P...
true
b3f3651ba8fe80328ea0381a8d62f1497bb2ba72
khairislama/PythonLittleProjects
/Factorial-calculator-of-a-number/factorial.py
508
4.4375
4
print(" *** WELCOME TO FACTORIAL CALCULATOR *** ") num=None def factorial(num): if num == 1: return num else: return num * factorial(num-1) while num==None: try: num = int(input("Enter you number to calculate factorial : ")) except: print("Please enter a valid number! ")...
true
ee34cb08365877b9cc014df5f5bdcc0478b88063
omoshalewa/SCA_Projects
/armstrongNumber.py
631
4.21875
4
def armstrong(): number = int(input("Enter number: ")) number_len = len(str(number)) if number <= 1: print("Enter a number greater than 1") elif number_len == 1: print("All single numbers are Armstrong numbers") else: sum_total = 0 for digit in str(number): ...
true
cb7e917acf0b0ddb9937e012cf2cb638291ed1a6
miaow1/e1006s18
/CodeSamples/SimpleExamples/common_words.py
2,822
4.15625
4
import string import re import re def get_words_from_file(f_name, min_l): """ Reads a text file and returns a list with each word in the file. :param f_name: name of the text file. :param min_l: Minimum length of words that should be in result. :return: List of each word. """ result = N...
true
4db456c20db3317e0d20deae616fedcd256a6ce0
decadevs/use-cases-python-lere01
/generators.py
1,156
4.46875
4
# Document at least 3 use cases of generators """ Generators are functions (expression/comprehension) that return lazy iterators which although are like lists do not store their content in memory. This makes generators useful when dealing extremely large files or infinite sequence. They are also commonly used to cre...
true