blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0ebc30ff3f710310db361194090f163abcf9e8c7
MarsWilliams/PythonExercises
/How-to-Think-Like-a-Computer-Scientist/DataFiles.py
2,582
4.34375
4
#Exercise 1 #The following sample file called studentdata.txt contains one line for each student in an imaginary class. The student’s name is the first thing on each line, followed by some exam scores. The number of scores might be different for each student. #joe 10 15 20 30 40 #bill 23 16 19 22 #sue 8 22 17 14 32 17 ...
true
e59b96d2f3400e5f8b52cb8a26ee3e7479913d29
dhoshya/grokking-algorithms
/quickSort.py
440
4.15625
4
# D&C def quickSort(arr): # base case if len(arr) < 2: return arr else: pivot = arr[0] # using list comprehension less = [i for i in arr[1:] if i <= pivot] # using normal syntax greater = list() for i in arr[1:]: if i >= pivot: ...
true
e44f1c6cef22aedc4f5114c69f0260f2a37646a9
AniketKul/learning-python3
/ordereddictionaries.py
849
4.3125
4
''' Ordered dictionaries: they remember the insertion order. So when we iterate over them, they return values in the order they were inserted. For normal dictionary, when we test to see whether two dictionaries are equal, this equality os only based on their K and V. For ordered dictionary, when we test to see whethe...
true
f4451ce74fd1b6d16856f09f21f2eee9ae8c8f9a
jorricarter/PythonLab1
/Lab1Part2.py
523
4.125
4
#todo get input currentPhrase = input("If you provide me with words, I will convert them into a camelCase variable name.\n") #todo separate by word #found .title @stackoverflow while looking for way to make all lowercase wordList = currentPhrase.title().split() #todo all lowercase start with uppercase #found .title() t...
true
d51e758b43989603f02fc40214a03a970be2d4d1
KishorP6/PySample
/LC - Decission.py
1,362
4.34375
4
##Input Format : ##Input consists of 8 integers, where the first 2 integers corresponds to the fare and duration in hours through train, the next 2 integers corresponds to the fare and duration in hours though bus and the next 2 integers similarly for flight, respectively. The last 2 integers corresponds to the fare an...
true
ddeadc23b291498c7873533b16bf78c945670b2c
CStage/MIT-Git
/MIT/Lectures/Lecture 8.py
1,429
4.125
4
#Search allows me to search for a key within a sorted list #s is the list and e is what we search for #i is the index, and the code basically says that while i is shorter than the the #length of the list and no answer has been given yet (whether true or false) #then it should keep looking through s to see if it can fin...
true
9e11800cd87f7fa6c523cf6e0f6869e2ce59fb66
jacobeskin/Moon-Travel
/kuumatka_xv.py
1,828
4.25
4
import itertools import numpy as np import matplotlib.pyplot as plot # Numerical calculation and visualisation of the change in position # and velocity of a spacecraft when it travels to the moon. Newtons # law of gravitation and second law of motion are used. Derivative is # evaluated with simple Euler method. This ...
true
e050bf9dbde856f206bac59513c3a19e47e23a92
nwelsh/PythonProjects
/lesson3.py
408
4.28125
4
#Lesson 3 I am learning string formatting. String formatting in python is very similar to C. #https://www.learnpython.org/en/String_Formatting name = "Nicole" print("Hello, %s" % name) #s is string, d is digit, f is float (like c) age = 21 print("%s is %d years old" % (name, age)) data = ("Nicole", "Welsh", 21.1) f...
true
cad277b1a2ca68f6a4d73edc25c2680120b88137
tanvirtin/gdrive-sync
/scripts/File.py
1,380
4.125
4
''' Class Name: File Purpose: The purpose of this class is represent data of a particular file in a file system. ''' class File: def __init__(self, name = None, directory = None, date = None, fId = None, folderId = None, extension = ""): self.__name = name self.__directory = directory self.__date = date ...
true
caa33fdad5d9812eb473d03a497c46d6a0ad71f2
YasirQR/Interactive-Programming-with-python
/guess_number.py
1,963
4.21875
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import math import random import simplegui num_range = 100 count = 0 stop = 7 # helper function to start and restart the game def new_game(): #...
true
1c10a0791d3585aa56a5b6c88d133b7ea98a8b24
haydenbanting/LawnBot
/Mapping/mapping_functions/matrix_builder.py
2,029
4.25
4
''' Function for creating matricies for map routing algorithms Author: Kristian Melo Version: 15 Jan 2018 ''' ######################################################################################################################## ##Imports ##############################################################################...
true
66d85d4d119be319d62c133c1456c91a630291db
10zink/MyPythonCode
/HotDog/hotdog.py
1,624
4.1875
4
import time import random import Epic # Programmed by Tenzin Khunkhyen # 3/5/17 for my Python Class # HotDogContest #function that checks the user's guess with the actual winner and then returns a prompt. def correct(guess, winner): if guess.lower() == winner.lower(): statement = "\nYou gusses right, ...
true
0b18e86b3b5c414604e6cf3e35618770998043a9
10zink/MyPythonCode
/Exam5/Store.py
1,448
4.46875
4
import json import Epic # Programmed by Tenzin Khunkhyen # 4/16/17 for my Python Class # This program is for Exam 5 # This program just reads a json file and then prints information from a dictionary based on either # a category search or a keyword search. #This function reads the json file and converts it into a ...
true
c601c685111500976d62442a4e2be11bb928ee77
justdave001/Algorithms-and-data-structures
/SelectionSort.py
524
4.1875
4
""" Sort array using brute force (comparing value in array with sucessive values and then picking the lowest value """ #Time complexity = O(n^2) #Space complexity = O(1) def selection_sort(array): for i in range(len(array)): for j in range(i+1, len(array)): if array[i] > array[j]: ...
true
3c8df58e0135bd806acd5735d66bf42e718cd49d
signoreankit/PythonLearn
/numbers.py
551
4.1875
4
""" Integer - Whole numbers, eg: 0, 43,77 etc. Floating point numbers - Numbers with a decimal """ # Addition print('Addition', 2+2) # Subtraction print('Subtraction', 3-2) # Division print('Division', 3/4) # Multiplication print('Multiplication', 5*7) # Modulo or Mod operator - returns the remained after ...
true
3b6559c4f2511789a65a458111ba32103cf340a6
tjrobinson/LeoPython
/codes.py
2,373
4.21875
4
for x in range(0,2): userchoice = input("Do you want to encrypt or decrypt?") userchoice = userchoice.lower() if userchoice == "encrypt": Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ" StringToEncrypt = input("Please enter a message to encrypt: ") StringToEncrypt =...
true
44d05ed22e742656562ce9179d63dee9cc2d8980
redjax/practice-python-exercises
/06-string-lists.py
567
4.375
4
""" Ask the user for a string and print out whether this string is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.) """ test = [0, 1, 2, 3, 4, 5] # print(test[::-1]) word_input = input("Enter a word, we'll tell you if it's a palindrome: ") def reverse_word(word): reve...
true
510de01b1b80cc1684faaf2441dd5154bdd52b7c
zaydalameddine/Breast-Cancer-Classifier
/breastCancerClassifier.py
1,959
4.125
4
# importing a binary database from sklearn from sklearn.datasets import load_breast_cancer # importing the splitting function from sklearn.model_selection import train_test_split # importing the KNeighborsClassifier from sklearn.neighbors import KNeighborsClassifier import matplotlib.pyplot as plt # loading the databs...
true
b0a6d7b51978c4ed6691bc4542e63d63f90fc36a
mirandaday16/intent_chatbot
/formatting.py
301
4.25
4
# Capitalizes the first letter of every word in a string, e.g. for city names # Parameters: a place name (string) entered by the user def cap_first_letters(phrase): phrase_list = [word[0].upper() + word[1:] for word in phrase.split()] cap_phrase = " ".join(phrase_list) return cap_phrase
true
adc452c82b5e6a0346987e640bcd8364578e0ac6
MLBott/python-fundamentals-student
/A1/243 assignment 1 Michael Bottom.py
1,909
4.125
4
""" Author: Michael Bottom Date: 1/14/2019 """ import math def lowestNumListSum(firstList, secondList): """ This function accepts two lists of numbers and returns the sum of the lowest numbers from each list. """ firstList.sort() secondList.sort() sumTwoLowest = firstList[0] + secondList...
true
93542a99082c9944497ae78bf2f4589d6985e56c
adithyagonti/pythoncode
/factorial.py
260
4.25
4
num=int(input('enter the value')) if num<0: print('no factorial for _ve numbers') elif num==0: print('the factorial of 0 is 1') else: fact=1 for i in range(1,num+1): fact= fact*i print("the factorial of", num,"is",fact)
true
b6456f6c87553fab9af92919b1505a90bf675ad8
geediegram/parsel_tongue
/ozioma/sleep_schedule.py
651
4.15625
4
# Ann inputs the excepted hours of sleep, the excess no of hours and no of sleep hours # First number is always lesser than the second number # If sleep hour is less than first number, display "Deficiency" # If sleep hour is greater than second number, display "Excess" # If sleep hour is greater than sleep hour and les...
true
2edfabb63a04e58a1987cb9935140691549c1911
geediegram/parsel_tongue
/goodnew/main.py
1,443
4.46875
4
from functions import exercise if __name__ == "__main__": print(""" Kindly choose any of the options to select the operation to perform 1. max_of_three_numbers 2. sum_of_numbers_in_a_list 3. product_of_numbers_in_a_list 4. reverse-string 5. factorial_of_number ...
true
5f24adb4960ef8fbe41b5659321ef59c1143d2b1
geediegram/parsel_tongue
/Emmanuel/main.py
877
4.28125
4
from functions import exercise if __name__== "__main__": print(""" 1. Check for maximum number 2. Sum of numbers in a list 3. Multiple of numbers in a list 4. Reverse strings 5. Factorial of number 6. Number in given range 7. String counter 8. List un...
true
6e456e8a3206d57ab9041c2cbc00013701ed3345
geediegram/parsel_tongue
/ozioma/positive_and_negative_integer.py
363
4.5625
5
# take a number as input # if the number is less than 0, print "Negative!" # if the number is greater than 0, print "Positive!" # if the number is equal to 0, print "Zero!" print('Enter a value: ') integer_value = int(input()) if integer_value < 0: print('Negative!') elif integer_value > 0: print('Positive!') ...
true
4dfbf66266a20143fc1f3ef6095dbe11b995f3e3
victorkwak/Projects
/Personal/FizzBuzz.py
884
4.1875
4
# So I heard about this problem while browsing the Internet and how it's notorious for stumping like 99% # of programmers during interviews. I thought I would try my hand at it. After looking up the specifics, # I found that FizzBuzz is actually a children's game. # # From Wikipedia: Fizz buzz is a group word game for ...
true
b05ab548d4bb352e48135c2a0afd2a4a6251e9ea
whencespence/python
/unit-2/homework/hw-3.py
282
4.25
4
# Write a program that will calculate the number of spaces in the following string: 'Python Programming at General Assembly is Awesome!!' string = 'Python Programming at General Assembly is Awesome!!' spaces = 0 for letter in string: if letter == ' ': spaces += 1 print(spaces)
true
cfeb8cd2427bfac3c448c16eb217e3d01152d005
bm7at/wd1_2018
/python_00200_inputs_loops_lists_dicts/example_00920_list_methods_exercise.py
336
4.34375
4
# create an empty list called planets # append the planet "earth" to this list # print your list planet_list = [] # append planet_list.append("earth") print planet_list # [1, 2, 3, 4, 5] # now extend your planets list # with the planets: "venus", "mars" # print your list planet_list.extend(["venus", "mars"]) pri...
true
dfc679815218037a7d1926ad153c23875d61dd64
Mwai-jnr/Py_Trials
/class_01/l28.py
735
4.34375
4
#if statements ## start name = "victor" if name == "victor": print("you are welcome") else: print('you are not welcome') # example 2 age = '15' if age <= '17': print("you are under age") else: print("you can visit the site") # example 3 # two if statements age = '17' if age <='17': ...
true
66948e9a7ce8e8114d8a492300d48506a2e4c30b
Mwai-jnr/Py_Trials
/class_01/L37.py
854
4.46875
4
# Loops. # For Loop. #Example 1 #for x in range (0,10): # print('hello') #Example 2 #print(list(range(10,20))) # the last no is not included when looping through a list #Example 3 #for x in range(0,5): # print('Hello %s' % x) # %s acts as a placeholder in strings #it is used when you want to ins...
true
6bbe9e80f879c703b375b52b8e8b3ca5ea16b9f5
deepakkmr896/nearest_prime_number
/Nearby_Prime.py
998
4.1875
4
input_val = int(input("Input a value\n")) # Get the input from the entered number nearestPrimeNum = []; # Define a function to check the prime number def isPrime(num): isPrime = True for i in range(2, (num // 2) + 1): if(num % i == 0): isPrime = False return isPrime # Assuming 10 as th...
true
a9067a7adee78d3a72e2cd379d743dd360ed2795
joelamajors/TreehouseCourses
/Python/Learn Python/2 Collections/4 Tuples/intro_to_tuples.py
578
4.5625
5
my_tuple = (1, 2, 3) # tuple created my_second_tuple = 1, 2, 3 # this is a tuple too # the commas are necesary! my_third_tuple = (5) # not a tuple my_third_tuple = (5,) # parenthesis are not necessary, but helpful. dir(my_tuple) # will give you all the stuff you can do. Not much! # you can edit _stuff_ within a ...
true
8824bf993e2383393d16357e6a318fd27e8e0525
joelamajors/TreehouseCourses
/Python/Learn Python/2 Collections/5 Sets/set_math_challenge.py
2,248
4.4375
4
# Challenge Task 1 of 2 # Let's write some functions to explore set math a bit more. # We're going to be using this # COURSES # dict in all of the examples. # _Don't change it, though!_ # So, first, write a function named # covers # that accepts a single parameter, a set of topics. # Have the function return a list of...
true
e0dc49212a72b8f58ba69c192bf48e41718d93c5
brian-sherman/Python
/C859 Intro to Python/Challenges/11 Modules/11_9 Extra Practice/Task1.py
434
4.21875
4
""" Complete the function that takes an integer as input and returns the factorial of that integer from math import factorial def calculate(x): # Student code goes here print(calculate(3)) #expected outcome: 6 print(calculate(9)) #expected outcome: 362880 """ from math import factorial def calculate(x): f = ...
true
4b775221b8af334d4b2f8b9af0c64ecd2d3c9724
brian-sherman/Python
/C859 Intro to Python/Challenges/09 Lists and Dictionaries/9_5_1_Multiplication_Table.py
548
4.25
4
""" Print the two-dimensional list mult_table by row and column. Hint: Use nested loops. Sample output for the given program: 1 | 2 | 3 2 | 4 | 6 3 | 6 | 9 """ mult_table = [ [1, 2, 3], [2, 4, 6], [3, 6, 9] ] for row in mult_table: for element in row: list_len = len(row) current_id...
true
fd3d0f0a14900b339535fc94ef21b59619ba66e1
brian-sherman/Python
/C859 Intro to Python/Challenges/06 Loops/6_8_2_Histogram.py
797
4.96875
5
""" Here is a nested loop example that graphically depicts an integer's magnitude by using asterisks, creating what is commonly called a histogram: Run the program below and observe the output. Modify the program to print one asterisk per 5 units. So if the user enters 40, print 8 asterisks. num = 0 while num >= 0...
true
6da6609432fd57bc89e4097da96dcd60e80cb94c
brian-sherman/Python
/C859 Intro to Python/Challenges/09 Lists and Dictionaries/9_15_1_Nested_Dictionaries.py
2,843
4.96875
5
""" The following example demonstrates a program that uses 3 levels of nested dictionaries to create a simple music library. The following program uses nested dictionaries to store a small music library. Extend the program such that a user can add artists, albums, and songs to the library. First, add a command that ...
true
ffd50de6b5a8965a8b34db611bd115d2939df135
brian-sherman/Python
/C859 Intro to Python/Challenges/09 Lists and Dictionaries/9_3_1_Iteration.py
1,068
4.4375
4
""" Here is another example computing the sum of a list of integers. Note that the code is somewhat different than the code computing the max even value. For computing the sum, the program initializes a variable sum to 0, then simply adds the current iteration's list element value to that sum. Run the program below...
true
f1b2c6a2815b2621cab190582196521ec04da9e2
brian-sherman/Python
/C859 Intro to Python/Challenges/07 Functions/7_17_1_Gas_Volume.py
678
4.375
4
""" Define a function compute_gas_volume that returns the volume of a gas given parameters pressure, temperature, and moles. Use the gas equation PV = nRT, where P is pressure in Pascals, V is volume in cubic meters, n is number of moles, R is the gas constant 8.3144621 ( J / (mol*K)), and T is temperature in Ke...
true
0c123a95902de5efa3ecb815f22a3d242e376623
brian-sherman/Python
/C859 Intro to Python/Challenges/06 Loops/6_4_2_Print_Output_Using_Counter.py
330
4.46875
4
""" Retype and run, note incorrect behavior. Then fix errors in the code, which should print num_stars asterisks. while num_printed != num_stars: print('*') Sample output for the correct program when num_stars is 3: * * * """ num_stars = 3 num_printed = 0 while num_printed != num_stars: print('*') num_pri...
true
de8809d34f4bd91b00fb0b56d2835b3464c6ce3a
brian-sherman/Python
/C859 Intro to Python/Challenges/08 Strings/8_4_5_Area_Code.py
256
4.21875
4
""" Assign number_segments with phone_number split by the hyphens. Sample output from given program: Area code: 977 """ phone_number = '977-555-3221' number_segments = phone_number.split('-') area_code = number_segments[0] print('Area code:', area_code)
true
2f13722b0bd4d477768080b375bdd904af9da065
brian-sherman/Python
/C859 Intro to Python/Challenges/08 Strings/8_6 Additional Practice/Task_2_Reverse.py
294
4.21875
4
# Complete the function to return the last X number of characters # in the given string def getLast(mystring, x): str_x = mystring[-x:] return str_x # expected output: IT print(getLast('WGU College of IT', 2)) # expected output: College of IT print(getLast('WGU College of IT', 13))
true
0416f7bd9af4ef2845a77eb966ab0a21afd7fd64
brian-sherman/Python
/C859 Intro to Python/Boot Camp/Week 1/2_Calculator.py
1,871
4.4375
4
""" 2. Basic Arithmetic Example: Write a simple calculator program that prints the following menu: 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Quit The user selects the number of the desired operation from the menu. Prompt the user to enter two numbers and return the calculation result. Exa...
true
444195237db2c8f053a44b172038335f9d02567e
brian-sherman/Python
/C859 Intro to Python/Challenges/06 Loops/6_8_1_Print_Rectangle.py
256
4.5
4
""" Write nested loops to print a rectangle. Sample output for given program: * * * * * * """ num_rows = 2 num_cols = 3 for row in range(num_rows): print('*', end=' ') for column in range(num_cols - 1): print('*', end=' ') print('')
true
3cf756ebdd38a6a5ff233af1ba998c12f7ed1fa3
brian-sherman/Python
/C859 Intro to Python/Boot Camp/Week 1/8_Tuple_Example.py
534
4.625
5
""" 8. Tuple Example: Read a tuple from user as input and print another tuple with the first and last item, and your name in the middle. For example, if the input tuple is ("this", "is", "input", "tuple"), the return value should be ("this", "Rabor", "tuple") Example One: Enter your name to append into the tuple: ...
true
68150df94d2940bb980649e15c56a07194cb59fb
imharrisonlin/Runestone-Data-Structures-and-Algorithms
/Algorithms/Sorting/Quick_Sort.py
2,138
4.21875
4
# Quick sort # Uses devide and conquer similar to merge sort # while not using additional storage compared to merge sort (creating left and right half of the list) # It is possible that the list may not be divided in half # Recursive call on quicksortHelper # Base case: first < last (if len(list) <= 1 list is sorted) #...
true
ce1e57eb3168263137047a967c2223b65017ec89
kzmorales92/Level-2
/M3P2a.py
250
4.3125
4
#Karen Morales # 04/22/19 #Mod 3.2b #Write a recursive function to reverse a list. fruitList = ["apples", "bananas", "oranges", "pears"] def reverse (lst) : return [ lst[-1]]+ reverse (lst[:-1]) if lst else [] print (reverse(fruitList))
true
85d986e6a42307635cd237b666f0724a27537b16
claudiogar/learningPython
/problems/ctci/e3_5_sortStack.py
1,024
4.15625
4
# CTCI 3.5: Write a program to sort a stack such that the smallest items are on the top. You can use an additional temporary stack, but you may not copy the elements into any other data structure. The stack supports the following operations: push, pop, peek, and isEmpty. class SortedStack: def __init__(self): ...
true
4e9dcaa32b8662fb64d27faa933a01d47cc0caf8
Harjacober/HackerrankSolvedProblems
/Python/Regex Substitution.py
311
4.15625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import re def substitution(string): string = re.sub(r'((?<=\s)&&(?=\s))','and', string) string = re.sub(r'(?<=\s)\|\|(?=\s)','or', string) return string N = int(input()) for i in range(N): print(substitution(input()))
true
45063d790455032ec43c9407c1e71b4453845f5d
adityarsingh/python-blockchain
/backend/util/cryptohash.py
799
4.15625
4
import hashlib #it is library that includes the sha256 function import json def crypto_hash(*args): """ This function will return SHA-256 hash of the given arguments. """ stringed_args = sorted(map(lambda data: json.dumps(data),args)) #Lambda functions can have any number of arguments but only one ex...
true
968e67c487bc93767de11e74957b8af63e716fe9
vjishnu/python_101
/quadratic.py
591
4.15625
4
from math import sqrt #import sqrt function from math a = int(input("Enter the 1st coifficient")) # read from user b = int(input("Enter the 2st coifficient")) # read from user c = int(input("Enter the 3st coifficient")) # read from user disc = b**2 - 4*a*c # to find the discriminent disc1 = sqrt(disc)# thn find the...
true
fd7b805579cf158999eebd8cb269c0de1f288b80
lucasgcb/daily
/challenges/Mai-19-19/Python/solution.py
815
4.15625
4
def number_finder(number_list): """ This finds the missing integer using 2O(n) if you count the set operation. """ numbers = list(set(number_list)) ## Order the list # Performance of set is O(n) # https://www.oreilly.com/library/view/high-performance-python/9781449361747/ch04.html expected_i...
true
9fbf85740e7f3aa9f1e438ff0a51c5939294dac4
Meenawati/competitive-programming
/dict_in_list.py
522
4.40625
4
# Write a Python program to check if all dictionaries in a list are empty or not def dict_in_list(lst): for d in lst: if type(d) is not dict: print("All Elements of list are not dictionary") return False elif d: return False return True print(dict_in_list(...
true
40d9f9e8e046e5b41d83213bbea3540365d123e0
alfem/gamespit
/games/crazy-keys/__init__.py
1,577
4.15625
4
#!/usr/bin/python # -*- coding: utf8 -*- # Crazy Keys # My son loves hitting my keyboard. # So I made this silly program to show random colors on screen. # And maybe he will learn the letters! :-) # Author: Alfonso E.M. <alfonso@el-magnifico.org> # License: Free (GPL2) # Version: 1.0 - 8/Mar/2013 import ran...
true
da4199473308b99e312b5b542252423592417d85
nabrink/DailyProgrammer
/challenge_218/challenge_218.py
342
4.15625
4
def to_palindromic(number, step): if len(number) <= 1 or step > 1000 or is_palindromic(number): return number else: return to_palindromic(str(int(number) + int(number[::-1])), step + 1) def is_palindromic(number): return number == number[::-1] number = input("Enter a number: ") print(to_pa...
true
5c5625cca2c934141df40410f1496302c699da06
brasqo/pyp-w1-gw-language-detector
/language_detector/main.py
846
4.125
4
#!/usr/bin/python # -*- coding: utf-8 -*- from collections import defaultdict import operator """This is the entry point of the program.""" def detect_language(text, languages): """Returns the detected language of given text.""" # implement your solution here # create dictionary with same keys as l...
true
3f115dc4d77c49f3827e26674bac162ae8613b57
CodesterBoi/My-complete-works
/File Handling.py
2,273
4.125
4
''' #Reading from a file: car_name = input("Which car's stats do you want to display?") t = open("Car_stats.txt","r") end_of_file = False print(car_name) car_name = True while True: car_name = t.readline().strip() speed = t.readline().strip() acceleration = t.readline().strip() handling =...
true
067dc51bc622e4e7514fc72c0b8b4626db950da5
amitp29/Python-Assignments
/Python Assignments/Assignment 3/question12.py
1,237
4.34375
4
''' Read 10 numbers from user and find the average of all. a) Use comparison operator to check how many numbers are less than average and print them b) Check how many numbers are more than average. c) How many are equal to average. ''' num_list = [] sum_of_num = 0 for i in range(10): while True: try: ...
true
45bcaf8e7ddb54e50dc916ee8ae1604345c27072
amitp29/Python-Assignments
/Python Assignments/Assignment 3/question20.py
835
4.34375
4
''' Write a program to generate Fibonacci series of numbers. Starting numbers are 0 and 1, new number in the series is generated by adding previous two numbers in the series. Example : 0, 1, 1, 2, 3, 5, 8,13,21,..... a) Number of elements printed in the series should be N numbers, Where N is any +ve integer. ...
true
874f3d5621af8a3cd128bd2d06e30cfe6bb3f0c5
amitp29/Python-Assignments
/Python Assignments/Assignment 3/question7.py
430
4.21875
4
''' Create a list with at least 10 elements in it :- print all elements perform slicing perform repetition with * operator Perform concatenation wiht other list. ''' #perform repetition with * operator list1 = [1]*7 list2 = [4,5,6] #Perform concatenation with other list list3 = list1+list2...
true
7545be7a5decce69dd33717fc7a77ca5848e6a3d
amitp29/Python-Assignments
/Python Assignments/Assignment 2/question3.py
942
4.15625
4
''' 4. Given a list of strings, return a list with the strings in sorted order, except group all the strings that begin with 'x' first. e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields ['xanadu', 'xyz', 'aardvark', 'apple', 'mix']. Hint: this can be done by m...
true
1dca7820586525dcd22cebeb2d851eb1d2bf8c42
SJasonHumphrey/DigitalCrafts
/Python/Homework004/word_histogram.py
958
4.3125
4
# 2. Word Summary # Write a word_histogram program that asks the user for a sentence as its input, and prints a dictionary containing # the tally of how many times each word in the alphabet was used in the text. wordDict = {} sentence = input('Please enter a sentence: ') def wordHistogram(sentence): for word in s...
true
f37f41087fd970146217e4b32a16f0d3af7d9b5e
naolwakoya/python
/factorial.py
685
4.125
4
import math x = int(input("Please Enter a Number: ")) #recursion def factorial (x): if x < 2: return 1 else: return (x * factorial(x-1)) #iteration def fact(n, total=1): while True: if n == 1: return total n, total = n - 1, total * n def factorial(p): if p ==...
true
05bf4280a7750cf207609ae63ed15f1cee96843f
jkfer/Codewars
/logical_calculator.py
1,602
4.40625
4
""" Your task is to calculate logical value of boolean array. Test arrays are one-dimensional and their size is in the range 1-50. Links referring to logical operations: AND, OR and XOR. You should begin at the first value, and repeatedly apply the logical operation across the remaining elements in the array sequenti...
true
b3a0608ad6899ac13e9798ecf4e66c597f688bd1
jkfer/Codewars
/valid_paranthesis.py
1,071
4.3125
4
""" Write a function called that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return true if the string is valid, and false if it's invalid. Examples "()" => true ")(()))" => false "(" => false "(())((()())())" => t...
true
f6d7508e322f3248106378483dd377e9ee7ac9e8
YaserMarey/algos_catalog
/dynamic_programming/count_factors_sets.py
1,410
4.15625
4
# Given a number 'n' # Count how many possible ways there are to express 'n' as the sum of 1, 3, or 4. # Notice that {1,2} and {2,1} are two methods and not counted as one # Pattern Fibonacci Number def CFS(Number): dp = [0 for _ in range(Number + 1)] dp[0] = 1 # if number = 0 then there is only set ...
true
5871c7a813bddf1480a681d08b2ee5d1d76c52d7
YaserMarey/algos_catalog
/dynamic_programming/count_of_possible_way_to_climb_stairs.py
1,035
4.1875
4
# Given a stair with ‘n’ steps, implement a method to count how many # possible ways are there to reach the top of the staircase, # given that, at every step you can either take 1 step, 2 steps, or 3 steps. # Fib Pattern def CS(S): T = [0 for i in range(S + 1)] T[0] = 1 T[1] = 1 T[2] = 2 ...
true
5d671a339e350f8a3c039ed153667496f6f5850c
burnbrigther/py_practice
/ex15_2.py
687
4.46875
4
# imports the argv feature from the sys package from sys import argv # Takes input values from argv and squishes them together (these are the two command line items) # then unpacks two arguments sent to argv and assigns them to script and filename script, filename = argv # Takes the value from the command line argumen...
true
978a2fdf4c8dd6ec10b53d88591c18b452ec29ca
OluchiC/PythonLab1
/Lab1.py
925
4.21875
4
sentence = 'I can’t wait to get to School_Name! Love the idea of meeting new Noun and making new Noun! I know that when Number years pass, I will be Age and I will have a degree in Profession. I hope to make my family proud! Am I done with this MadLib Yet?: Boolean.' school_name = input('What\'s the school name?') mee...
true
9bf71c7546e14fcade018ff905880acd633547e9
rainakdy1009/Prog11
/dragon games.py
2,525
4.21875
4
import random import time def displayIntro(): #Explain the situation print('''You are in a land full of dragons. In front of you, you see two caves. In one cave, the dragon is friendly and will share his treasure with you. The other dragon is greedy and hungry, and will eat you on sight.''') print() ...
true
342ca3b9f92f9adf562bf6fd4b5278305e466255
jessegtz7/Python-Learning-Files
/Strings.py
1,018
4.15625
4
name = 'Ivan' age = 29 #**Concateante** ''' print('His name is ' + name + ' and he is ' + age) -- this will result as a "TypeError: can only concatenate str (not "int") to str" age mus be cast in to a str ''' print('His name is ' + name + ' and he is ' + str(age)) #**String format** #1.- Arguments by position. print...
true
76ab13972c5734bc324efb8b53482705ae990746
irtefa/bst
/simple_bst.py
1,142
4.1875
4
from abstract_bst import AbstractBst class SimpleBst(AbstractBst): # A simple compare method for integers # @given_val: The value we are inserting or looking for # @current_val: Value at the current node in our traversal # returns an integer where # -1: given_val is less than current_val # 1: given_val is grea...
true
c1ad1d4d22f1edfe5bd439118e7c79fc67d7567d
romanticair/python
/basis/Boston-University-Files/AllAnswer/Assignment_9_Answer/a3_task1.py
2,967
4.125
4
# Descriptive Statistice # Mission 1. def mean(values): # Take as a parameter a list of numbers, calculates4 # and returns the mean of those values sumValues = 0 for value in values: sumValues += value return sumValues / len(values) # Mission 2. def variance(values): # Take as a parame...
true
dff8367263ee46866a30dd2fcb8e241d07968d21
chsclarke/Python-Algorithms-and-Data-Structures
/coding_challenge_review/array_practice.py
885
4.28125
4
def mergeSorted(arr1, arr2): #code to merge two sorted arrays sortedArr = [None] * (len(arr1) + len(arr2)) i = 0 j = 0 k = 0 #iterate through both list and insert the lower of the two while(i < len(arr1) and j < len(arr2)): # <= allows function to support duplicate values i...
true
589ff4948bafda92c5f6007c693dd42b4ec5853c
Abel237/automate-boring-stuffs
/automate_boring_stuffs/automate.py
1,384
4.15625
4
# This program says hello and asks for my name. # print('Hello, world!') # print('What is your name?') # ask for their name # myName = input() # print('It is good to meet you, ' + myName) # print('The length of your name is:') # print(len(myName)) # print('What is your age?') # ask for their age # myAge...
true
d8326d7dd0f2ea05957104c482bacf2776968aff
optionalg/HackerRank-8
/time_conversion.py
987
4.125
4
''' Source: https://www.hackerrank.com/challenges/time-conversion Sample input: 07:05:45PM Sample output: 19:05:45 ''' #!/bin/python import sys def timeConversion(s): meridian = s[-2] time = [int(i) for i in s[:-2].split(':')] # Converting each time unit to integer and obtaining # each unit by split...
true
9bc2d5011ccdacbf7e172ab4c0245c8b5f437f3f
harrowschool/intro-to-python
/lesson3/task2.py
620
4.3125
4
# Task 2a # Add comments to the code to explain: # What will be output when the code is run? # In what circumstances would the other output message be produced num1 = 42 if num1 == 42: print("You have discovered the meaning of life!") else: print("Sorry, you have failed to discover the meaning of life!") ...
true
9c6a978c2595de1301aef97991389bb02cb9855f
skipdev/python-work
/assignment-work/jedi.py
554
4.15625
4
def jedi(): #Display the message "Have you fear in your heart?" print("Have you fear in your heart?") #Read in the user’s string. response = input(str()) #The program will then decide if the user can be a Jedi or not, based on their response. if response.lower() == "yes": print("Fear is the path t...
true
b76cdc2e8a3bf58989bd280c7f3d82810c67f153
skipdev/python-work
/assignment-work/jumanji.py
543
4.28125
4
number = 0 #Display the message "How many zones must I cross?" print("How many zones must I cross?") #Read in the user’s whole number. number = int(input()) #Display the message "Crossing zones...". print("Crossing zones...") #Display all the numbers from the user's whole number to 1 in the form "…crossed zone [num...
true
072bac7e650722c717a17abfa2bc288fde93e0f2
skipdev/python-work
/work/repeating-work.py
219
4.25
4
#Get the user's name name = str(input("Please enter your name: ")) #Find the number of characters in the name (x) x = len(name) #Use that number to print the name x amount of times for count in range(x): print(name)
true
04a15af1fcb1ffccb529a4321c499c5bd1b88d04
skipdev/python-work
/work/odd-even.py
238
4.375
4
#Asking for a whole number number = (int(input("Please enter a whole number: "))) #Is the number even or odd? evenorodd = number % 2 #Display a message if evenorodd == 0: print("The number is even") else: print("The number is odd")
true
f2b76267a6fcd9f60e5c1c4745a8362ed3c9bd27
MrT3313/Algo-Prep
/random/three_largest_numbers/✅ three_largest_numbers.py
1,413
4.34375
4
# - ! - RUNTIME ANALYSIS - ! - # ## Time Complexity: O(n) ## Space Complexity: O(1) # - ! - START CODE - ! - # # - 1 - # Define Main Function def FIND_three_largest_numbers(array): # 1.1: Create data structure to hold final array finalResult = [None, None, None] # 1.2: Loop through each item in the chec...
true
3c84466bc01a6b2a5ddbd595fbb6dcb107b40e74
MrT3313/Algo-Prep
/⭐️ Favorites ⭐️/Sort/⭐️ bubbleSort/✅ bubbleSort.py
590
4.21875
4
def bubbleSort(array): isSorted = False counter = 0 # @ each iteration you know the last num is in correct position while not isSorted: isSorted = True # -1 : is to prevent checking w/ out of bounds # counter : makes a shorter array each iteration for i in range(len(array)...
true
71dc3f9110ad21660a526284e6b58b8834729e7a
ashNOLOGY/pytek
/Chapter_3/ash_ch3_coinFlipGame.py
799
4.25
4
''' NCC Chapter 3 The Coin Flip Game Project: PyTek Code by: ashNOLOGY ''' import math import random #Name of the Game print("\nThe Coin Flip Game" "\n------------------\n") #Set up the Heads & Tails as 0 h = 0 t = 0 #ask user how many flips should it do howMany = int(input("How many fli...
true
a494320f224a78e13f565b69e7aebd406709c979
RanabhatMilan/SimplePythonProjects
/GussingNum/guessing.py
880
4.25
4
# This is a simple guessing game. # At first we import a inbuilt library to use a function to generate some random numbers import random def guess_num(total): number = random.randint(1, 10) num = int(input("Guess a number between 1 to 10: ")) while num != number: if num > number: num = ...
true
cf64c6a26c86f5af34c39f617763757d4ab270ed
bushki/python-tutorial
/tuples_sets.py
1,801
4.53125
5
# tuple - collection, unchangeable, allows dupes ''' When to use tuples vs list? Apart from tuples being immutable there is also a semantic distinction that should guide their usage. Tuples are heterogeneous data structures (i.e., their entries have different meanings), while lists are homogeneous sequences. Tuples...
true
757c5b54164ebe279401ef9cb63e920715352258
xatrarana/python-learning
/PYTHON programming/3.dictonary in python/dict problemss.py
269
4.15625
4
## i have to get the sentance as input form the user and cout the user input.. #sentence -> input,key->word, value->length of the word sent=input("Enter the sentence") words=sent.split(" ") count_words={words:len(words) for words in words} print(count_words)
true
635385f3da34913511846c5f0010347b260aa5fa
houckao/grade-calculator-python
/grades_calculator.py
1,598
4.15625
4
""" This is a library of functions designed to be useful in a variety of different types of grade calculations. """ # import support for type hinting the functions from typing import List, Dict def average(grades: List[float]) -> float: """Calculates the average of an array of grades, rounded to 2 decimal places ...
true
7bda8a77649f5832e637e38a7f7564cc0b2fd4d1
qihong007/leetcode
/2020_03_04.py
1,138
4.3125
4
''' Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string. You can assume the string has only u...
true
3761089895083f5fb8111f5b8db218c81fa86d71
khushalj/GOOGLE-HASH-CODE-2021
/pizza.py
2,318
4.1875
4
#!/usr/bin/python3 #Function that prints the solution to send to the judge def imprimirsolucion(deliveries): # We print number of shipments print (len (deliveries)) for between in deliveries: #We print each shipment generating a string and finally printing it #First, we put the...
true
9a20562783968cda53b51396d3a55fc0072ff9d0
pouya-mhb/My-Py-projects
/OOP Practice/prac1.py
1,658
4.15625
4
# A class for dog informations dogsName = [] dogsBreed = [] dogsColor = [] dogsSize = [] dogsInformation = [dogsName, dogsBreed, dogsColor, dogsSize] #Create the class class Dog (): #methods # init method for intialization and attributes in () def __init__(self, dogBreed, name, dog...
true
d779c188dbd38b81d162f126fe2f502e2dd671d6
adityagrg/Intern
/ques2.py
234
4.3125
4
#program to calculate the no. of words in a file filename = input("Enter file name : ") f = open(filename, "r") noofwords = 0 for line in f: words = line.split() noofwords += len(words) f.close() print(noofwords)
true
343677c250f436b5095c72985eadd30da635da00
Young-Thunder/RANDOMPYTHONCODES
/if.py
206
4.1875
4
#!/usr/bin/python car = raw_input("Which car do you have") print "You have a " + car if car == "BMW": print "Its is the best" elif car =="AUDI": print "It is a good car" else: print "UNKNOWN CAR "
true
e535d1c452c734ab747fda28d116d4b5fe2f9325
gia-bartlett/python_practice
/practice_exercises/odd_or_even.py
431
4.375
4
number = int(input("Please enter a number: ")) # input for number if number % 2 == 0: # if the number divided by 2 has no remainder print(f"The number {number} is even!") # then it is even else: print(f"The number {number} is odd!") # otherwise, it is odd ''' SOLUTION: num = input("Enter a number: ") mo...
true
8596578006399b3095b2a572e3f08aa0789031ba
JavaPhish/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
340
4.28125
4
#!/usr/bin/python3 """ Adds 2 integers """ def add_integer(a, b=98): """ Adds A + B and returns """ if (type(a) is not int and type(a) is not float): raise TypeError("a must be an integer") if (type(b) is not int and type(b) is not float): raise TypeError("b must be an integer") retur...
true
a6b0b97119142fff91d2b99dc01c945d5409c799
JavaPhish/holbertonschool-higher_level_programming
/0x06-python-classes/4-square.py
873
4.125
4
#!/usr/bin/python3 """ AAAAAAHHHHH """ class Square: """ Square: a class. """ def __init__(self, size=0): """ Init - init method """ if type(size) is not int: raise TypeError("size must be an integer") if size < 0: raise ValueError("size must be >= 0") ...
true
649b70c784a4bebd56897ba1f7b89fc98277a6e8
OlayinkaAtobiloye/Data-Structures
/Data Structures With OOP/linkedlist.py
2,391
4.3125
4
class Node: def __init__(self, value, next_=None): self.value = value self.next = next_ class LinkedList: """A linked list is a linear data structure. It consists of nodes. Each Node has a value and a pointer to a neighbouring node(i.e it links to it's neighbor) hence the name linked list....
true
59c9e4ce10bbfcff84f1d0b23d2938ea98e67783
motleytech/crackCoding
/RecursionAndDyn/tripleStep.py
568
4.1875
4
'''Count ways to get to nth step, given child can take 1, 2 or 3 steps at a time''' # let f(n) be the ways to get to step n, then # f(n) = f(n-1) + f(n-2) + f(n-3) def tripleStep(n): 'return number of ways to get to nth step' if 1 <= n <= 3: return n a, b, c = 1, 2, 3 n = n-3 while n > 0:...
true
0eaabc6474396fc098c038667a838bf486705375
motleytech/crackCoding
/arraysAndStrings/uniqueCharacters.py
1,703
4.21875
4
''' determine if a string has all unique characters 1. Solve it. 2. Solve it without using extra storage. Key idea: Using a dictionary (hashmap / associative array), we simply iterate over the characters, inserting each new one into the dictionary (or set). Before inserting a character, we check if it already exists...
true
e7d7975306ff4dc19aace83acc35a0b95172a3e0
motleytech/crackCoding
/arraysAndStrings/isStringRotated.py
788
4.125
4
''' Given 2 strings s1 and s2, and a method isSubstring, write a method to detect if s1 is a rotation of s2 The key ideas are... 1. len(s1) == len(s2) 2. s1 is a substring of s2 + s2 If the above 2 conditions are met, then s2 is a rotation of s1 ''' def isSubstring(s1, s2): ''' Returns True if s1 is a subst...
true