blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
2f69b2620798d10de0b6eb730ee28e82cb032a67
vikky1993/Mytest
/test3.py
1,997
4.34375
4
# Difference between regular methods, class methods and static methods # regular methods in a class automatically takes in instance as the first argument and by convention we wer # calling this self # So how can we make it to take class as the first argument, to do that we gonna use class methods #just add a decor...
true
6b66cbbdb06804c86c757ca97397895a314ecfeb
RamaryUp/hackerrank
/Python/sets/symmetric_difference.py
1,060
4.28125
4
''' HackerRank Challenge Name : Symmetric Difference Category : Sets Difficulty : easy URL : https://www.hackerrank.com/challenges/symmetric-difference/problem Given sets of integers, and , print their symmetric difference in ascending order. The term symmetric difference indicates those values that exist in either ...
true
ef64e4a52c2f1f0d14755358ba29b6f945a86336
SinghTejveer/stepic_python_in_action_eng
/solutions/s217.py
713
4.25
4
"""Given a real positive number a and an integer number n. Find a**n. You need to write the whole program with a recursive function power(a, n). Sample Input 1: 2 1 Sample Output 1: 2 Sample Input 2: 2 2 Sample Output 2: 4 """ def solve(num: float, exp: int) -> float: """Calculate num*...
true
99f3382c8b97ce2f4195f6ac93d9712d662cace5
SinghTejveer/stepic_python_in_action_eng
/solutions/s005.py
1,065
4.15625
4
# pylint: disable=invalid-name """Difference of times Given the values of the two moments in time in the same day: hours, minutes and seconds for each of the time moments. It is known that the second moment in time happened not earlier than the first one. Find how many seconds passed between these two moments of time...
true
85288d85c45185c3505ac16f9fc76d02459e83a3
SinghTejveer/stepic_python_in_action_eng
/solutions/s080.py
423
4.1875
4
""" Write a program, which reads the line from a standard input, using the input() function, and outputs the same line to the standard output, using the print() function. Please pay attention that you need to use the input function without any parameters, and that you need to output only that, what was transferred to ...
true
8c3ed77439371b18c45e60d0c1623efa5e2570c7
bthuynh/python-challenge
/PyPoll/main.py
2,879
4.125
4
# You will be give a set of poll data called election_data.csv. # The dataset is composed of three columns: Voter ID, County, and Candidate. # Your task is to create a Python script that analyzes the votes and calculates each of the following: # The total number of votes cast # A complete list of candidates who receive...
true
8a4876cd4aae26f15d9673aac9fdf90aa58b573c
peltierchip/the_python_workbook_exercises
/chapter_1/exercise_17.py
787
4.1875
4
## #Compute the amount of energy to achieve the desired temperature change H_C_WATER=4.186 J_TO_KWH=2.777e-7 C_PER_KWH=8.9 #Read the volume of the water and the temperature change from the user volume=float(input("Enter the amount of water in milliliters:\n")) temp_change=float(input("Enter the value of the temperature...
true
1e0ed285d5f8797eab8da2e8bd076f1c7078185a
peltierchip/the_python_workbook_exercises
/chapter_2/exercise_49.py
894
4.40625
4
## #Determine the animal associated with the inserted year #Read the year from the user year=int(input("Enter the year:\n")) #Check if the year is valid if year>=0: #Determine the corresponding animal and display the result if year%12==8: animal="Dragon" elif year%12==9: animal="Sn...
true
4878ceeb7108bd2885a2fccdce8abb5312be586d
peltierchip/the_python_workbook_exercises
/chapter_8/exercise_184.py
1,378
4.59375
5
## # Perform the flattening of a list, which is convert # a list that contains multiple layers of nested lists into a list that contains all the same elements without any nesting ## Flatten the list # @param data the list to flatten # @return the flattened list def flattenList(data): if not(data): return d...
true
5d8a7606ac90a78fb1303d7f7e93c1be4e9aa563
peltierchip/the_python_workbook_exercises
/chapter_5/exercise_115.py
995
4.5
4
## #Determine the list of proper divisors of a positive integer entered from the user ##Create the list of proper divisors # @param n the positive integer # @return the list of proper divisors def properDivisors(n): p_d=[] i=1 #Keep looping while i is less or equal than about half of n while i<=(n//2): ...
true
8312a957ec2cc7de0eacaa4fda57e20f04689b70
peltierchip/the_python_workbook_exercises
/chapter_5/exercise_120.py
785
4.1875
4
## #Display a list of items formatted ##Formatting items in a list # @param l the list # @return a string containing the formatted elements def formattingList(l): i=0 n_l=l if len(l)==0: return "No items have been entered." if len(l)==1: return str(l[i]) delimeter=" " n_s="" ...
true
1d460dae11b9cf1493fa428c3d32e07fcf3910d8
peltierchip/the_python_workbook_exercises
/chapter_4/exercise_95.py
1,319
4.3125
4
## #Capitalize a string entered from the user ##Capitalize the string # @param string the string to capitalize # @return the string for which the capitalization has been realized def capitalize_it(string): c_string=string i=0 while i<len(string) and c_string[i]==" ": i=i+1 if i<len(string): ...
true
029562d3c3a05977df813e73fbda14bf86927683
peltierchip/the_python_workbook_exercises
/chapter_8/exercise_181.py
1,233
4.125
4
## # Determine whether it is possible to form the dollar amount entered by # the user with a precise number of coins, always entered by the user from itertools import combinations_with_replacement ## Determine whether or not it is possible to construct a particular total using a # specific number of coins # @param d_...
true
ab065da1c97d276ae71cff4985aa8b33314cf6ee
peltierchip/the_python_workbook_exercises
/chapter_1/exercise_7.py
247
4.1875
4
## #Calculation of the sum of the first n positive integers #Read positive integer n=int(input("Enter a positive integer\n")) #Calculation of the sum s=(n)*(n+1)/2 #Display the sum print("The sum of the first %d positive integers is: %d" %(n,s))
true
b6f80becd1d1f37802a427950c059b41788d2b0d
peltierchip/the_python_workbook_exercises
/chapter_6/exercise_136.py
921
4.71875
5
## # Perform a reverse lookup on a dictionary, finding keys that # map to a specific value ## Find keys that map to the value # @param d the dictionary # @param v the value # @return the list of keys that map to the value def reverseLookup(d,v): # Create a list to store the keys that map to v k_a_v=[] # Check ...
true
c22deedf7d33043df0d14f90d3068ea1776b5f54
peltierchip/the_python_workbook_exercises
/chapter_7/exercise_172.py
1,981
4.15625
4
## # Search a file containing a list of words and display all of the words that # contain each of the vowels A, E, I, O, U and Y exactly once and in order # Create a list to store vowels vowels_list = ["a", "e", "i", "o", "u", "y"] # Read the name of the file to read from the user f_n_r = input("Enter the name of the ...
true
b9a6cb431b02ff057c8ce4aff5a20ae724f78b30
peltierchip/the_python_workbook_exercises
/chapter_5/exercise_111.py
718
4.4375
4
## #Display in reverse order the integers entered from the user, after being stored in a list #Read the first integer from the user n=int(input("Enter the first integer:\n")) #Initialize integers to an empty list integers=[] #Keep looping while n is different from zero while n!=0: #Add n to integers integers.ap...
true
84e1d58ad16f91825fcfb06eac1c1226b61f5e6a
Lycurgus1/python
/day_1/Dictionaries.py
1,220
4.53125
5
# Dictionary student_records = { "Name": "Sam" # Name is key, sam is value , "Stream": "DevOps" , "Topics_covered": 5 , "Completed_lessons": ["Tuples", "Lists", "Variables"] } # Can have a list in a tuple student_records["Name"] = "Jeff" print(student_records["Completed_lessons"][2]) # fetching ind...
true
1467bd581d54b3244d0ed003f2e5a47d0d6e77a7
Lycurgus1/python
/day_1/String slicing.py
567
4.21875
4
# String slicing greeting_welcome = "Cheese world" # H is the 0th character. Indexing starts at 0. print(greeting_welcome[3]) # Gets 4th character from string print(greeting_welcome[-1]) # Gets last character from string print(greeting_welcome[-5:]) # Gets 1st character to last x = greeting_welcome[-5:] print(x) # St...
true
2ecaa40da83339322abdb4f2377cbe44fad0b3b6
Lycurgus1/python
/OOP/Object Orientated Python.py
1,496
4.25
4
# Object orientated python # Inheritance, polymorhpism, encapsulation, abstraction class Dog: amimal_kind = "Canine" # Class variable # Init intalizes class # Give/find name and color for dog def __init__(self, name, color): self.name = name self.color = color def bark(self): ...
true
d9df4158b15accfba5c36e113f383140409ab02a
Lycurgus1/python
/More_exercises/More_Methods.py
2,013
4.21875
4
# From the Calculator file importing everything from Calculator import * # Inheriting the python calculator from the previous page class More_Methods(Python_Calculator): # As per first command self not needed def remainder_test(): # Input commands get the numbers to be used, and they are converted to ...
true
80a11ffa961d83208461d324062f37d9f7b1d830
yesusmigag/Python-Projects
/Functions/two_numberInput_store.py
444
4.46875
4
#This program multiplies two numbers and stores them into a variable named product. #Complete the missing code to display the expected output. # multiply two integers and display the result in a function def main(): val_1 = int(input('Enter an integer: ')) val_2 = int(input('Enter another integer: ')) mul...
true
a5643896a36f24aab394372e73d18e052deb624c
yesusmigag/Python-Projects
/List and Tuples/10 find_list_example.py
710
4.34375
4
"""This program aks the user to enter a grocery item and checks it against a grocery code list. Fill in the missing if statement to display the expected output. Expected Output Enter an item: ice cream The item ice cream was not found in the list.""" def main(): # Create a list of grocery items. grocery_list ...
true
8c4a55fa444dc233b0f11291147c224b0ed1bdb5
yesusmigag/Python-Projects
/List and Tuples/18 Min_and_Max_functions.py
500
4.40625
4
"""Python has two built-in functions named min and max that work with sequences. The min function accepts a sequence, such as a list, as an argument and returns the item that has the lowest value in the sequence.""" # MIN Item my_list = [5, 4, 3, 2, 50, 40, 30] print('The lowest value is', min(my_list)) #display Th...
true
73037324693d0170667f036a2e61fcd1e586895f
yesusmigag/Python-Projects
/File and Files/Chapter6_Project3.py
639
4.125
4
'''Write a program that reads the records from the golf.txt file written in the previous exercise and prints them in the following format: Name: Emily Score: 30 Name: Mike Score: 20 Name: Jonathan Score: 23''' #Solution 1 file = open("golf.txt", "r") name = True for line in file: if name: print("Nam...
true
f735a64f0aa2132efd6a12b57cc812bc87a29444
JaimeFanjul/Algorithms-for-data-problems
/Sorting_Algorithms/ascii_encrypter.py
1,301
4.40625
4
# ASCII Text Encrypter. #-------- # Given a text with several words, encrypt the message in the following way: # The first letter of each word must be replaced by its ASCII code. # The second letter and the last letter of each word must be interchanged. #-------- # Author: Jaime Fanjul García # Date: 16/10/2020 ...
true
bc0c2d7871b4263c62e43cd04d7370fc4657468e
gitsana/Python_Tutorial
/M5-Collections/words.py
1,607
4.5
4
#!/usr/bin/env python3 #shebang # indent with 4 spaces # save with UTF-8 encoding """ Retrieve and print words from a URL. Usage: python3 words.py <URL> """ from urllib.request import urlopen def fetch_words(): """Fetch a list of words from a URL. Args: url: The URL of a UTF-8 text document Returns: A list o...
true
a90012c851cad115f6f75549b331cfa959de532b
JasleenUT/Python
/ShapeAndReshape.py
587
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 3 22:47:26 2019 @author: jasleenarora """ #You are given a space separated list of nine integers. #Your task is to convert this list into a 3X3 NumPy array. #Input Format #A single line of input containing space separated integers. #Output For...
true
a685dfed0946a9c01454d98f65abab97d25f6ce2
StarPony3/403IT-CW2
/Rabbits and recurrence.py
645
4.3125
4
# program to calculate total number of rabbit pairs present after n months, # if each generation, every pair of reproduction-age rabbits produces k rabbit pairs, instead of only one. # variation of fibonacci sequence # n = number of months # k = number of rabbit pairs # recursive function for calculating grow...
true
d9f32b00f9bcaec443b3fc22b1f239333bfb26a3
peterpfand/aufschrieb
/higher lower.py
413
4.65625
5
string_name.lower() #to lower a string .higher() #to higher a string #example: email = input("What is your email address?") print(email) final_email = email.lower() print(final_email) string_name.isLower() #to check if a string id written in lowercase letters .ishigher() #to check...
true
ad26db5b5d0e3e5b8c73c190b88db85b16c8fa3c
sawaseemgit/AppsUsingDictionaries
/PollingApp.py
1,596
4.21875
4
print('Welcome to Yes/No polling App') poll = { 'passwd': 'acc', } yes = 0 no = 0 issue = input('What is the Yes/No issue you will be voting on today: ').strip() no_voters = int(input('What is number of voters you want to allow: ')) repeat = True while repeat: for i in range(no_voters): fname = input(...
true
99a2a83c7059b61e14c054e650e4bb1c221047cd
iroro1/PRACTICAL-PYTHON
/PRACTICAL-PYTHON/09 Guessing Game One.py
699
4.25
4
# Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. import random numGuess= 0 a = random.randint(1,9) end= 1 while (end != 0) or (end != 0): guess = input('Guess a number : ') guess = int(gues...
true
f033cc8e82f2692f55b1531159229168fdb638b9
iroro1/PRACTICAL-PYTHON
/PRACTICAL-PYTHON/12 List Ends.py
293
4.125
4
# Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. def rand(): import random return random.sample(range(5, 25), 5) a= rand() print(a) newList = [a[0],a[-1]] print(newList)
true
cfa6497baa42d0662b46188a4460d47c28e878aa
LemonTre/python_work
/Chap09/eat_numbers.py
1,166
4.15625
4
class Restaurant(): def __init__(self,restaurant_name,cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): print("The name of restaurant is: " + self.restaurant_name.title() + ".") print("The type of restaurant is " + s...
true
a787c4e2a01b88818289586d13c7332a12d8868f
omkar1117/pythonpractice
/file_write.py
993
4.3125
4
fname = input("Enter your First name:") lname = input("Enter your Last name:") email = input("Enter your Email:") if not fname and not lname and not email: print("Please enter all the details:") elif fname and lname and not email: print("Please enter a valid email") elif email and fname and not lname: pr...
true
dddb2bfd290929643eb202396aecd88df6d51e0f
Catering-Company/Capstone-project-2
/Part2/sub_set_min_coin_value.py
1,889
4.75
5
# CODE FOR SETTING THE MINIMUM COIN INPUT VALUE ( CHOICE 2 OF THE SUB-MENU ) # -------------------------------------------------- # Gets the user to input a new minimum amount of coins that the user can enter # into the Coin Calulator and Mutiple Coin Calculator. # There are restrictions in place to prevent the user ...
true
f2725f5d5f4b12d7904d271873c421c99ff2fe9f
MagRok/Python_tasks
/regex/Python_tasks/Text_stats.py
1,627
4.15625
4
# Create a class that: #• When creating an instance, it required entering the text for which it will count statistics. # The first conversion occurred when the instance was initialized. #Each instance had attributes: - lower_letters_num - which stores the number of all lowercase letters in the text #- upper_letters_num...
true
ad88d60e5b4b5ab7c77df24182ec07525e213411
hulaba/geekInsideYou
/trie/trieSearch.py
2,112
4.125
4
class TrieNode: def __init__(self): """ initializing a node of trie isEOW is isEndOfWord flag used for the leaf nodes """ self.children = [None] * 26 self.isEOW = False class Trie: def __init__(self): """ initializing the trie data structure with...
true
0d877b43c404c588ef0dbacd8c93c94b17534359
hulaba/geekInsideYou
/tree/levelOrderSpiralForm.py
1,421
4.1875
4
""" Write a function to print spiral order traversal of a tree. For below tree, function should print 1, 2, 3, 4, 5, 6, 7. spiral_order """ class Node: def __init__(self, key): self.val = key self.left = None self.right = None def spiralOrder(root): h = heightOfTree(root) ltr = F...
true
8bbd84f22d9af1917de39200a00c0a8edeb81a34
hulaba/geekInsideYou
/linked list/deleteListPosition.py
1,403
4.15625
4
class Node: def __init__(self, data): """initialising the data and next pointer of a node""" self.data = data self.next = None class linkedList: def __init__(self): """initialising the head node""" self.head = None def push(self, new_data): """inserting t...
true
1ebf124d42d510c2e60c3c7585c03e0efd6dad18
gnsisec/learn-python-with-the-the-hard-way
/exercise/ex14Drill.py
871
4.21875
4
# This is Python version 2.7 # Exercise 14: Prompting and Passing # to run this use: # python ex14.py matthew # 2. Change the prompt variable to something else entirely. # 3. Drill: Add another argument and use it in your script, # the same way you did in the previous exercise with first, second = ARGV. from sys imp...
true
1804f578c7ff417744edc804043b2016d8bcde4a
paulocuambe/hello-python
/exercises/lists-execises.py
554
4.21875
4
my_list = ["apple", "banana", "cherry", "mango"] print(my_list[-2]) # Second last item of the list my_list.append("lemon") if "lemon" in my_list: print("Yes, that fruit is in the list.") else: print("That fruit is not in the list.") my_list.insert(2, "orange") print(my_list) new_list = my_list[1:] print(n...
true
45ab566c204a9a593871d670c1c0e206fa3949fd
paulocuambe/hello-python
/exercises/dictionaries/count_letter.py
367
4.125
4
""" Count how many times each letter appears in a string. """ word = "lollipop" # Traditional way trad_count = dict() for l in word: if l not in trad_count: trad_count[l] = 1 else: trad_count[l] += 1 print(trad_count) # An elegant way elegant_count = dict() for l in word: elegant_count[l] ...
true
fccfaac6346eaf23b345cd2117cda259fd83ff80
MrinaliniTh/Algorithms
/link_list/bring_last_to_fast.py
1,663
4.15625
4
class Node: def __init__(self, val): self.val = val self.next = None class LinkedList: def __init__(self): self.head = None def create_link_list(self, val): if not self.head: self.head = Node(val) else: temp = self.head while temp...
true
b3f14159120e16453abdbd43687885956393e811
TaylorWhitlatch/Python
/tuple.py
967
4.3125
4
# # Tuple is a list that: # # 1. values cannot be changed # # 2. it uses () instead of [] # # a_tuple = (1,2,3) # print a_tuple # # # Dictionaries are lists that have alpha indicies not mumerical # # name = "Rob" # gender = "Male" # height = "Tall" # # # A list makes no sense to tie together. # # person = { # ...
true
79004d747935ebfc19599a9df859400c47120c7e
PavanMJ/python-training
/2 Variables/variables.py
832
4.1875
4
#!/usr/bin/python3 ## All the variables in python are objects and every object has type, id and value. def main(): print('## checking simple variables and their attributes') n = 12 print(type(n), n) f = 34.23 print(type(f), f) print(f / 4) print(f // 4) print(round(f / 4), end = '\n...
true
fe789098e54d1a7a59573d36fc03a4da0159b552
vuminhph/randomCodes
/reverse_linkedList.py
969
4.1875
4
class Node: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(self, value): self.head = Node(value) def add_node(self, value): ptr = self.head while ptr.next != None: ptr = ptr.next ptr.next = Node(va...
true
a83a1d0e35bed07b1959086aff1ef4f7a872520e
rpayal/PyTestApp
/days-to-unit/helper.py
1,232
4.40625
4
USER_INPUT_MESSAGE = "Hey !! Enter number of days as a comma separated list:unit of measurement (e.g 20, 30:hours) " \ "and I'll convert it for you.\n " def days_to_hours(num_of_days, conversion_unit): calculation_factor = 0 if conversion_unit == "hours": calculation_factor = 24 ...
true
05564cfff12bdf3b73b32f3f4c8b484046ff3d91
PatDaoust/6.0002
/6.0002 ps1/ps1b adapt from teacher.py
2,717
4.125
4
########################### # 6.0002 Problem Set 1b: Space Change # Name: # Collaborators: # Time: # Author: charz, cdenise #================================ # Part B: Golden Eggs #================================ # Problem 1 def dp_make_weight(egg_weights, target_weight, memo = {}): """ Find number of eggs t...
true
6df61f24bfe1e9943ac01de9eec80caad342c8a9
rootid23/fft-py
/arrays/move-zeroes.py
851
4.125
4
#Move Zeroes #Given an array nums, write a function to move all 0's to the end of it while #maintaining the relative order of the non-zero elements. #For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums #should be [1, 3, 12, 0, 0]. #Note: #You must do this in-place without making a copy of the ...
true
85b9bec9a1ceea4ee661b59c7efc82595e30f871
Anand8317/food-ordering-console-app
/admin.py
2,127
4.15625
4
admin = {"admin":"admin"} food = dict() def createAdmin(): newAdmin = dict() username = input("Enter username ") password = input("Enter password ") newAdmin[username] = password if username in admin: print("\nAdmin already exist\n") else: admin.update(newAdmin) ...
true
c9033580121ba38277facb1729565d15a994b8b6
Ani-Stark/Python-Projects
/reverse_words_and_swap_cases.py
419
4.15625
4
def reverse_words_order_and_swap_cases(sentence): arrSen = sentence.split() arrSen = list(reversed(arrSen)) result = list(" ".join(arrSen)) for i in range(len(result)): if result[i].isupper(): result[i] = result[i].lower() else: result[i] = result[i].upper() ...
true
e0857fdba34db0f114bcf7843f844aea775303e7
Villanity/Python-Practice
/Reverse Array/Reverse_Array_while.py
343
4.59375
5
#Python program to reverse the array using iterations def reverse_array (array1, start, end): while (start<=end): array1[start], array1[end] = array1[end], array1[start] start += 1 end -= 1 A = [1, 2, 2 , 3, 4] start=0 end= len(A) -1 print(A) print("The reversed Array is: ") reverse_array(A...
true
fb67e1eff16e1804ecf9c2e4ff0010962bb930c3
guyitti2000/int_python_nanodegree_udacity
/lessons_month_one/lesson_3_FUNCTIONS/test.py
263
4.21875
4
def times_list(x): x **= 2 return x output = [] numbers = [2, 3, 4, 3, 25] for num in numbers: val = times_list(numbers) print(output.append(val)) # this is supposed to iterate through a list of numbers then print out the squares
true
093d56467f6309b099b8e2210efe8ecaca8397eb
shanahanben/myappsample
/Portfolio/week6/article_four_word_grabber.py
564
4.15625
4
#!/usr/bin/python3 import random import string guessAttempts = 0 myPassword = input("Enter a password for the computer to try and guess: ") passwordLength = len(myPassword) while True: guessAttempts = guessAttempts + 1 passwordGuess = ''.join([random.choice(string.ascii_letters + string.digits)for n in ...
true
106ddf889cd1ac1fb1b4e6fe1beef995982c4c31
tajrian-munsha/Python-Basics
/python2 (displaying text and string).py
2,391
4.53125
5
# displaying text #to make multiple line we can- 1.add \n in the string or, 2.use print command again and again.\n means newline. print ("I am Shawki\n") #we can use \t in the string for big space.\t means TAB. print ("I am a\t student") #we can use triple quotes outside the string for newline.For doing that,we can ...
true
0812e177cd0f9b5e766f6f981b4bc1947946fa22
akhilreddy89853/programs
/python/Natural.py
288
4.125
4
Number1 = int(input("How many natural numbers you want to print?")) Count = 0 Counter = 1 print("The first " + str(Number1) + " natural numbers are", end = '') while(Count < Number1): print(" "+str(Counter), end = '') Counter = Counter + 1 Count = Count + 1 print(".")
true
7a9ed1b59eca36822827d20359aa1b1eb9292d52
JeRusakow/epam_python_course
/homework7/task2/hw2.py
1,861
4.4375
4
""" Given two strings. Return if they are equal when both are typed into empty text editors. # means a backspace character. Note that after backspacing an empty text, the text will continue empty. Examples: Input: s = "ab#c", t = "ad#c" Output: True # Both s and t become "ac". Input: s = "a##c", t = ...
true
f226cabe15ea1b978dcb8015c040575394d90fbf
JeRusakow/epam_python_course
/tests/test_homework1/test_fibonacci.py
1,083
4.125
4
from homework1.task2.fibonacci.task02 import check_fibonacci def test_complete_sequence(): """Tests if true sequence starting from [0, 1, 1, ... ] passes the check""" test_data = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] assert check_fibonacci(test_data) def test_sequence_fragment(): """Tests if tru...
true
95bdedbc353d1b86f536777b28f8fca63990d8bc
kevindurr/MOOCs
/Georgia Tech - CS1301/Test/6.py
1,693
4.21875
4
#Write a function called are_anagrams. The function should #have two parameters, a pair of strings. The function should #return True if the strings are anagrams of one another, #False if they are not. # #Two strings are considered anagrams if they have only the #same letters, as well as the same count of each letter. F...
true
622b856988a7621b09fca280ba2564a593df37e1
kevindurr/MOOCs
/Georgia Tech - CS1301/Objects & Algos/Algos_5_2/Problem_Set/5.py
1,403
4.375
4
#Write a function called search_for_string() that takes two #parameters, a list of strings, and a string. This function #should return a list of all the indices at which the #string is found within the list. # #You may assume that you do not need to search inside the #items in the list; for examples: # # search_for_st...
true
a7b544425be8d629667975fc19983028bbe51136
Ebi-aftahi/Files_rw
/word_freq.py
735
4.125
4
import csv import sys import os file_name = input(); if not os.path.exists(file_name): # Make sure file exists print('File does not exist!') sys.exit(1) # 1 indicates error items_set = [] with open(file_name, 'r') as csvfile: csv_reader = csv.reader(csvfile, delimiter=','...
true
7bb3dc041d323337163fab2cf5a19ef6e97c94c2
DharaniMuli/PythonAndDeepLearning
/ICPs/ICP-3/Program1_e.py
1,627
4.21875
4
class Employee: data_counter = 0 total_avg_salary = 0 total_salary = 0 # List is a class so I am creating an object for class mylist = list() def __init__(self, name, family, salary, department): self.empname = name self.empfamily = family self.empsalary = salary ...
true
df79f1a4a72a30fe40de567859db42fbb44e8f5d
echedgy/prg105fall
/3.3 Nested Ifs.py
1,247
4.21875
4
package = input("Which package do you have? (A, B, C): ") print("You entered Package " + package) minutes_used = int(input("How many minutes did you use this month? ")) package_price = 0.0 if package == "A" or package == "a": package_price = 39.99 if minutes_used > 450: additional_minutes = min...
true
93746c4f02729852c13d04b1de64a729a6a07dd8
echedgy/prg105fall
/11.2 Production Worker.py
816
4.28125
4
# Once you have written the classes, write a program that creates an object of the ProductionWorker class and prompts # the user to enter data for each of the object’s data attributes. # Store the data in the object and then use the object’s accessor methods to retrieve it and display it on the screen. import employ...
true
112a19946aef220606d17f2f547e67a58da7da03
echedgy/prg105fall
/2.3 Ingredient Adjuster.py
1,089
4.46875
4
# A cookie recipe calls for the following ingredients: # 1.5 cups of sugar # 1 cup of butter # 2.75 cups of flour # The recipe produces 48 cookies with this amount of ingredients. Write a program that asks the user # how many cookies they want to make, and then displays the number of cups # (to two decimal places...
true
08e291f0d7343d98f559e10755ac64ebf74d652c
varaste/Practice
/Python/PL/Python Basic-Exercise-6.py
1,064
4.375
4
''' Python Basic: Exercise-6 with Solution Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers. Python list: A list is a container which holds comma separated values (items or elements) between square brackets where items or e...
true
6fdf3e5c757f7de27c6afb54d6728116d9f3ae55
varaste/Practice
/Python/PL/Python Basic-Exercise-4.py
553
4.3125
4
''' Write a Python program which accepts the radius of a circle from the user and compute the area. Python: Area of a Circle In geometry, the area enclosed by a circle of radius r is πr2. Here the Greek letter π represents a constant, approximately equal to 3.14159, which is equal to the ratio of the circumf...
true
0173ae9e82213f4f01ccc6239a152b7ad0c5f8ad
varaste/Practice
/Python/PL/Python tkinter widgets-Exercise-8.py
756
4.21875
4
''' Python tkinter widgets: Exercise-8 with Solution Write a Python GUI program to create three single line text-box to accept a value from the user using tkinter module. ''' import tkinter as tk parent = tk.Tk() parent.geometry("400x250") name = tk.Label(parent, text = "Name").place(x = 30, y = 50) ema...
true
285451e05017f8598ff68eb73ae537ca2e0922a5
varaste/Practice
/Python/PL/Python Basic-Exercise-27-28-29.py
1,554
4.1875
4
''' Python Basic: Exercise-27 with Solution Write a Python program to concatenate all elements in a list into a string and return it. ''' def concat(list): output = "" for element in list: output = output + str(element) return output print(concat([1, 4, 0, 0,"/" , 0, 7,"/" ,2, 0])) ...
true
0ed76e4bb935107504ffed0f3b77804d7f42cdc2
varaste/Practice
/Python/PL/Python tkinter widgets-Exercise-7.py
688
4.21875
4
''' Python tkinter widgets: Exercise-7 with Solution Write a Python GUI program to create a Text widget using tkinter module. Insert a string at the beginning then insert a string into the current text. Delete the first and last character of the text. ''' import tkinter as tk parent = tk.Tk() # create the ...
true
897a1b3f11bc3f0352e61ed6802094bd6c341729
michalkasiarz/automate-the-boring-stuff-with-python
/regular-expressions/usingQuestionMark.py
499
4.125
4
import re # using question mark -> for something that appears 1 or 0 times (preceding pattern) batRegex = re.compile(r"Bat(wo)?man") mo = batRegex.search("The Adventures of Batman") print(mo.group()) # Batman mo = batRegex.search("The Adventures of Batwoman") print((mo.group())) # Batwoman # another example with ...
true
9393e65692d8820d71fdda043da48ec33658b467
michalkasiarz/automate-the-boring-stuff-with-python
/dictionaries/dataStructures.py
686
4.125
4
# Introduction to data structure def printCats(cats): for item in cats: print("Cat info: \n") print("Name: " + str(item.get("name")) + "\nAge: " + str(item.get("age")) + "\nColor: " + str(item.get("color"))) print() cat = {"name": "Parys",...
true
c795f6ac170f96b398121ddbbc9a22cf13835061
AshwinBalaji52/Artificial-Intelligence
/N-Queen using Backtracking/N-Queen_comments.py
2,940
4.125
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 1 00:42:23 2021 @author: Ashwin Balaji """ class chessBoard: def __init__(self, dimension): # board has dimensions dimension x dimension self.dimension = dimension # columns[r] is a number c if a queen is placed at row r and column ...
true
dee277547fa6e80610a419c7285ff2074e0078cf
tejadeep/Python_files
/tej_python/basics/add.py
287
4.28125
4
#program by adding two numbers a=10 b=20 print"%d+%d=%d"%(a,b,a+b) #this is one method to print using format specifiers print"{0}+{1}={2}".format(a,b,a+b) #this is one method using braces #0 1 2 print"{1}+{0}={2}".format(a,b,a+b) # here output is 20+10=30
true
0ddac05ddceaa96fc1a31d35d43e91bedd70dc8e
dannikaaa/100-Days-of-Code
/Beginner Section/Day2-BMI-Calulator.py
418
4.3125
4
#Create a BMI Calculator #BMI forumula #bmi = weight/height**2 height = input("Enter your height in m: ") weight = input("Enter your weight in kg: ") #find out the type of height & weight #print(type(height)) #print(type(weight)) #change the types into int & float int_weight = int(weight) float_height = float(hei...
true
3fd9c30f76f11696abac88e60cc1ce28c212b729
akashbhalotia/College
/Python/Assignment1/012.py
554
4.25
4
# WAP to sort a list of tuples by second item. # list1.sort() modifies list1 # sorted(list1) would have not modified it, but returned a sorted list. def second(ele): return ele[1] def sortTuples(list1): list1.sort(key=second) inputList = [(1, 2), (1, 3), (3, 3), (0, 3), (3, 5), (7, 2), (5, 5)] print('Input...
true
c52de657a3ae4643f627703138e86bc03d8383dc
momentum-cohort-2019-02/w3d3-oo-pig-yyapuncich
/pig.py
2,594
4.15625
4
import random class ComputerPerson: """ Computer player that will play against the user. """ def __init__(self, name, current_score=0): """ Computer player will roll die, and automatically select to roll again or hold for each turn. They will display their turn totals after each tu...
true
b6d518a4d5c829045cc4b19c1a0630422cf38050
SwethaVijayaraju/Python_lesson
/Assignments/Loops/Biggest number divisible.py
522
4.25
4
#write a function that returns the biggest number divisible by a divisor within some range. def biggest(num1,num2,divisor): bignum=None while num1<=num2: if (num1%divisor)==0: bignum=num1 num1=num1+1 return bignum print(biggest(1,10,2)) #answer should be 10 #write a function that returns the biggest nu...
true
db73a48731ed073e252d56eedc05c98588ba1675
jayednahain/python-Function
/function_mix_calculation.py
386
4.15625
4
def addition(x,y): z=x+y return print("the addtion is: ",z) def substruction(x,y): z=x-y return print("the substruction is : ",z) def multiplication(x,y): z=x*y return print("the multiplication is :",z) a = int(input("enter a number one : ")) b = int(input("enter second nu...
true
7a3c29e08029bdbfd42dbda0b6cc6c22144d01c8
Nate-17/LetsUpgrade-Python
/primenumber.py
444
4.28125
4
''' This is a module to check weather the given number is even or odd.'' ''' def prime(num): ''' This is the main function which check out the given number is even or odd. ''' if num > 1: for i in range(2, num): if (num % i) == 0: break return p...
true
686c1f0c8ebec7caade9bd99e8c45b5581e421e1
SweetLejo/DATA110
/past_exercises_leo/yig012_t2.py
1,562
4.28125
4
#Oppgave 1 from math import pi #imports pi from the math library, since its the only thing I'll use in this exercise it felt redundant to import the whole library radius = float(input('Radius: ')) #promts the user to enter a radius area = round((radius**2)*pi, 3) #defines a variable as the area, and rounds it to 3...
true
fac04373d57b33f9dd8298e01aaf36f0ebb3fb75
wonderme88/python-projects
/src/revstring.py
285
4.40625
4
# This program is to reverse the string def revStr(value): return value[::-1] str1 = "my name is chanchal" str2 = "birender" str3 = "chanchal" #print revStr(str1) list = [] list.append(str1) list.append(str2) list.append(str3) print (list) for x in list: print revStr(x)
true
e10a0af7adca68109ebeb211ad994b2877c5a52d
EugenieFontugne/my-first-blog
/test/python_intro.py
835
4.125
4
volume = 18 if volume < 20: print("It's kinda quiet.") elif 20 <= volume < 40: print("It's nice for background music") elif 40 <= volume < 60: print("Perfect, I can hear all the details") elif 60 <= volume < 80: print("Nice for parties") elif 80 <= volume < 100: print("A bit loud!") else: print("My hears are hurt...
true
3eb6198afa9481a86e43c80b29b1156c64108dc0
JI007/birthdays
/birthday search.py
2,316
4.3125
4
def birthday(): birthdays = {'Jan': ' ','Feb': ' ', 'Mar': ' ', 'Apr': ' ', 'May': 'Tiana (10), Tajmara (11) ', 'June': ' ', 'July': 'Jamal (7)', 'Aug': 'Richard (7) ', 'Sept': 'Nazira (16) ', 'Oct': ' ', 'Nov': ' ', 'Dec': ' '} birthday() # Welcomes the user to the program print("\n\n\t\tWelcome to th...
true
df97a2008ef5f6576c0d100699bef3a4ce706400
Shamita29/266581dailypractice
/set/minmax.py
455
4.21875
4
#program to find minimum and maximum value in set def Maximum(sets): return max(sets) def Minimum(sets): return min(sets) """ setlist=set([2,3,5,6,8,28]) print(setlist) print("Max in set is: ",Maximum(setlist)) print("Min in set is: ",Minimum(setlist)) """ print("Enter elements to be added in set") sets = set(map...
true
3165bc53048b76a1fc5c7bc58bef2663c595f69e
zmatteson/epi-python
/chapter_4/4_7.py
335
4.28125
4
""" Write a program that takes a double x and an integer y and returns x**y You can ignore overflow and overflow """ #Brute force def find_power(x,y): if y == 0: return 1.0 result = 1.0 while y: result = x * result y = y - 1 return result if __name__ == "__main__": print(f...
true
7bfff88b28253ec0f69e3c93dc01c29be200e71b
zmatteson/epi-python
/chapter_13/13_1.py
1,092
4.1875
4
""" Compute the intersection of two sorted arrays One way: take the set of both, and compute the intersection (Time O(n + m) ) Other way: search in the larger for values of the smaller (Time O(n log m ) ) Other way: start at both and walk through each, skipping where appropriate (Time O(n + n) , space O(intersection ...
true
af77d80d6b95b5dc847f33ba0783b5fcc7c872d6
zmatteson/epi-python
/chapter_5/5_1.py
1,620
4.21875
4
""" The Dutch National Flag Problem The quicksort algorith for sorting arrays proceeds recursively--it selects an element ("the pivot"), reorders the array to make all the elements less than or equal to the pivot appear first, followed by all the elements greater than the pivot. The two subarrays are then sorted rec...
true
d3e57c2ec3133003e2d8d5f67c2aee403e3ab0e8
zmatteson/epi-python
/chapter_14/14_1.py
959
4.15625
4
""" test if a tree satisfies the BST property What is a BST? """ class TreeNode: def __init__(self, left = None, right = None, key = None): self.left = left self.right = right self.key = key def check_bst(root): max_num = float('inf') min_num = float('-inf') return check_bst_...
true
cad9a59e7ed85cd5f9c7cea130d6589ee7a70bd9
Pyae-Sone-Nyo-Hmine/Ciphers
/Caesar cipher.py
1,362
4.46875
4
def encode_caesar(string, shift_amt): ''' Encodes the specified `string` using a Caesar cipher with shift `shift_amt` Parameters ---------- string : str The string to encode. shift_amt : int How much to shift the alphabet by. ''' ...
true
de6be7734a7996f5bbea60637be01ed928b7ddb4
v4vishalchauhan/Python
/emirp_number.py
669
4.28125
4
"""Code to find given number is a emirp number or not""" """Emirp numbers:prime nubers whose reverse is also a prime number for example:17 is a prime number as well as its reverse 71 is also a prime number hence its a emirp number..""" def prime_check(k): n=int(k) if n<=1: return False for i in range(2,n)...
true
112da86c726bd8f3334258910eae937aff2f8db5
ms99996/integration
/Main.py
1,664
4.1875
4
"""__Author__= Miguel salinas""" """This is my attempt to create a mad lib """ ask = input("welcome to my mad lib, would you like to give it a try? enter " "yes or no, the answer is case sensitive: ") while ask not in ("yes", "no"): ask = input("please type a valid input: ") def get_answers(...
true
d6baa2d4320f15ece2bd9d628911145a1b471105
ErenBtrk/PythonSetExercises
/Exercise7.py
237
4.375
4
''' 7. Write a Python program to create a union of sets. ''' set1 = set([1,2,3,4,5]) set2 = set([6,7,8]) set3 = set1 | set2 print(set3) #Union setx = set(["green", "blue"]) sety = set(["blue", "yellow"]) seta = setx | sety print(seta)
true
546cd33519cea7f759d09ccd11203d44fed2fc4d
sivaprasadkonduru/Python-Programs
/Sooryen_python/question3.py
608
4.125
4
''' Write a function that takes an array of strings and string length (L) as input. Filter out all the string string in the array which has length ‘L’ eg. wordsWithoutList({"a", "bb", "b", "ccc"}, 1) → {"bb", "ccc"} wordsWithoutList({"a", "bb", "b", "ccc"}, 3) → {"a", "bb", "b"} wordsWithoutList({"a", "bb", "b", "ccc"...
true
c80c00855a308016585a2620659b44a93b218a07
kauboy26/PyEvaluator
/miscell.py
569
4.15625
4
def print_help(): print 'Type in any expressions or assignment statements you want.' print 'For example:' print '>> a = 1 + 1' print '2' print '>> a = a + pow(2, 2)' print '6' print '\nYou can also define your own functions, in the form' print 'def <function name>([zero or more comma s...
true
76972fcaadbc52294e7e06871d1f7115e8eb6285
jabarszcz/randompasswd
/randompasswd.py
1,496
4.125
4
#!/usr/bin/env python3 import argparse import string import random # Create parser object with program description parser = argparse.ArgumentParser( description="simple script that generates a random password") # Define program arguments parser.add_argument("-a", "--lower", action='store_true', ...
true
7fbee6b902a11525f9d8afd0f20a343126dd51b1
isaolmez/core_python_programming
/com/isa/python/chapter6/Tuples.py
530
4.4375
4
## Tuples are very similar to lists; but they are immutable tuple1 = (1,2,3) print tuple1 # For tuples, parantheses are redundant and this expression craetes a tuple. # For lists we must use brackets tuple2 = "a", "b", "c" print tuple2 # tuple1[1] = 99 # ERROR: We cannot mutate tuple or assign new values to its elemen...
true
916b10dc06df2fece2e1af6afe15b80696ea11cc
isaolmez/core_python_programming
/com/isa/python/chapter5/Exercise_5_11.py
468
4.1875
4
for item in range(0,21,2): print item, print for item in range(0, 21): if item % 2 == 0: print item, print for item in range(1,21,2): print item, print for item in range(0, 21): if item % 2 == 1: print item, print ## If you omit return type, it does not give warning but returns ...
true
b433ed328d118c05a67b42d8085391af87955ba7
isaolmez/core_python_programming
/com/isa/python/chapter7/SetOperators.py
899
4.21875
4
## 1. Standard Type Operators set1 = set([1, 2, 3, 3]) # Removes duplicates print set1 set2 = set("isa123") print set2 print 1 in set1 print "i" in set2 print "---- Equality test" set1Copy = set(set1) print "set1 == set1Copy", set1 == set1Copy print "set1 < set1Copy", set1 < set1Copy # Strictly must be smaller. Equa...
true