blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ea6d481fbc6767ece7f3066aa2907ef61e9e4f50
nlpet/topcoder
/quick_sums.py
1,840
4.21875
4
""" Problem Statement Given a string of digits, find the minimum number of additions required for the string to equal some target number. Each addition is the equivalent of inserting a plus sign somewhere into the string of digits. After all plus signs are inserted, evaluate the sum as usual. For example, consider the...
true
463d7f1ebb83c916a6549ce0089109c0de3165fa
mustafa7777/LPTHW
/ex30_2.py
1,219
4.3125
4
print "you walk into a dark room and there are two doors, choose a door, 1 or 2." door = raw_input("> ") if door == "1": print "there is an opening to a tunnel with some light at the end of it" print "what do you do now, go through the tunnel or go back to the dark room" print "enter '1' to leave throug...
true
8454b0c878b02861494d1001c960e3bc94bb8a32
kskirilov/python
/hangman.py
1,555
4.40625
4
""" Hangman Game This is probably the hardest one out of these 6 small projects. This will be similar to guessing the number, except we are guessing the word. The user needs to guess letters, Give the user no more than 6 attempts for guessing wrong letter. This will mean you will have to have a counter. You can do...
true
9642cddbc4b2bc5c3775bab6f5c3ed43de60bd93
ravigaur06/PythonProject
/set_methods/list_methods.py
749
4.3125
4
l1=[1,2,3] #append l1.append([4,5]) print ("Appended: {}".format(l1)) #clear l1.clear() print ("Cleared the list: {}".format(l1)) #copy import copy l1=[1,2,3,[4,5]] l2=l1.copy() print ("Copied : {}".format(l2)) l3=copy.deepcopy(l1) print ("Deep Copied: {}".format(l3)) #count #index print (l1[0]) #e...
true
d2c17efc197b2bbb1e5bef7f111b8b9ef82f3b0e
ericjsilva/programming-mb-python
/lab2/temp_convert_FtoC.py
817
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """temp_convert.py: Convert temperature F to C.""" # initialize looping variable, assume yes as first answer continueYN = "Y" while continueYN.upper() == "Y": # get temperature input from the user, and prompt them for what we expect degF = float(input("Enter tem...
true
3841e1a48c4b1f3a5bc25dfc6650b8f850001e7d
bhrgv/MissionRnD-Python-Course
/PythonCourse/unit2_assignment_03.py
2,441
4.25
4
__author__ = 'Kalyan' notes = ''' These are the kind of questions that are typically asked in written screening tests by companies, so treat this as practice! Convert the passed in positive integer number into its prime factorization form. If number = a1 ^ p1 * a2 ^ p2 ... where a1, a2 are primes and p1, p2 are powe...
true
4b6351eaf60a71cbd3253840f9b5bdfb7dcaf2db
tlpgalvao/learnpythonthehardway
/ex6.py
1,177
4.15625
4
#-*-coding:utf8;-*- #qpy:2 #qpy:console x = "There are %d types of people." % 10 # 10 will appear in the place of %d binary = "binary" # binary will appear when we call for binary do_not = "don't" # don't will appear when we call for do_not y = "Those who know %s and those who %s." % (binary, do_not) # the frist %s wi...
true
921f7c8362280941a3f20a927ff21c6ccb794082
2Irina2/Py-Codette
/programming_basics/part3/sol/shopping_list.py
1,049
4.28125
4
# Shopping List # Demonstrates list methods items = [] choice = None while choice != "0": print( """ High Scores 0 - Exit 1 - Show Items 2 - Add an Item 3 - Delete an Item 4 - Sort Items """ ) choice = input("Choice: ") print() # exit if choice == "0": ...
true
4a92f403e01fa36d070a4e0953e4ec6c7ccf470c
dhyoon1112/python_practiceproblems
/9. Guessing Game One.py
644
4.21875
4
import random as r print("Guess a number between 1 through 10. Type exit if you want to leave") count = 0 guess = "x" number = r.randint(1,10) while guess != number and guess != "exit": guess = input("Guess a number between 1 through 10: ") count += 1 if guess == "exit": print...
true
f7ad931926a23e2b1918846d9c37803e28cfec8e
nblase22/python-challenge
/PyParagraph/main.py
1,347
4.21875
4
import os import re # set up the txt file for import filename = input("Input the name of the file containing the paragraph to be read: ") paragraph_file = os.path.join('resources', filename) # pull the paragraph into python with open(paragraph_file, 'r') as txtFile: paragraph = txtFile.read().replace("\n", " ") ...
true
68280202a2655b34cf263755bedf7ba78b6b2872
nurseybushc/Udacity_IntroToSelfDrivingCars
/Module 2 - Bayesian Thinking/array_iteration_and_stopping.py
509
4.125
4
# This function takes in the road and determines where to stop def find_stop_index(road): ## TODO: Iterate through the road array ## TODO: Check if a stop sign ('s') is found in the array ## If one is, break out of your iteration ## and return the value of the index that is *right before* the stop sign ...
true
8f1a8ee476bc94da2d0045c246e019cfefa92774
SandroRolak/Learning.Python
/challenge1.py
297
4.125
4
print("Hello, Would you like to continue?") print("Click 1 for yes or 2 for no") resposta = int(input()) if resposta == 1 or resposta =="yes": print("Continuing...") elif resposta == 2 or resposta == "no": print("Exiting") else: print("Please try again and respond with yes or no.")
true
ac704e5a338499e8306b37b61899e056a9b83f66
Medtotech/Self-taught-
/List Overlap Comprehensions.py
611
4.1875
4
#Take two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] #write a program that returns a list that contains only the elements that are common between the lists (without duplicates). # Make sure your program works on two lists of diffe...
true
43eb4fbc3e5e5b669e027b9bf07125d821ce63c3
gaoxinrui/pyIKSFA
/source/Difference.py
1,571
4.46875
4
""" TODO finish the documentation once you are completely sure how it all works REMEMBER TO MENTION COLUMN MAJOR! @author G. Eli Jergensen <gelijergensen@ou.edu> - constructed following the paper by Stephen Liwicki et. al """ from abc import ABC, abstractmethod import numpy as np class Difference(ABC): @...
true
1bcea18d2e05f890cc5e543c2c9d8b0d2da9ced7
juliandunne1234/pands-problems-2020gmit
/w6_squareroot/w6_sqrtfunction.py
330
4.1875
4
# Calculate the suare root of a positive # floating point no. uusing the import # math sqrt function. import math def sqrt(): enternumber = float(input("Please enter a positive number: ")) squareroot = round(math.sqrt(enternumber), 4) print("The square root of", enternumber, "is approx.", squareroot) ...
true
2c8a11a731093485853d385c5a822de8e53d2f7d
juliandunne1234/pands-problems-2020gmit
/w4_collatz/collatz.py
383
4.34375
4
#This program takes a number and # completes a calculation based # on whether the number is even or odd. x = int(input("Please enter any number: ")) # Even number is divided by 2; # odd number is * 3 and then add 1. while x != 1: if x == 0: break elif x % 2 == 0: x = x / 2 else: ...
true
e802da45ce8362f08f7f6ef30e285e265ec2b698
Jake-Len/Rock-Paper-Scissors
/Rock Paper Scissors/HardMode.py
2,785
4.34375
4
#hard game mode import random past_player_choices = [] #storing past player choices past_computer_choices = [] #storing past computer choices #in hard mode, past choices are stored and evaluated to check for biases toward a certain choice. #the computer checks to see if the player uses one choice more than others and...
true
8e348b37fd04632686addbdc238affddad595945
timuchin51/tasks
/2_most_common_words/most_common_words.py
1,195
4.21875
4
#!/usr/bin/env python3 import re import operator from sys import argv def split_the_text(file_name): with open(file_name, 'r') as text_file: text = re.findall('(?i)[a-z\'?a-z]+', text_file.read()) words = set(text) counted_words = [(key, text.count(key)) for key in words] return sorted(counte...
true
f74fc1fdcc0a54ba213f1f2cb3c33d5229b85a9b
vassi95/HackBulgaria-101-Python
/Week7/2-SQL-Starter/manage.py
2,633
4.125
4
import sqlite3 from create import Table class Employees: def list_employees(self): conn = sqlite3.connect("Table.db") cursor = conn.cursor() result = cursor.execute("SELECT id, name, monthly_salary, yearly_bonus, possition FROM users") for i in result: print("{} | {} |...
true
9e2b2186f3f597c149457ecc7eb6cb04f333a3bc
adrianbeloqui/Python
/nested_lists.py
1,675
4.25
4
"""Given the names and grades for each student in a Physics class of N students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. Note: If there are multiple students with the same grade, order their names alphabetically and print each name on a new line. Input For...
true
f5a91d70052cf83da7e7c0343e19bdbc55bc1c34
adityakuppa26/Reinforcement-Learning
/lib/envs/random_walk.py
1,840
4.1875
4
import gym from gym import spaces from gym.utils import seeding class RandomWalk(gym.Env): """ This environment imports random walk environment. Two actions are possible: 0: Moves up the chain (Right) 1: Moves down the chain (Left) There are two terminal states location at both the ex...
true
14bad12dbe8116c80ce8f06b54fea032c438f027
AshaEswarappa/Python_Codes
/Fibonacci/fibonacci.py
279
4.3125
4
#!/usr/bin/env python3 def Fib(N): x, y = 0, 1 #initialize the variables while (y < N): print(y, end = ' ', flush =True) x, y = y, x+y N = int(input("Enter the number for which you need fibonacci series: ")) print(" The Fibonacci series for {} is : ". format(N)) Fib(N)
true
2ca87e4db818f51d4ba25ebc9124fc5ef40d1e42
s-ruby/uxr_spring_2021
/challenges/25_oop_exceptions_review/checking_challenge_solutions.py
2,524
4.1875
4
print('Question 1') class CheckingAccount(): def __init__(self, account_holder, account_number): self.account_holder = account_holder self.account_number = account_number self.withdrawal_limit = 2000 self.balance = 0 ''' 1.1 Create method 'deposit' that adds to the account ba...
true
849001ed62252fae0a25b1b7570955e3c8fe94d7
s-ruby/uxr_spring_2021
/challenges/unit_testing_fall_2020/music_playlist_functions.py
2,880
4.28125
4
''' THESE FIRST THREE FUNCTIONS ARE FROM LAST CHALLENGE THEY SHOULD NOT NEED TO BE CHANGED ''' # prints out what is in your playlist # takes one argument: 'playlist' (a list) def display_playlist(playlist): if len(playlist) == 0: print('Playlist is empty!') else: for i in range(len(playlist)): print(f'Track {...
true
5d4db97ee46df54264293ef49c71d07685c7d1ff
MasterLee028/homework
/7-1,2,3,4,5,8,9,10.py
2,043
4.1875
4
#7-1 car = input("Please tell me what car do you want to rent: ") print("\n"+car.title()) #7-2 number = input("how many people come to eat? ") number = int(number) if number >8: print("There is no empty seats!") else: print("We have enough seat!") #7-3 number = input("Please enter a number: ") numbe...
true
701b26e89a50bdd8be4c322d0a897555902b672d
Serg-Protsenko/GH_Python
/HT_01/Task_06.py
482
4.375
4
''' 6. Write a script to check whether a specified value is contained in a group of values. Test Data : 3 -> [1, 5, 8, 3] : True -1 -> (1, 5, 8, 3) : False ''' our_list = [1, 5, 8, 3] our_tuple = (1, 5, 8, 3) value = 3 check = False if value in our_list: check = True else: check = Fals...
true
59c6674fc9d9b60ea760819b0ca5ae0ef4a3fc7d
iamrishap/PythonBits
/InterviewBits/greedy/highest-product.py
2,176
4.21875
4
""" Given an array A, of N integers A. Return the highest product possible by multiplying 3 numbers from the array. NOTE: Solution will fit in a 32-bit signed integer. Input Format: The first and the only argument is an integer array A. Output Format: Return the highest possible product. Constraints: 1 <= N <= 5e5 Exam...
true
f4e986363821a1b2ab95bbfb1a37993587b32475
iamrishap/PythonBits
/InterviewBits/math/rearrange-array.py
1,448
4.1875
4
""" Rearrange a given array so that Arr[i] becomes Arr[Arr[i]] with O(1) extra space. Example: Input : [1, 0] Return : [0, 1] Lets say N = size of the array. Then, following holds true : All elements in the array are in the range [0, N-1] N * N does not overflow for a signed integer """ # If you had extra space to d...
true
7cd8bd2b6849000c586b12371576e407aef4a39d
iamrishap/PythonBits
/InterviewBits/binary-search/sorted-insert-position.py
673
4.28125
4
""" Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Here are few examples. [1,3,5,6], 5 → 2 [1,3,5,6], 2 → 1 [1,3,5,6], 7 → 4 [1,3,5,6], 0 → 0 """ # You need to return ...
true
9e103adb5edc5dc2faa52a34aef6a6ffabb9c8a3
iamrishap/PythonBits
/InterviewBits/linked-lists/reverse-link-list-2.py
1,995
4.34375
4
""" Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list. Note 2: Usually the version often seen in the interviews is reversing the wh...
true
1b5dfb89f8e2278c57780f7a81e908cb5029ce4b
iamrishap/PythonBits
/InterviewBits/math/fizzbuzz.py
1,569
4.53125
5
""" Given a positive integer A, return an array of strings with all the integers from 1 to N. But for multiples of 3 the array should have “Fizz” instead of the number. For the multiples of 5, the array should have “Buzz” instead of the number. For numbers which are multiple of 3 and 5 both, the array should have “Fizz...
true
61d05bf73148d910c85546e9de157b18735fd03f
iamrishap/PythonBits
/InterviewBits/dp/longest-increasing-subsequence.py
1,560
4.21875
4
""" Find the longest increasing subsequence of a given array of integers, A. In other words, find a subsequence of array in which the subsequence’s elements are in strictly increasing order, and in which the subsequence is as long as possible. This subsequence is not necessarily contiguous, or unique. In this case, we ...
true
2f952195989d620cc5fa152f539ff135cf71db18
iamrishap/PythonBits
/InterviewBits/dp/regex-match-1.py
2,543
4.25
4
""" Implement wildcard pattern matching with support for ‘?’ and ‘*’ for strings A and B. ’?’ : Matches any single character. ‘*’ : Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). Input Format: The first argument of input contains a str...
true
14cab32ed365156d622bf7ce9d4a899a79e7c9dd
mo-mahdi/Coursera-Python_for_Everybody_Spec-Michigan-
/Programming for Everybody -Getting Started with Python/Assignments/Assignment4.6.py
1,016
4.25
4
''' 4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of time-and-a-half in a function called computepay()...
true
0e5b4617caeebda0abb6de734248c8752c4c8886
andrei-kozel/100daysOfCode
/python/day009/exercise1.py
1,100
4.34375
4
# You have access to a database of student_scores in the format of a dictionary. # The keys in student_scores are the names of the students and the values are their exam scores. # Write a program that converts their scores to grades. # By the end of your program, you should have a new dictionary called student_grades t...
true
6021878f4e28d6f890522aa70c8a8ae23e153422
andrei-kozel/100daysOfCode
/python/day015/coffe_machine.py
2,921
4.1875
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "cappuccino": { ...
true
00858be5704d7f76ae43ac5616848115c936cf8f
andrei-kozel/100daysOfCode
/python/day026/exercise4.py
380
4.5
4
# You are going to use Dictionary Comprehension to create a dictionary called result # that takes each word in the given sentence and calculates the number of letters in each word. sentence = "What is the Airspeed Velocity of an Unladen Swallow?" # Don't change code above 👆 # Write your code below: result = {word: ...
true
13efb5a2fcde59bcd6adb3b2646b962fa55ad132
connorbassett21/comp110-21f-workspace
/exercises/ex06/dictionaries.py
1,303
4.1875
4
"""Practice with dictionaries.""" __author__ = "730397999" # Define your functions below def invert(initial: dict[str, str]) -> dict[str, str]: """When given a dictionary, it inverts it.""" inverted_list = {} for key in initial: inverted_list[initial[key]] = key if len(inverted_list) < len(i...
true
ff7ab6f40ddd5fbe03ec92e527923f6db6da2b7c
Mishalovoper/ML-Course
/Data Visualization Matplotlib/MatplotlibPt3.py
920
4.28125
4
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0,10,11) y = x ** 2 #Plot appearance fig = plt.figure() ax = fig.add_axes([0,0,1,1]) #color of the line, you should put the name of the color for example, blue #Or you can put RGB HEX CODE FOR EXAMPLE #FFFFFF #Linewidth is the width of the line #Al...
true
8cad6fbbe3339316dc9403deadacb2ed834fa40d
boki1983/Project
/PythonBasic/basic/Functions.py
2,374
4.34375
4
# Defining a Function # Function definition is here def printme( stri ): "This prints a passed string into this function" print(stri) return; # Now you can call printme function printme("I'm first call to user defined function!") printme("Again second call to the same function") #Pass by reference vs valu...
true
f7062f815e9a45cd40e9231a8b116dbb27006346
ZukhriddinMirzajanov/Data-structures
/stack.py
1,498
4.3125
4
import queue class Node: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(self): self.head = None class Stack: def __init__(self): self.LinkedList = LinkedList() def iterate(self): if self.Link...
true
99232157b3a8bee124bc23e6e423ebf65e8f7ad2
krzysj13/practicepython.org
/18_CowsAndBulls.py
1,620
4.125
4
''' Create a program that will play the “cows and bulls” game with the user. The game works like this: Randomly generate a 4-digit number. Ask the user to guess a 4-digit number. For every digit that the user guessed correctly in the correct place, they have a “cow”. For every digit the user guessed correctly in the w...
true
20c552b8bff3e1fe596c0c7b6b47e91c8f9f7c15
krzysj13/practicepython.org
/13_FibonacciSolutions.py
992
4.5625
5
''' Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. Take this opportunity to think about how you can use functions. Make sure to ask the user to enter the number of numbers in the sequence to generate.(Hint: The Fibonnaci seqence is a sequence of numbers where the ne...
true
3b650c16d6c4e477066bd2d1190ed0c94e778e35
bllanos/python-learning-exercises
/learnPythonTheHardWay/ex3/ex3.py
933
4.3125
4
print "I will now count my chickens:" print 'Single quotes also work to delimit string literals.' print "Hens", 25 + 30 / 6 # = 30 # When printing, a space is inserted between arguments. print "Roosters", 100 - 25 * 3 % 4 # = 100 - (25 * 3) % 4 # = 100 - 75 % 4 ...
true
ff063a5122414d00d92f67906f77a292b0fc80f5
SEDarrow/PythonCode
/WileyDSAPracticeProblems/EBookSimulator.py
2,716
4.125
4
class Bookshelf(): class Book(): def __init__(self, name, file): self.name = name self._file = file def readBook(self): text = open(self._file, 'r') print(text.read()) text.close() library = {"Pride and Predjudice": "p...
true
240cc847c156f75b7933704bc06718c48e9005fa
gdudorov/python_bootcamp
/d00/ex06/recipe.py
2,135
4.34375
4
cb= { 'sandwich': {'ingr': ('ham', 'bread', 'cheese', 'tomatoes'), 'meal' : 'lunch','time' : 10}, 'cake': {'ingr':('flour', 'sugar', 'eggs'), 'meal' : 'dessert', 'time' : 60}, 'salad': {'ingr': ('avocado', 'arugula', 'tomatoes', 'spinach'),'meal' : 'lunch','time' : 15}} #function to add a new recipe to cookbook w...
true
b46ec5bc890ce7211bb2d022eb02104efdf90e63
sulav999/iwacademy_assignment_2
/Data_Type/Question_TwentySeven.py
249
4.25
4
""" 27. Write a Python program to replace the last element in a list with another list. Sample data : [1, 3, 5, 7, 9, 10], [2, 4, 6, 8] Expected Output: [1, 3, 5, 7, 9, 2, 4, 6, 8] """ num=[1,2,3,4,5,6,7] num1=[2,3,8,9,0,10] num[-1:]=num1 print(num)
true
fcc246aac00dd3e55553e7724795bc2957c4bc81
sulav999/iwacademy_assignment_2
/Data_Type/Question_Eighteen.py
246
4.1875
4
# 18. Write a Python program to get the largest number from a list. def list_compare(list): container=list[0] for i in list: if i > container: container=i return container print(list_compare([1,2,3,40,60,80]))
true
3c2c972526a8fbd4a9d3339b330cf0a7ff2f9cac
gaurav-210/Python-Assignments
/assignment10/assignment10.py
1,668
4.28125
4
#Q.1 inheritance of animal class and acess the base class: class animal : def animal_attribute(self): print("Animal") class tiger(animal) : pass a=tiger() a.animal_attribute() #Q.2.WHAT WILL BE THE OUTPUT OF THE FOLLOWING CODE. class A: def f(self): return self.g() def g(self): ...
true
d920062af83178ba337b352ba8eb94b403886b40
Hessemtee/codecademypython3beginnercourse
/06code_challenges/06loops_advanced.py
2,897
4.28125
4
# Create a function named larger_sum() that takes two lists of numbers as parameters named lst1 and lst2. # The function should return the list whose elements sum to the greater number. If the sum of the elements of each list are equal, return lst1. #Write your function here def larger_sum(lst1, lst2): sum_lst1 = 0...
true
be5220d03dd4bb9ca1d2a16693de2e065ec6d2e6
katel85/pands-Problem-Sheet
/Week 6 Task/Squareroot.py
1,545
4.65625
5
# Write a program that takes a positive floating-point number as input and outputs an approximation of its square root # Author Catherine Leddy # Ref: https://www.geeksforgeeks.org/find-root-of-a-number-using-newtons-method/#:~:text=Let%20N%20be%20any%20number,correct%20square%20root%20of%20N. # Ref: https://stackover...
true
fbcf2d7048347b75c446bae76ebc30d5d2cdbf18
Nick12321/python_tutorial
/guessing_game.py
1,631
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Aug 4 21:07:07 2020 @author: nick """ ###make import statements in homework5_8.py # Make Guess_Game class to store guess number, tries per game. # method to generate random number, check guess (low or high) # Game__init__ generate and store random num...
true
9089cb04bc99a0001b2283af5e7332bd6b63307e
sifatok93/conditionals
/Lab(if conditionals).py
2,294
4.59375
5
#!/usr/bin/env python # coding: utf-8 # In[6]: number_50 = 50 my_number = None if number_50 > 100: less_than_50 = 100 # if number_50 is greater than 100, assign the `my_number` variable to the number 100 elif number_50 > 50: less_than_50 = 50 # if number_50 is greater than 50, assign the `my_numbe...
true
a5352e7257c4b5f74e9cd37f2f3751363b97187d
yobaus/PythonPrograms
/LittlePrograms/Pythagorean .py
1,280
4.40625
4
# based on https://www.reddit.com/r/beginnerprojects/comments/19jwi6/project_pythagorean_triples_checker/ # By Pete Baus 9/11/2019 Loop = True def PartOne(): print('Welcome to the right triangle tester. \n*plese only you number key and whole numbers.') Side1 = int(input('Plese type your first side: ')) # inpu...
true
21a03ce65f292e9f78be08ea1249d2b1f76f5d2b
yobaus/PythonPrograms
/LittlePrograms/HigherLower.py
1,080
4.3125
4
# based on https://www.reddit.com/r/beginnerprojects/comments/19jj9a/project_higherlower_guessing_game/ # By Pete Baus 9/18/2019 import random def GuessStep(): print('\nHow to play: The computer randomly selects a number between 1 and 100 and the you has to guess what the number is. \nAfter every guess, the compu...
true
8d866293f328610854e969063e84cd115c1bdfb9
mdroshan25/100-days-Coding
/Week1.py
614
4.21875
4
print("This is my first program to develop") print("Wish me good Luck") print("I need to do fast to stay in country") #print("enter your name") name =input("enter your name") age = int(input("enter your age:")) phone = input("enter your phone no:") print() print("your name is:", name) if age < 18: print(f"you are ...
true
7f242d873e555761566cc634bd4623b1c60a568c
tearsforyears/toys
/draw3d.py
1,761
4.375
4
# coding=utf-8 import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import sys def draw_points(x=None, y=None, z=None): ''' this function use points to draw points in 3d space there is a sample with parameter equation x = x y = sin(x) z...
true
3ccb42dbc0070105f4ede955861993e991209235
suprit-kumar/PythonQA
/list_programmes.py
2,845
4.4375
4
"""Python program to interchange first and last elements in a list""" # def interchange1Elements(arr): # size = len(arr) # # Swaap array # temp = arr[0] # arr[0] = arr[size - 1] # arr[size - 1] = temp # # return arr # arr = [1, 2, 3, 4, 5, 6, 7, 8, 9] # swap = interchange1Elements(arr) # print(...
true
9086664930ae2fa11179563d6c8a7a444936946b
trz-maier/iax
/iax/inferfaces/__init__.py
2,080
4.1875
4
from abc import ABC, abstractmethod from typing import Tuple class DistanceFunction(ABC): def __init__(self, name): """ Distance Function Interface used to generalise the calculation within the library. Implements evaluate function. :param name: """ self._name = nam...
true
f153eda9b43addc523f009882394127718cb05ce
abhi-386/CSC-110-
/name_similarity.py
1,176
4.34375
4
### ### Author: Benjamin Dicken ### Description: This program takes the users first, middle, and last name as input. ### It will tell the user which two of all combinations of the three ### are most similar. ### def count_same_characters(a, b): i = min(len(a), len(b)) - 1 count = 0 ...
true
0fe273e3ffb4724e735e1c25c7ed7873ae195653
higorsantana-omega/algorithms-and-data-structures
/data_structures/arrays/arrays_operations.py
715
4.3125
4
""" === Speed Complexity by Operation === - Lookup -> O(1) - Unshift -> O(n) - Push -> O(1) - Insert -> O(n) - Pop -> O(1) - Delete -> O(n) """ import collections list1 = [1, 2, 3] """ Deque is preferred over list in the cases where we need quicker append and pop operations from both the ends of container, as d...
true
c9191990b6e77c52416bf5fd618f92b3a47dc161
higorsantana-omega/algorithms-and-data-structures
/big_o_notation/rules/different_terms_for_inputs.py
472
4.15625
4
""" === Big O Notations Rules - Different Terms for Inputs === What if an algorithm receives two different inputs and it depends on the size of both? In that case, the Big O Notation should have different variables for each input, like the following: - O(a + b) - O(n*m) """ def compressBoxesTwice(boxes1, boxes2): # ...
true
0b53b29bd47b5feb4f7d619a567b0489aaea6326
julienisbet/python-debugging
/debugging-4.py
679
4.1875
4
# This is our code from earlier in the class # that converts number grades to letter grades # Its currently working for the first example # but the second example 75 is also printing A # Can you spot the problem? def letter_grade(num_grade): num_grade = 93 if num_grade >= 90: grade = 'A' elif num_grade >= 80...
true
fe15b46b8af64873e4ecde02f75928494df9cff8
nmp14/Codewars
/5_kyu/Parenth-check.py
555
4.46875
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. def valid_parentheses(string): count_left = 0 count_right = 0 for char in string: if count_righ...
true
fa1169801819580134d234b7ff83c85f7b247df9
romu42/practice
/python_morsels/compact.py
990
4.21875
4
#!/usr/bin/env python3 # by rog """ pythonmorsels.com For this week's exercise I want you to write a function that accepts a sequence (a list for example) and returns a new iterable (anything you can loop over) with adjacent duplicate values removed. For example: >>> compact([1, 1, 1]) [1] >>> compact([1, 1, 2, 2,...
true
19557b9c044c870ee7a8d4dada5bf5221ef74c64
KLKln/Module6
/more_functions/string_functions.py
1,186
4.5625
5
""" Program: Multiply_String.py Author: Kelly Klein Last date modified: 6/17/2020 This program will take a String and a number and repeat the string n number of times. """ def multiply_string(message, n): """ Use reST style. :param message: string message passed in :param n: number of times we rep...
true
0e684347c8366ce6e170c197e8363e6524f3d6d7
miketrame/words-with-enemies
/main.py
2,535
4.3125
4
"""Main logic for words-with-enemies.""" import game def main(): """Main entry point into the program.""" print("Welcome to words-with-enemies! The cli for words with friends with") print("a solver to defeat your enemies!") print("\"help\" for more info.") current_game = game.Game() current_g...
true
74e9a3c6e5b1f43c3d1db5507de0034730a77ab7
n6nq/checking
/accounts.py
2,778
4.28125
4
"""Accounts class holds all the data for an account, duh""" import database import dbrow import category import trigger import override import entry from datetime import date import sqlite3 class Account(dbrow.DBRow): """ACCOUNT - The account class holds values for identifyng an account to the user ...
true
ad1d222e08ba5f7d0a1fab9a2c696f5180ae3c79
NorthcoteHS/10MCOD-Vincent-CROWE
/user/Decypher.py
387
4.1875
4
""" program: cipher name: Vincent Objective: Create a randomised encryption """ from random import randint #for randomised numbers dec = input ('what do you want to encrypt ') encode = dec for dec in encode: #for loop dec = ord(dec) dec = (randint(65, 122)) #turns dec into a random number print ((chr(dec)),...
true
e1bd13ce69ee4183bdf57a9c950c047c0a47c40c
krautz/programming-marathon
/algorithms/sort/mergesort.py
1,278
4.21875
4
""" Merge Sort algorithm. Time Complexity: O(n * log(n)) Space Complexity: O(n) """ def mergesort(list, begin, end): # empty sublist: return empty list if begin > end: return [] # one element in sublist: return list with this element if begin == end: return [list[begin]] # divi...
true
40898e8dd6c396f36162269308ca80a9bb0dce1c
mohitlal1/python
/String formating techniques/string_formatting.py
406
4.125
4
# String formatting from string import Template name = 'John Snow' question = 'how many' print('Hello, %s' % name) print('Hello, {}'.format(name)) def greet(name, question): print(f"Hello, {name}! Are you watching {question}?") greet('Arya', 'Game of Thrones') templ_string = 'Hey $name, $question next episodes a...
true
3e9946e93f27abeb52253063fa1e12fbd6369c4f
hsuweibo/Pygame-Snake
/direction.py
647
4.3125
4
from enum import Enum class Direction(Enum): """An enumerate class representing one of the four directions""" up = 1 down = 2 left = 3 right = 4 @staticmethod def is_opposite(dir1, dir2): """ Test to see if dir1 and dir2 are opposite directions. :param dir1: a Dir...
true
2ea5b20750a9dd6dc68b8be5badaa8e9deef4678
emaquino44/Intro-Python
/src/day-1-toy/dicts.py
828
4.375
4
# Make an array of dictionaries. Each dictionary should have keys: # # lat: the latitude # lon: the longitude # name: the waypoint name # # Make up three entries of various values. waypoints = [ { "lat": 47.606209, "lon": -122.332069, "name": "Seattle, WA" }, { "lat": 21.967...
true
aea77c524ae47172509b8464b47c56672793c64a
Surajv311/NeoAlgo
/Python/math/Binary_Exponentiation.py
760
4.59375
5
# Python Program to find Binary Exponent Iteratively and Recursively. # Iterative function to calculate exponent. def binExpo_iterate(a,b): res=1 while b>0: if b%2==1: res=(res*a) a=a*a b//=2 return res # Recursive function to calculate exponent. def binExpo_recurse(a,b...
true
9f0df30ef49f36e01b43f7df440212a55be53da1
puneeth1999/InterviewPreparation
/CodeSignal/Arcade/Intro/#4AdjacentElementsProduct.py
811
4.375
4
''' Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. Example For inputArray = [3, 6, -2, -5, 7, 3], the output should be adjacentElementsProduct(inputArray) = 21. 7 and 3 produce the largest product. Input/Output [execution time limit] 4 seconds (...
true
5d27f9994cb5b4c22ba31a831392f33f67b04cbf
AykCanDem/python-design-patterns
/Factory_Class.py
1,051
4.375
4
""" The factory finds the relevant class using some kind of logic from the attributes of the request. Then, it asks the subclass to initiate the new object and return it to client. Factory Method: is a method that used to create product objects without specifying their concrete classes. It is for adding extra abstract...
true
b4f617b35d5650128117d022a54e41cd5492d853
ndm8/Python-and-Graph-Theory-
/Prime Factorization.py
554
4.25
4
#This program finds the prime factorization of a number that the user enters. # #Author: Nick Montana # #Date: 3/21/17 cont = 'Y' while (cont == 'Y'): x = int(input ("Enter a number: ")) print () print ("Prime Factorization is:") while (x%2 == 0): x = x / 2 print (2) ...
true
c31829344cbc99f70d294c11c837514fae594381
andrewWong21/10_db
/stu_mean.py
1,885
4.125
4
import sqlite3 import csv f = "discobandit.db" db = sqlite3.connect(f) c = db.cursor() #====== def create_avg_table(): c.execute("CREATE TABLE peeps_avg (student TEXT PRIMARY KEY, id INTEGER, avg REAL)") list_of_students = look_up_students() id = 1 while (id < len(list_of_students)): command...
true
46525d925c9570c786f76fc3889a65aa92b38195
HackClubNUV/Python-50-Exercises
/practice5.py
617
4.15625
4
''' Pig Latin problem 1) If the word begins with a vowel (a, e, i, o, or u), add “way” to the end of the word. So “air” becomes “airway” and “eat” becomes “eatway.” 2) If the word begins with any other letter, then we take the first letter, put it on the end of the word, and then add “ay.” Thus, “python” becomes “y...
true
a40652c1bdbcb9a02179fc1144c67d1937ce638f
justkaran/pythonproblems
/fizzbuzz.py
706
4.40625
4
'''Write a function which prints every number from 0 up to the given input. If divisible by 3, print "Fizz" instead of the number. If divisible by 5, print "Buzz". If input is divisible by 3 AND 5, print "FizzBuzz".''' #Clarify the Problem #Create Inputs #Outline the Solution # a function that takes in the input as...
true
663c8390cb7f8d1647e8cb198fe067046691ea9b
beauxq/tic
/winning.py
2,509
4.25
4
""" utility functions related to plays in the game of tic-tac-toe """ from typing import List, Set, Tuple import numpy as np possible_win_sets = ( # horizontal lines (0, 1, 2), (3, 4, 5), (6, 7, 8), # vertical lines (0, 3, 6), (1, 4, 7), (2, 5, 8), # diagonal lines (0, 4, 8), ...
true
c54f644267825b4107a941aead8ddb345251bf51
Ahmed--Mohsen/leetcode
/populating_next_right_pointers_in_each_node 2.py
1,431
4.25
4
""" Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant extra space. For example, Given the following binary tree, 1 / \ 2 3 / \ \ 4 5 ...
true
087e7c1f6ce0a7818359fb14b2b5df25101bb937
Ahmed--Mohsen/leetcode
/reverse_linked_list.py
1,594
4.125
4
""" Reverse a singly linked list. click to show more hints. Hint: A linked list can be reversed either iteratively or recursively. Could you implement both? """ # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param {ListNode} h...
true
2af37f39c9ec71691c8d571ecc8ca17e019ad2ff
Ahmed--Mohsen/leetcode
/binary_tree_right_side_view.py
1,844
4.3125
4
""" Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For example: Given the following binary tree, 1 <--- / \ 2 3 <--- \ \ 5 4 <--- You should return [1, 3, 4]. """ # Definitio...
true
4a014be0cef6e36dbb7673f68984a8e2b2c7def4
Ahmed--Mohsen/leetcode
/Wildcard_Matching.py
1,844
4.15625
4
""" Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). The function prototype should be: bool isMatch(const char *s, const char *p)...
true
d1fd7d6383669c4bcf5c77a2ef4547fb974ff5af
Ahmed--Mohsen/leetcode
/ZigZag_Conversion.py
1,030
4.3125
4
""" The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conve...
true
97b539fbc4706c736d7aa9f89dfd85cbd7043a83
Ahmed--Mohsen/leetcode
/Binary_Tree_Zigzag_Level_Order_Traversal.py
1,623
4.125
4
""" Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7 return its zigzag level order traversal as: [ [3], ...
true
01915255a14dedfa66216487965878428d103843
Ahmed--Mohsen/leetcode
/Minimum_Window_Substring.py
1,717
4.15625
4
""" Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC". Note: If there is no such window in S that covers all characters in T, return the empty string "". If there are multip...
true
a62a47d5bffb64ae6248eef802936c77f73a9f90
Ahmed--Mohsen/leetcode
/shortest_palindrome.py
1,447
4.1875
4
""" Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. For example: Given "aacecaaa", return "aaacecaaa". Given "abcd", return "dcbabcd". """ class Solution: # @param {string}...
true
71ee0642444d696263b521c23ecda76b14b982bb
vishnuverse/algorithms-and-datastructures
/abstract_data_structures/stack.py
993
4.21875
4
class Stack: def __init__(self): self.stack = [] # one dir array (abstract datatype) # push method or insertion // O(1) def push(self, data): self.stack.append(data) # moving item In LIFO way ie pop first element // O(1) def pop(self): if self.stack_size() < 1: ...
true
306ca827389dfe0c2f09dd2bf8fbbab67bbac860
armou/euler-project
/problem04/problem4.py
881
4.25
4
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. import time start_time = time.time() #Check if a number is a palindrome (can be read the same way backw...
true
0ba826338f8d8674bb2e40b69e14513af6f8a21a
jamesdidit72/Eng88_Working_With_Files
/exception_handling.py
2,148
4.15625
4
# `try`, `except` and `finally` blocks of code # def greeting(): #| throws indention error, missing 'pass' # name = 'DevSecOps' # year = 2021 # print(name + year) #| throws TypeError, cannot put a string and int together # file = open('order.txt') #| throws FileNotFoundError, file doesnt exist # try: # file...
true
113c8d176d5f9bf0db80f0143f2b97f375a98b32
Elio67/CodeWars-Python
/Binary Addition.py
652
4.34375
4
''' Binary Addition Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition. The binary number returned should be a string. ''' # My code def add_binary(a, b): c = a + b return (str(bin(c)[2:])) # My test print(add_binary(1,...
true
450697796c5ed12187af169eb78d6b1441ae23c4
Scientific-Computing-at-Temple-Physics/prime-number-finder-Haplescent
/primes_tester.py
1,650
4.5
4
# This is a comment. Python will ignore these lines (starting with #) when running import math as ma # To use a math function, write "ma." in front of it. Example: ma.sin(3.146) # These functions will ask you for your number ranges, and assign them to 'x1' and 'x2' x1 = int(raw_input('smallest number to check: '))...
true
dba8efc69a283ba8253d05753fa618ad24406ce0
Radmehan/python
/pythonTut14Exer1prb.py
658
4.34375
4
""" Problem Statement: So, in this tutorial i.e. Python exercise 1 tutorial, what we have to do is to create a dictionary, similar to the real-world dictionary. There is no limit to the definition you provide to any word as this exercise is just for your practice. The details and functionalities that are essential and...
true
e8553217b954250e2f338fd419b5844700199c61
Harshvardhanvipat/Python_workspace
/OOP/generalFunctions.py
638
4.34375
4
# map(), filter, zip, reduce function # map is a pure function # below map function is a pure function my_list = [1, 2, 3] def multiple_by2(item): return item*2 # this print statement takes a function and a list as there arguments, and returns a new list that is not changed. As you can see that my_list is un...
true
432411b2a5439bb698446ca518b36a30b85dda1f
SushmaBR/FirstPython
/lists.py
2,205
4.21875
4
""" x=[10,"sush",True,30,50] x[1]=1000 for i in x: print(i) print("First element is",x[0]) """ list1=[10,20] list2=[5,15] list3=list1+list2 #list addition or list concatenation #for i in list3: print(list3) print("list4") #[start:end+1] list4=list3[2:4] #taking part of list is called slicing fo...
true
45b61836e35138d8d8575272076d04a2949d2e1c
ChristianAhKuoi/Comic-Book-Store-GUI
/Code Avengers - Python 3/Task 3 - Widget.py
638
4.3125
4
from tkinter import * # Create a window root = Tk() root.title("My GUI App") # Create a label and add it to the window using pack() label1 = Label(root, text="My GUI App!") label1.pack() #Create a StringVar() to store text words = StringVar() # Create a text entry field words_entry = Entry(root, textv...
true
f335909d09dde613d8f9d98d51a348cf24659f4c
insidescoop/sandbox-repo
/jordan/something.py
339
4.28125
4
print ('hello') print ('blah blah blah blah') abc=77*1 print (abc) # this is an example of a string data type x="5*5*5" print (x) # get a value from user and display it name=input("name of company: ") print (name) # example of conditional statement z=25 if z>1: print ("buy") elif z==25: print ("hold") else: ...
true
b6d8415b890a392975653a1607ee14ef935fa74c
dsf3449/CMPS-150
/Programming Assignments/pa4/pa4.py
2,337
4.1875
4
# Author: David Fontenot # CLID/ULID: dsf3449/C00177513 # Course/Section: CMPS 150 - Lecture Section #002 # Assignment: pa4 # Date Assigned: Monday, February 20, 2017 # Date/Time Due: Friday, March 3, 2017 -- 11:55pm # # Description: This program will ask the user for their package t...
true