blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
26ccdbc2bae76c99ce4409f4dbaef17419d78086
sam676/PythonPracticeProblems
/Robin/palindromeNumber.py
1,709
4.3125
4
""" Sheltered at home, you are so bored out of your mind that you start thinking about palindromes. A palindrome, in our case, is a number that reads the same in reverse as it reads normally. Robin challenges you to write a function that returns the closest palindrome to any number of your choice. If your number is exa...
true
095000b97fa3e4993fef3682cb33e688586eb4ae
sam676/PythonPracticeProblems
/Robin/isMagic.py
1,199
4.53125
5
""" You've heard about Magic Squares, right? A magic square is one big square split into separate squares (usually it is nine separate squares, but can be more), each containing a unique number. Each horizontal, vertical, and diagonal row MUST add up to the same number in order for it to be considered a magic squar...
true
57a76e4402bad59476588863a63a67e89e5d5bd0
sam676/PythonPracticeProblems
/Robin/numScanner.py
1,174
4.25
4
""" How are our lovely number people doing today? We're going to have an exclusive numbers-only party next week. You can bring any type of friends that wear "String" clothes as long as they are real number. As we expect the infinite number of numbers to come to the party, we should rather build a scanner that will ...
true
a4b9901488a005c10a02c477fa009b2131fa8906
sam676/PythonPracticeProblems
/Robin/addPositiveDigit.py
501
4.125
4
""" Beginner programmer John Doe wants to make a program that adds and outputs each positive digit entered by the user (range is int). For instance, the result of 5528 is 20 and the result of 6714283 is 31. """ def addPositiveDigit(n): total = 0 if n >= 0: for x in str(n): total += int(x)...
true
e241aa2106c8e48c37c3531b6d7fa8bdbbf216e7
amirrulloh/python-oop
/leetcode/2. rverse_integer.py
863
4.1875
4
#Definition """ Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers wi...
true
c097cfa78f6c8bc2a62eb04cd86023c51f221b5d
miller9/python_exercises
/17.py
1,337
4.625
5
print (''' 17. Write a version of a palindrome recognizer that also accepts phrase palindromes such as "Go hang a salami I'm a lasagna hog.", "Was it a rat I saw?", "Step on no pets", "Sit on a potato pan, Otis", "Lisa Bonet ate no basil", "Satan, oscillate my metallic sonatas", "I roamed under it as a tired nude...
true
571f2c597feb3192b9d5f7cf72e6403ef8b332c9
miller9/python_exercises
/12.py
384
4.21875
4
print (''' 12. Define a procedure histogram() that takes a list of integers and prints a histogram to the screen. For example, histogram( [ 4, 9, 7 ] ) should print the following: **** ********* ******* ''') def histogram(l): for value in l: print ("*" * value) int_list = [4, 9, 7] print ('The histogra...
true
111e530378568654c44b14627fe5f11fe8493a43
miller9/python_exercises
/10.py
1,024
4.34375
4
print (''' 10. Define a function overlapping() that takes two lists and returns True if they have at least one member in common, False otherwise. You may use your 'is_member()' function, or the 'in' operator, but for the sake of the exercise, you should (also) write it using two nested for-loops. ''') def o...
true
e14c143ea086ca19b10c2f4f9cb59e0d4d55f651
benjaminhuanghuang/ben-leetcode
/0306_Additive_Number/solution.py
2,106
4.21875
4
''' 306. Additive Number Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding two. For example: "112358" is an additive number bec...
true
a4ff52bf767bec2d17ad4e192855aa4380807c6b
benjaminhuanghuang/ben-leetcode
/0398_Random_Pick_Index/solution.py
1,366
4.125
4
''' 398. Random Pick Index Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array. Note: The array size can be very large. Solution that uses too much extra space will not pass the judge. Example: i...
true
fc6127107d0807ee269b4505543ee30741c4695a
benjaminhuanghuang/ben-leetcode
/0189_Rotate_Array/solution.py
1,649
4.1875
4
''' 189. Rotate Array Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note: Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem. ''' class Solution(object): de...
true
45929efac6474bb344733cd8130f9c2ea68f7bcd
benjaminhuanghuang/ben-leetcode
/0414_Third_Maximum_Number/solution.py
2,003
4.1875
4
''' 414. Third Maximum Number Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). Example 1: Input: [3, 2, 1] Output: 1 Explanation: The third maximum is 1. Example 2: Input: [1, 2] Output: 2 Expl...
true
e6cdd47a3fe566991b401e000debe99d16451178
benjaminhuanghuang/ben-leetcode
/0031_Next_Permutation/solution.py
1,715
4.125
4
''' 31. Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order). The replacement must be in-place, do not allocate extra...
true
b8f6e39447a33973e6a3d806cc407b73b372f7be
walokra/theeuler
/python/euler-1_fizzbuzz.py
413
4.125
4
# Problem 1 # 05 October 2001 # # 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. # # Answer: 233168 # #!/usr/bin/python sum = 0 max = 1000 for i in range(1,max): if i%3 ...
true
503423d6683506ce9ff4fde7f73cfbd7b1cb5145
tolaoner/Python_Exercises
/different_numbers.py
613
4.125
4
'''Create a sequence of numbers and determine whether all the numbers of it are different from each other''' import random list_numbers=[] different=True for i in range(5): list_numbers.append(random.randrange(1,10,1)) print(list_numbers[i]) for i in range(5): for j in range(5): if i==j: continue if list_nu...
true
399474bdd93e47d000ed9ae9734dd2e5b85fe660
Siddhant6078/Placement-Programs
/Python/factors_of_a_num.py
214
4.25
4
# Python Program to find the factors of a number def print_factors(n): print 'Factors of {0} are:'.format(n) for x in xrange(1,n+1): if n % x == 0: print x n1 = int(input('Enter a n1: ')) print_factors(n1)
true
92f4bea4efbe1c7549407a44b85bf03ceeb25104
Siddhant6078/Placement-Programs
/Python/swap two variables.py
663
4.34375
4
# Python program to swap two variables using 3rd variable x = input('Enter value of x: ') y = input('Enter value of y: ') print 'The value of x: Before:{0}'.format(x) print 'The value of y: Before:{0}'.format(y) temp = x x = y y = temp print 'The value of x: After:{0}'.format(x) print 'The value of y: After:{0}'.fo...
true
e3f91759b3e4661e53e1c5bb42f6525cef89b2d5
Siddhant6078/Placement-Programs
/Python/Positive or Negative.py
319
4.5
4
# Program to Check if a Number is Positive, Negative or 0 # Using if...elif...else num = float(input('Enter a Number: ')) if num > 0: print 'Positive' elif num == 0: print 'Zero' else: print 'Negative' # Using Nested if if num >= 0: if num == 0: print 'Zero' else: print 'Positive' else: print 'Negative'
true
73fed6743975942f340fc78009c16b9e2cf7b875
abhinavkuumar/codingprogress
/employeeDict.py
1,049
4.1875
4
sampleDict = { 'emp1': {'name': 'John', 'salary': 7500}, 'emp2': {'name': 'Emma', 'salary': 8000}, 'emp3': {'name': 'Tim', 'salary': 6500} } while 1: answer = input("Do you want to add or remove an employee? Select q to quit (a/r/q) ") newlist = list(sampleDict.keys()) if answer == 'a': ...
true
2da72ad227e82145ffd64f73b39620330c83c21d
greenhat-art/guess-the-number
/guessingGame.py
604
4.3125
4
import random print("Number guessing game") number = random.randint(1, 9) chances = 0 print("Guess a number between 1 to 9:") while chances < 5: guess = int(input("Enter your guessed number:- ")) if guess == number: print("Congratulation you guessed the right number!") break ...
true
957d95428e0af1b303930e7071dfbe710f84f99b
anasm-17/DSA_collaborative_prep
/Problem_sets/fizzbuzz/fizzbuzz_jarome.py
1,879
4.3125
4
from test_script.test import test_fizzbuzz """ A classic Data Structures an algorithms problem, you are given an input array of integers from 1 to 100 (inclusive). You have to write a fizzbuzz function that takes in an input array and iterates over it. When your function receives a number that is a factor of 3 you ...
true
dd80e66757066ef8d97911680ffb0e47411d9c25
jineshshah101/Python-Fundamentals
/Casting.py
580
4.3125
4
# variable example x = 5 print(x) # casting means changing one data type into another datatype # casting the integer x into a float y = float(x) print(y) # casting the integer x into a string z = str(x) print(z) # Note: Cannot cast a string that has letters in it to a integer. The string itself mu...
true
6141bb86224dbc1c19efca92f530682d1a04e570
jineshshah101/Python-Fundamentals
/Calendar.py
1,448
4.46875
4
import calendar #figuring things out with calendar # printing out the week headers # using the number 3 so we can get 3 characters for the week header week_header = calendar.weekheader(3) print(week_header) print() # print out the index value that represents a weekday # in this case we are getting the ind...
true
ce0cfdebf310432f6641ef77c298ebefefa2d2d6
gihs-rpc/01-Sleeping-In
/challenge-1-sleeping-in-MoseliaTemp3/1.1 ~ Sleeping In.py
1,612
4.34375
4
#Repeatedly used things defined here for ease of modification. EndBool = "\n (Y/N) > " Again = "Incorrect input." #Begin Program. while True: print("\n") #Is tomorrow a school day? SchoolTomorrow = input("Do you have school tomorrow?" + EndBool) print() #Repeat question until answe...
true
2d9ca18c7b90af0ac266f5f8b8b684492c2bbc4e
laurendayoun/intro-to-python
/homework-2/answers/forloops.py
2,846
4.40625
4
""" Reminders: for loop format: for ELEMENT in GROUP: BODY - ELEMENT can be any variable name, as long as it doesn't conflict with other variables in the loop - GROUP will be a list, string, or range() - BODY is the work you want to do at every loop range format is: range(start, stop, step) or range(st...
true
8a93636bd5b7b955f431bc4f351583b742fe14cf
senavarro/function_scripts
/functions.py
947
4.40625
4
#Create a function that doubles the number given: def double_value(num): return num*2 n=10 n=double_value(n) print(n) -------------------------------------- #Create a recursive function that gets the factorial of an undetermined number: def factorial(num): print ("Initial value =", num) if num > 1: num = n...
true
d48b8e88545ebcf87820f63294285c9b0d370331
kingdunadd/PythonStdioGames
/src/towersOfHanoi.py
2,977
4.34375
4
# Towers of Hanoi puzzle, by Al Sweigart al@inventwithpython.com # A puzzle where you must move the disks of one tower to another tower. # More info at https://en.wikipedia.org/wiki/Tower_of_Hanoi import sys # Set up towers A, B, and C. The end of the list is the top of the tower. TOTAL_DISKS = 6 HEIGHT = TOTAL_DISK...
true
0b0329ee3244562c8c7aa7abb3068f2c06737bde
codesheff/DS_EnvTools
/scripts/standard_functions.py
706
4.21875
4
#!/usr/bin/env python3 def genpassword(forbidden_chars:set={'!* '} , password_length:int=8) -> str: """ This function will generate a random password Password will be generated at random from all printable characters. Parameters: forbidden_chars: Characters that are not allowed in the pass...
true
97defbcbd96034d5ac170250340d05d18732da78
willpxxr/python
/src/trivial/sorting/quicksort.py
2,527
4.25
4
from math import floor from typing import List def _medianOf3(arr: List, begin: int, end: int) -> (int, int): """ Brief: Help method to provide median of three functionality to quick sort An initial pivot is selected - then adjusted be rotating the first index, center index and end index...
true
52d309fa9f4cca8b527da7850fca9256a34c2b6c
hannahbishop/AlgorithmPuzzles
/Arrays and Strings/rotateMatrix.py
1,244
4.25
4
def rotate_matrix(matrix, N): ''' Input: matrix: square, 2D list N: length of the matrix Returns: matrix, rotated counter clockwise by 90 degrees Example: Input: [a, b] [c, d] Returns: [b, d] [a, c] Efficiency:...
true
e72fe631c3633f59c643e7a58de5ab3c9c564eb9
Ziiv-git/HackerRank
/HackerRank23.py
1,987
4.1875
4
''' Objective Today, we’re going further with Binary Search Trees. Check out the Tutorial tab for learning materials and an instructional video! Task A level-order traversal, also known as a breadth-first search, visits each level of a tree’s nodes from left to right, top to bottom. You are given a pointer, , pointing...
true
53cecd207777cb4b81667a0869fc3318f8673f47
mciaccio/pythonCode
/udacityPythonCode/classes/inheritance.py
2,075
4.34375
4
# class name first letter uppercase "P" class Parent(): # constructor def __init__(self, last_name, eye_color): print("Parent Constructor called\n") self.last_name = last_name self.eye_color = eye_color # super class instance method def show_info(self): prin...
true
8ad0f485fbad4f5edc9df95ba3a4b21257add7bc
ashwin-magalu/Python-OOPS-notes-with-code
/access.py
713
4.28125
4
class Employee: name = "Ashwin" # public member _age = 27 # protected member __salary = 10_000 # private member --> converted to _Employee__salary def showEmpData(self): print(f"Salary: {self.__salary}") class Test(Employee): def showData(self): print(f"Age: {self._age}") #...
true
5761bda1dc5763f3e0acae42b4b98c928c84fb19
pr0d33p/PythonIWBootcamp
/Functions/7.py
422
4.21875
4
string = "The quick Brow Fox" def countUpperLower(string): lowerCaseCount = 0 upperCaseCount = 0 for letter in string: if letter.isupper(): upperCaseCount += 1 elif letter.islower(): lowerCaseCount += 1 print("No. of Upper case characters: {}".format(upperCase...
true
8ec919cee9c1ce1c5a1a92e94e661e153449b5cd
axisonliner/Python
/del_files.py
1,854
4.125
4
# Script for deleting files from a folder using the command line: # command line: python del_files.py arg1 arg2 # - arg1 = folder path # - arg2 = file extention # Example: python del_files.py C:\Desktop\folder_name .exr import os import sys import math def get_size(filename): st = os.stat(filename) ...
true
2a0f013ad2aac2a67e9eafb1fa8a009d9aa663a8
ESROCOS/tools-pusconsole
/app/Utilities/Database.py
2,907
4.375
4
import sqlite3 as sq3 from sqlite3 import Error class Database(object): """ This class represents a database object. It implements some methods to ease insertion and query tasks """ def __init__(self, dbname: str): """ This is the constructor of the class :param dbname: The...
true
e7eea0e92c5c8cf7c537f545b05a17a819b4d108
pab2163/pod_test_repo
/Diana/stock_market_challenge.py
1,221
4.25
4
# Snippets Challenge # Playing with the stock market. # Write code to take in the name of the client as the user input name = input("Hi there!\nWhat is your name?: ") print("Hello "+ name + "!" ) # Write code to get user input savings" and personalize message with "name" savings =int(input("What are your curren...
true
d3db4c2dbb599de13e7396db16f96912d335b126
Abdullahalmuhit/BT_Task
/BT_Solution.py
548
4.125
4
value = int (input("How many time you want to run this program?: ")) def check_palindromes(value): charecter = input("Enter Your One Character: ") my_str = charecter+'aDAm' # make it suitable for caseless comparison my_str = my_str.casefold() # reverse the string rev_str = reversed(my_st...
true
9297bd49c2a7ddd20007b3d0f599ce7a15cfa670
rajatkashyap/Python
/make_itemsets.py
564
4.21875
4
'''Exercise 3 (make_itemsets_test: 2 points). Implement a function, make_itemsets(words). The input, words, is a list of strings. Your function should convert the characters of each string into an itemset and then return the list of all itemsets. These output itemsets should appear in the same order as their correspond...
true
8095f1c33d099fcdad65003a2f4add5d07bd5090
orionbearduo/Aizu_online_judge
/ITP1/ITP_1_6_A.py
539
4.28125
4
""" Reversing Numbers Write a program which reads a sequence and prints it in the reverse order. Input The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence. Output Print the reversed sequence in a line. Print a single space character be...
true
0935e6a46fdd933261931fa71727206015745918
orionbearduo/Aizu_online_judge
/ITP1/ITP_1_5_C.py
824
4.28125
4
""" Print a Chessboard Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. #.#.#.#.#. .#.#.#.#.# #.#.#.#.#. .#.#.#.#.# #.#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Input T...
true
bdff89efc61f5158b6d87dd6b5eeb5f11e91b898
orionbearduo/Aizu_online_judge
/ITP1/ITP_1_8_A.py
245
4.3125
4
# Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string. # Sample Input # fAIR, LATER, OCCASIONALLY CLOUDY. # Sample Output # Fair, later, occasionally cloudy. n = str(input()) print(n.swapcase())
true
dd8e680dc6602a27517af06f09319447b4256735
renuit/renu
/factor.py
226
4.125
4
n=int(input("Enter a number:")) fact=1 if(n<0): print("No factorial for -Ve num") elif(n==0): print("factorial of 0 is 1") else: for i in range(1,n+1): fact=fact*i print("factorial of", n,"is",fact)
true
7c94602bbc0ce53124f4e2c892c85d24dcbd0331
garima-16/Examples_python
/occurrence.py
260
4.4375
4
#Program to find the occurrences of a character in a string string1=input("enter any string ") ch=input("enter a character ") count=0 for i in string1: if ch==i: count+=1 print("number of occurrences of character in string ",count)
true
c310929561622e694202ce37ffcd91d77ef4551c
Dinesh-Sivanandam/Data-Structures
/Linked List/insert_values.py
1,664
4.375
4
#Creating the class node class Node: def __init__(self, data=None, next=None): self.data = data self.next = next #Creating the class for linked list class LinkedList: #this statement initializes when created #initializing head is none at initial def __init__(self): ...
true
0693111789c72af4db96730c3caa7b0cf4422571
sachinasy/oddevenpython
/prac1.py
268
4.34375
4
# program to identify the even/odd state of given numbers # function to print oddeven of given number #oddeven function number = int(input("enter a number: ")) if number % 2== 0: print ("the entered number is even") else: print ("the entered number is odd")
true
e3459e66daea9d2747d6b5e5f05db326b8f2a127
epangar/python-w3.exercises
/String/1-10/5.py
343
4.125
4
""" 5. Write a Python program to get a single string from two given strings, separated by a space and swap the first two characters of each string. """ def style_str(str1, str2): answer1 = str2[0:2] + str1[2:] answer2 = str1[0:2] + str2[2:] answer = answer1 + " " + answer2 return answer print(s...
true
3f12cfba4069f64e2c4218935ae0649fbb5d05bd
epangar/python-w3.exercises
/String/1-10/2.py
327
4.28125
4
""" 2. Write a Python program to count the number of characters (character frequency) in a string. """ def count_char(str): dict = {} for i in range(0, len(str)): key = str[i] if key in dict: dict[key] += 1 else: dict[key] = 1 return...
true
2afa17246ba3754f0694b361e4d8f6cbc0df047d
pdshah77/Python_Scripts
/Input_Not_Required/PreFixMapSum.py
776
4.28125
4
''' Write a Program to Implement a PrefixMapSum class with the following methods: insert(key: str, value: int): Set a given key's value in the map. If the key already exists, overwrite the value. sum(prefix: str): Return the sum of all values of keys that begin with a given prefix. Developed By: Parth Shah Python ...
true
35615a6933af9421794d96c35d06310a87ac0562
Flact/python100
/Codes/day_02.py
2,417
4.3125
4
# it will print "H" # print("Hello"[0]) # --------------------------- # type checking # num_char = len(input("What is your name? ")) # this print function will throw a erorr # print("Your name has " + num_char + " Characters") # ----------------------------------------------------- # print(type(num_char)) # the fi...
true
edd17e6ae441888ea4ea37c64c203075231f5e79
Flact/python100
/Codes/day_05/loop_with_range.py
292
4.28125
4
# for number in range(1, 10): # print(number) # this will print 1 - 9 (not include 10, but include 1) # this will print 1 - 10 numbers step by 3 # for number in range(1, 11, 3): # print(number) # total up to 100 total = 0 for num in range(1, 101): total += num print(total)
true
f229875b6fbae36c226b1df10b1ec46a724d3383
kalpanayadav/python
/cosine.py
802
4.34375
4
def myCos(x): ''' objective: to compute the value of cos(x) input parameters: x: enter the number whose cosine value user wants to find out approach: write the infinite series of cosine using while loop return value: value of cos(x) ''' epsilon=0.00001 multBy=-x**2 term=1 ...
true
35fe7adbad7d0928347a52e7bc91f0fd2b4662a5
ikemerrixs/Au2018-Py210B
/students/arun_nalla/session02/series.py
1,900
4.375
4
#!use/bin/env python def fibo(n): '''Write a alternative code to get the nth value of the fibonacci series using type (list) 0th and 1st position should return 0 and 1 and indexing nth position should return SUM of previous two numbers''' if n ==0: return 0 elif n ==1: return 1 my_list = [0,1] ...
true
c69af38ba8fc630402d9e5415d128a00948cb973
ikemerrixs/Au2018-Py210B
/students/ejackie/session04/trigrams.py
843
4.3125
4
#!/usr/bin/env python3 import sys from collections import defaultdict words = "I wish I may I wish I might".split() def build_trigrams(words): """ build up the trigrams dict from the list of words returns a dict with: keys: word pairs values: list of followers """ trigrams = defau...
true
6886b16e533f10be42a0cf60f0a8381c805eb6ad
KarmanyaT28/Python-Code-Yourself
/59_loopq4.py
424
4.21875
4
# Write a program to find whether a given number is prime or not number=int(input("enter your number which has to be checked")) # i=2 # for i in range(2,number): # if(number%i==0): # break # print("Not a prime number") prime = True for i in range(2,number): if(number%i==0): pri...
true
812e5fb56f013781312790cd6b4a2a20cc255647
KarmanyaT28/Python-Code-Yourself
/17_playwithstrings.py
1,014
4.40625
4
# name = input("Enter your name\n") # print("Good afternoon, " + name) # --------------------------------------------------------------------------- # Write a program to fill in a letter template given below # letter = '''Dear <Name> , you are selected ! <DATE>''' # letter = ''' # Greetings from TalkPy.or...
true
027170862720a141e62cd700cc30dc11db0a3b73
KarmanyaT28/Python-Code-Yourself
/45_conditionalq3.py
542
4.25
4
# A spam comment is defined as a text containing following keywords: # "make a lot of money" , "buy now","subscribe this", # "click this". # Write a program to detect these spams. text= input("Enter the text") spam = False if("make a lot of money" in text): spam = True elif("buy now" in text): sp...
true
a0b6a8921da7aa3562a1441fbe826bf528aa5ed6
RealMrRabbit/python_workbook
/exercise_3.py
2,794
4.5
4
#Exercise 3: Area of a Room #(Solved—13 Lines) #Write a program that asks the user to enter the width and length of a room. Once #the values have been read, your program should compute and display the area of the #room. The length and the width will be entered as floating point numbers. Include #units in your prompt an...
true
12853d4c6fbd6325541bce74c1307871c28bf8f9
z0k/CSC108
/Exercises/e2.py
1,960
4.1875
4
# String constants representing morning, noon, afternoon, and evening. MORNING = 'morning' NOON = 'noon' AFTERNOON = 'afternoon' EVENING = 'evening' def is_a_digit(s): ''' (str) -> bool Precondition: len(s) == 1 Return True iff s is a string containing a single digit character (between '0' and '9' i...
true
f23776b0ea7d95b86dc0ab31d15f208657050d50
Tavheeda/python-programs
/lists.py
1,882
4.25
4
# fruits = ['apple','orange','mango','apple','grapes'] # print(fruits) # print(fruits[1]) # import math # for fruit in fruits: # print(fruit) # numbers = [1,2,3,4,5,8,9,10] # print(numbers[2:5]) # print(numbers[3:]) # for number in numbers: # print(number) # i = 0 # while i < len(numbers): # print(numbers[i]) # ...
true
1d675bd4f0271c09a8998b7ea02f4b2d3110b6cf
powerlego/Main
/insertion_sort.py
1,053
4.125
4
""" file: insertion_sort.py language: python3 author: Arthur Nunes-Harwitt purpose: Implementation of insertion sort algorithm """ def insertion_sort(lst): """ insertionSort: List( A ) -> NoneType where A is totally ordered effect: modifies lst so that the elements are in order """ for m...
true
a0dbb5f621dd2a58469e0d26bf9190f45dfc86d8
Rossorboss/Python_Functions_Prac
/map,filter,lambda.py
2,621
4.5625
5
#map, lambda statements def square(num): return num ** 2 my_nums = [1,2,3,4,5] for x in map(square,my_nums): #the map function allows it to be used numerous times at once print(x) # Luke i am your father example--using map to call all 3 at the same time def relation_to_luke(name): if name == 'Darth Vad...
true
67065afeef4f82ff240a6920f642cc739a486010
dearwendy714/web-335
/week-8/Portillo_calculator.py
645
4.625
5
# ============================================ # ; Title: Assignment 8.3 # ; Author: Wendy Portillo # ; Date: 9 December 2019 # ; Modified By: Wendy Portillo # ; Description: Demonstrates basic # ; python operation # ;=========================================== # function that takes two parameters(numbers) and adds th...
true
84f611ef059a51b87074835a430eedf3da9f346c
davestudin/Projects
/Euler Problems/Euler Problems/Question 6.py
529
4.34375
4
from math import * input = int(raw_input("Enter sum of the desired Pythagorean Triple: ")) def pythag(sum): a,b,c=0.0,0.0,0.0 for a in range (1,sum): for b in range(a,sum): c=sqrt(a*a+b*b) if c%1==0 and a%1==0 and b%1==0: if (a+b+c)==sum: return 'The Pythagorean triple with sides that add up to '+...
true
0e06bc1f938f34183388ac64c76def7a328c4ba1
BNHub/Python-
/Made_Game.py
495
4.40625
4
#1. Create a greeting for your program. print("Welcome to the best band name game!") #2. Ask the user for the city that they grew up in. city = input("What is name of the city you grew up in?\n") #3. Ask the user for the name of a pet. pet_name = input("What's your pet's name?\n") #4. Combine the name of their ci...
true
1689f5917ee66e8fbdc904983a506f0afdfb06fc
tochukwuokafor/my_chapter_4_solution_gaddis_book_python
/bug_collector.py
285
4.15625
4
NUMBER_OF_DAYS = 5 total = 0 for day in range(NUMBER_OF_DAYS): print('Enter the number of bugs collected on day #' + str(day + 1) + ': ', sep = '', end = '') bugs_collected = int(input()) total += bugs_collected print('The total number of bugs collected is', total)
true
0d1890ddd1b000d26c4f5433970f2db1dc26090a
tochukwuokafor/my_chapter_4_solution_gaddis_book_python
/average_word_length.py
372
4.25
4
again = input('Enter a sentence or a word: ') total = 0 words_list = [] while again != '': words = again.split() for word in words: words_list.append(word) total += len(word) again = input('Enter another sentence or another word: ') average = total / len(words_list) print('The aver...
true
742ecea8c97e08e476b86cd4f5dcc38cab2bb947
era153/pyhton
/her.py
456
4.21875
4
name=int(input("no days employee1 work")) print("no days hour" , name) name1=int(input("no of hour employee1 work in first day")) print("no days hour" , name1) name2=int(input("no days hour employee1 work in second day")) print("no days hour" , name2) name3=int(input("no hour employee1 work in third day")) print("no da...
true
1504008a8d33a1bc1fcd9dcca04fcb05221e1eb6
hiteshpindikanti/Coding_Questions
/DCP/DCP140.py
950
4.125
4
""" This problem was asked by Facebook. Given an array of integers in which two elements appear exactly once and all other elements appear exactly twice, find the two elements that appear only once. For example, given the array [2, 4, 6, 8, 10, 2, 6, 10], return 4 and 8. The order does not matter. Follow-up: Can you...
true
9484cc99d76ae1d45dced6765fb9d850210ed1bc
hiteshpindikanti/Coding_Questions
/DCP/DCP9.py
1,348
4.21875
4
""" This problem was asked by Airbnb. Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10, since we pick 5 and 5. Follow-up: Can you do this ...
true
1f7e0f8e5af1f2f26af8d46cfdc55a235fed2168
hiteshpindikanti/Coding_Questions
/DCP/DCP61.py
512
4.25
4
""" This problem was asked by Google. Implement integer exponentiation. That is, implement the pow(x, y) function, where x and y are integers and returns x^y. Do this faster than the naive method of repeated multiplication. For example, pow(2, 10) should return 1024. """ def pow(base: int, power: int) -> int: ...
true
fcedd0fd56b0b84c51738c5e1fff640a6d79ffd5
hiteshpindikanti/Coding_Questions
/DCP/DCP46.py
1,148
4.1875
4
""" This problem was asked by Amazon. Given a string, find the longest palindromic contiguous substring. If there are more than one with the maximum length, return any one. For example, the longest palindromic substring of "aabcdcb" is "bcdcb". The longest palindromic substring of "bananas" is "anana". """ from copy ...
true
890055af08088ea6a059a404b41f58f5a858cd0c
hiteshpindikanti/Coding_Questions
/DCP/DCP102.py
684
4.125
4
""" This problem was asked by Lyft. Given a list of integers and a number K, return which contiguous elements of the list sum to K. For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it should return [2, 3, 4], since 2 + 3 + 4 = 9. """ from queue import Queue def get_sublist(l: list, k: int) -> list: ...
true
7134e0ee6a87054c906298ed87461d2e0d7af0eb
hiteshpindikanti/Coding_Questions
/DCP/DCP99.py
1,089
4.15625
4
""" This problem was asked by Microsoft. Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. Return its length: 4. Your algorithm should run in O(n) complexity. """ de...
true
793efcdcacb8e3d8865cfcca067fd02c52479fda
hiteshpindikanti/Coding_Questions
/DCP/DCP57.py
1,263
4.15625
4
""" This problem was asked by Amazon. Given a string s and an integer k, break up the string into multiple lines such that each line has a length of k or less. You must break it up so that words don't break across lines. Each line has to have the maximum possible amount of words. If there's no way to break the text up...
true
1bec2c55f061c3fd1f367ba492d0b580950583e3
santosh1561995/python-practice
/python-variables.py
429
4.125
4
print("For the datatypes in python an variable declaration") #in python data type will be calculated automtically no need to declare explicitly #integer type x=5 print(x) #float f=5.5 print(f) #multiple assignment to variable a=b=c=10 print(a,b,c) #assign values in one line a,b=1,"India" print(a,b) #Swapping t...
true
69cba86251ad064401c15b3a52c496026f0e8d3a
aliensmart/in_python_algo_and_dat_structure
/Code_1_1.py
738
4.46875
4
print('Welcome to GPA calculator') print('Please enter all your letter grades, one per line') print('Enter a blank line to designate the end.') #map from letter grade to point value points = { 'A+':4.0, 'A':4.0, 'A-':3.67, 'B+':3.33, 'B':3.0, 'B-':2.67, 'C+':2.33, 'C':2.0, 'C':1.67...
true
633cf9adaadad858607db184e9495e9a69d41937
aZuh7/Python
/oop.py
1,440
4.25
4
# Python Object-Oriented Programming class Employee: raise_amount = 1.04 num_of_emps = 0 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + "." + last + "@company.com" Employee.num_of_emps += 1 def f...
true
567c3b801b9679d4b30733df891d558e947fb65a
archisathavale/training
/python/basic_progs/min_max_nums.py
904
4.3125
4
#funtion of finding the minimum number def find_min_val(array): # assigning 1st element of array to minval minval=array[0] # traversing through the array for element in array: # to check whether the next element is smaller than the current if element < minval: # if yes assigning that number to minval ...
true
cee62cc8bd73c1f9be83e55fdc5e4c4ceb920a55
archisathavale/training
/python/Archis/addressbook.py
790
4.1875
4
addressbook={} # Empty Dictionary # Function of adding an address # email is the key and name is the value def add_address(email , name): addressbook [email] = name #print (addressbook) return (email, name) # Function of deleting an address # only key is enough to delete the value in a dictionary def dele_address(...
true
93d48b9b89f9ebaabe098bf46fcea589a96cd384
GuySK/6001x
/minFixPaymentCent.py
2,218
4.125
4
# This program calculates the minimum fixed payment to the cent # for cancelling a debt in a year with the interest rate provided. # minFixPaymentCent.py # def annualBalance(capital, annualInterestRate, monthlyPayment): ''' Calculates balance of sum after one year of fixed payments. Takes capital, interst r...
true
e19161d4378b326e7c2e9f2c0a570d1952f9fd2b
GuySK/6001x
/PS6/Answer/reverseString.py
524
4.46875
4
def reverseString(aStr): """ Given a string, recursively returns a reversed copy of the string. For example, if the string is 'abc', the function returns 'cba'. The only string operations you are allowed to use are indexing, slicing, and concatenation. aStr: a string returns: a reversed...
true
4e7410fee77d106caab46c92cb6e9d978bfb4376
GuySK/6001x
/PS6/Answer/buildCoder.py
661
4.40625
4
def buildCoder(shift): """ Returns a dict that can apply a Caesar cipher to a letter. The cipher is defined by the shift value. Ignores non-letter characters like punctuation, numbers, and spaces. shift: 0 <= int < 26 returns: dict """ import string lowcase = string.ascii_lowercase ...
true
2d9b308bb95891e46a2f5d6cf8b9a46e7f18e54b
GuySK/6001x
/PS4/Answers/bestWord.py
839
4.28125
4
def bestWord(wordsList): ''' Finds the word with most points in the list. wordsList is a list of words. ''' def wordValue(word): ''' Computes value of word. Word is a string of lowercase letters. ''' SCRABBLE_LETTER_VALUES = { 'a': 1, 'b': 3, 'c': 3, 'd':...
true
cec85a8e1acb2412389030e89ec6722bd9c83fbb
Mariappan/LearnPython
/codingbat.com/list_2/centered_average.py
977
4.125
4
# Return the "centered" average of an array of ints, which we'll say is the mean average of the values, # except ignoring the largest and smallest values in the array. If there are multiple copies of the smallest value, # ignore just one copy, and likewise for the largest value. # Use int division to produce the fin...
true
3bd5b189e5a3beb450efad8e39a346d7cd9300c3
lynellf/learing-python
/collections/slices.py
1,944
4.4375
4
# Sometimes we don't want an entie list or string, just a part. # A slice is a new list or string made from a previous list or string favorite_things = ['raindrops on roses', 'whiskers on kittens', 'bright coppeer kettles', 'warm woolen mittens', 'bright paper packages tied up with string', 'cream ...
true
5fd6323dab3a5e3221775e1be76bab49f7f3f68f
lynellf/learing-python
/python_basics/numbers.py
587
4.34375
4
# Numeric Data three = 1 + 2 print('The number %s' %(three)) # Rounding numbers _float = 0.233 + .442349 rounded = round(_float) print('A number is %s, and a rounded number is %s' %(_float, rounded)) # Converting strings to numbers string_num = '12' int_num = int(string_num) float_num = float(string_num) string_num_t...
true
6203dd89bad719a8003dd573f08865acb6301e10
arsummers/python-data-structures-and-algorithms
/challenges/comparator/comparator.py
1,060
4.3125
4
""" Comparators are used to compare two objects. In this challenge, you'll create a comparator and use it to sort an array. The Player class is provided in the editor below. It has two fields: name: a string. score: an integer. Given an array of n Player objects, write a comparator that sorts them in order of decreasi...
true
b937852ce70a3d673ec5d34f7d9b9f6f87a73617
arvakagdi/Basic-Algos
/IterativeBinarySearch.py
1,139
4.25
4
def binary_search(array, target): ''' Write a function that implements the binary search algorithm using iteration args: array: a sorted array of items of the same type target: the element you're searching for returns: int: the index of the target, if found, in the source ...
true
01dd8d67ceaad408cb442d882cf3c4c08f3eb445
eduardomrocha/dynamic_programming_problems
/tabulation/python/06_can_construct.py
1,574
4.25
4
"""Can construct. This script implements a solution to the can construct problem using tabulation. Given a string 'target' and a list of strings 'word_bank', return a boolean indicating whether or not the 'target' can be constructed by concatenating elements of 'word_bank' list. You may reuse elements of 'word_bank'...
true
326a3bc0283e5864a9b7f1930410749884f3fdbc
eduardomrocha/dynamic_programming_problems
/tabulation/python/08_all_construct.py
2,053
4.34375
4
"""All construct. This script implements a solution to the all construct problem using tabulation. Given a string 'target' and a list of strings 'word_bank', return a 2D list containing all of the ways that 'target' can be constructed by concatenating elements of the 'word_bank' list. Each element of the 2D list shou...
true
f6d6484b84550580fe2941e92fee20054c66d468
aakhedr/algo1_week2
/part3/quickSort3.py
2,470
4.21875
4
def quickSort(A, fileName): quickSortHelper(A, 0, len(A) - 1, fileName) def quickSortHelper(A, first, last, fileName): if first < last: pivot_index = partition(A, first, last, fileName) quickSortHelper(A, first, pivot_index - 1, fileName) quickSortHelper(A, pivot_index + 1, las...
true
f66e6d8773c886adb6c1932f8904ef545b2e2476
YuSheng05631/CrackingInterview
/ch4/4.5.py
1,184
4.15625
4
""" Implement a function to check if a binary tree is a binary search tree. """ import Tree def isBST(bt): if bt.left is None and bt.right is None: return True if bt.left is not None and bt.left.data > bt.data: return False if bt.right is not None and bt.right.data < bt.data: retur...
true
1c428f7cf06fa3b6113b2571221becade498a030
fire-ferrets/cipy
/cipy/alphabet/alphabet.py
1,452
4.46875
4
""" The Alphabet class provides a general framework to embed alphabets It takes a string of the chosen alphabet as attribute. This provides the encryption and decryption functions for the ciphers with a performance boost. """ class Alphabet(): def __init__(self, alphabet): """ Initialise an Alpha...
true
0c26e158842e1f3fcbd260a1115982c3a3303a6a
BenMarriott/1404
/prac_02/exceptions.py
1,036
4.28125
4
""" CP1404/CP5632 - Practical Answer the following questions: 1. When will a ValueError occur? When usings floating point numbers 2. When will a ZeroDivisionError occur? When attempting n/0 3. Could you change the code to avoid the possibility of a ZeroDivisionError? """ """"" try: numerator = int(input("En...
true
5a530c11bf9ff825ace09f85299d8ac1419ce7a3
nitishprabhu26/HackerRank
/Practice - Python/005_Loops.py
760
4.46875
4
if __name__ == '__main__': n = int(input()) for i in range(n): print(i**2) # The range() function # The range function is a built in function that returns a series of numbers. At a minimum, it needs one integer parameter. # Given one parameter, n, it returns integer values from 0 to n-1. For example...
true
219a8fe816e6bad703c55d6b75435fc761ace602
supriya1110vuradi/Python-Tasks-Supriyav
/task4.py
753
4.34375
4
# Write a program to create a list of n integer values and do the following # Add an item in to the list (using function) # Delete (using function) # Store the largest number from the list to a variable # Store the Smallest number from the list to a variable a = [1, 2, 3, 4, 5, 6] hi = max(a) lo = min(a) print(hi) pri...
true
8e488771b4e8aa522e9246dc9f50aec625dbd872
long2691/activities
/activity 5/comprehension.py
1,521
4.15625
4
prices = ["24", "13", "16000", "1400"] price_nums = [int(price) for price in prices] print(prices) print(price_nums) dog = "poodle" letters = [letter for letter in dog] print(letters) print(f"we iterate over a string into al ist : {letters}") capital_letters = [letter.upper() for letter in letters] #long version of s...
true
ccd5218382ffe23b84fffc1e0d137feb35b0ea18
andthenenteredalex/Allen-Downey-Think-Python
/thinkpy107.py
404
4.125
4
""" Allen Downey Think Python Exercise 10-7 This function checks if two words are anagrams and returns True if they are. """ def is_anagram(word_one, word_two): one = sorted(list(word_one)) two = sorted(list(word_two)) if one == two: return True elif one != two: return ...
true
aa0616170bc2dbbd2dca519e550437bb0365ac12
daviddlhz/holbertonschool-higher_level_programming
/0x0B-python-input_output/3-write_file.py
403
4.25
4
#!/usr/bin/python3 """write to a text file""" def write_file(filename="", text=""): """writes to a file Keyword Arguments: filename {str} -- name of file (default: {""}) text {str} -- text beingwritten (default: {""}) Returns: int -- number of charaters """ with open(filena...
true