blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
b197373baee082d3870197644e098d5ccdc4c9a6
evamaina/Basics
/sort.py
317
4.25
4
start_list = [5, 3, 1, 2, 4] square_list = [] # Your code here! for number in start_list: number = number**2 square_list.append(number) square_list.sort() print square_list """Write a for-loop that iterates over start_list and .append()s each number squared (x ** 2) to square_list. Then sort square_list!"""
true
68834fc74c7c5b40e0d42b732cac0612cb2a8992
evamaina/Basics
/my_dict2.py
386
4.46875
4
my_dict = { 'name': 'Nick', 'age': 31, 'occupation': 'Dentist', } print my_dict.items() print my_dict.keys() print my_dict.values() """While .items() returns an array of tuples with each tuple consisting of a key/value pair from the dictionary: The .keys() method returns a list of the dictionary's keys, and ...
true
bce4ab96307b6335aacbdf6efcbaf38f92387e83
JPoser/python-the-hardway
/Exercise 33/ex33st5.py
389
4.1875
4
# Learn Python The Hard Way - Exercise 33 study drill 5 # Copied by Joe Poser i = 2 max = 10 numbers = [] increase = 2 def count(i): for i in range(i, max): print "At the top i is %d" % i numbers.append(i) i = i + increase print "Numbers now: ", numbers print "At the bottom i is %d" % i ...
true
6e517cac536fb7bc827979ee81e448c89ca6cf9e
JPoser/python-the-hardway
/Exercise 30/ex30st4.py
1,224
4.34375
4
# Learn Python The Hard Way - Exercise 30 # Copied by JPoser # Sets the value of people to 30 people = 30 # Sets the value of cars to 40 cars = 40 # Sets the value of buses to 15 buses = 15 # Checks if cars are greater than people if cars > people: # If cars are greater than people prints this string pr...
true
cff2259fbf8e9b71c9cf246627600695c1baed45
JPoser/python-the-hardway
/Exercise 7/ex7st1.py
1,043
4.15625
4
# Learn Python The Hard Way. Exercise 7 Study Drill 1. # Copied by JPoser # prints string print "Mary had a little lamb." # prints string with string nested inside print "It's fleece was white as %s." % 'snow' # prints string print "And everywhere that mary went." # prints string 10 times print "." * 10 # wh...
true
f4db9cf283618b2912702f42d61dca43e86f0504
JPoser/python-the-hardway
/Exercise 4/ex4st3.py
1,276
4.34375
4
# Learn Python The Hard Way, Exercise 4 Study Drill 3. # Copied by JPoser. # Assigns variable "cars" to the integer (in future written as int) 100 cars = 100 # Assigns variable "space_in_a_car" to the floating number 4.0 space_in_a_car = 4.0 # Assigns the variable "drivers" to int 30 drivers = 30 # Assigns t...
true
e821fa06ec048569e90cde1194aeb4faf15d10b4
RidaATariq/ITMD_413
/Assignment-4/HW_4/program-2/main.py
1,482
4.25
4
""" This program asks the user to enter two 3x3 matrices to be multiplied and then it gets the result. Name: Cristian Pintor """ matrixA = [] matrixB = [] print('Enter a 3x3 matrix for matrix A: ') for i in range(9): matrixA.append(eval(input())) print('Enter a 3x3 matrix for matrix B') for i in range(9): m...
true
6f557ae80a05f830d801d159aa2e54c612e58ae3
RidaATariq/ITMD_413
/Assignment_15/cpintor_HW_15/question_17.1/main.py
2,109
4.375
4
import sqlite3 connection = sqlite3.connect('books.db') import pandas as pd # 1. Select all authors' last names from the authors # table in descending order output_1 = pd.read_sql("""SELECT last FROM authors ORDER BY last DESC""", connection) print(...
true
61269f6c768d5965e50de89834b6d89fad9c88b1
RidaATariq/ITMD_413
/Assignment-2/Module-3_Lopping/while-loop-2.py
462
4.1875
4
''' This program demonstrates the concept of while loop. ''' import random # Generate a random number to be guessed number = random.randint(0, 100) print("Guess a magic number between 0 and 100") guess = -1 while guess != number: guess = eval(input("Enter your guess: ")) if guess == number: print("...
true
3812633581de8a898f8d978cf0c7e589323d4b30
RobRoger97/test_tomorrowdevs
/cap3/63_Average.py
363
4.21875
4
#Read a value from user num = int(input("Enter a number: ")) sm=0.00 count=0 #Loop if num==0: print("Error message: the first number can't be 0") else: while num!=0: count=count+1 sm = sm+num num = int(input("Enter a number: ")) #Compute the average average=sm/count #Display ...
true
8d68b11c78a261b452176bcf9dc7abd61732c276
RobRoger97/test_tomorrowdevs
/cap2/58_Is_It_a_Leap_Year.py
622
4.375
4
# Read the year from the user year = int(input("Enter a year: ")) # Determine if it is a leap year #Any year that is divisible by 400 is a leap year. if year % 400 == 0: isLeapYear = True #Of the remaining years, any year that is divisible by 100 is not a leap year. elif year % 100 == 0: isLeapYear = False...
true
31dca49e06b0a06e436dd8abed18510140e6ec16
RobRoger97/test_tomorrowdevs
/cap2/62_Roulette_Payouts.py
1,319
4.125
4
## # Display the bets that pay out in a roulette simulation. # from random import randrange # Simulate spinning the wheel, using 37 to represent 00 value = randrange(0, 38) if value == 37: print("The spin resulted in 00...") else: print("The spin resulted in %d..." % value) # Display the payout for a single n...
true
e8f9c0ab9af876319bcec91df8d79769920effc0
RobRoger97/test_tomorrowdevs
/cap5/ex110_Sorted_Order.py
382
4.375
4
#Read a integer from the user integ = int(input("Enter a integer: ")) # Start with an empty list lis=[] #While loop while integ!=0: lis+=[integ] print(lis) integ = int(input("Enter a integer: ")) #Sort the value of the list lis.sort() #Display the values in ascending order print("The values, sorted i...
true
fad3b778a58587f27e8a349ab5195914ba9f25d1
RobRoger97/test_tomorrowdevs
/cap2/42_Note_to_Frequency.py
725
4.1875
4
#Note's frequency C4_f = 261.63 D4_f = 293.66 E4_f = 329.63 F4_f = 349.23 G4_f = 392.00 A4_f = 440.00 B4_f = 493.88 #Read the note name from user name = input ("Enter the two character note name, such as C4: ") #Store the note and its octave in separate variables note = name[0] octave = int(name[1]) #Get the frequen...
true
93d7bdb71b4db9b716b7b5aa22ab1e821e1cb6e3
RobRoger97/test_tomorrowdevs
/cap3/75_Is_a_String_a_Palindrome.py
513
4.40625
4
# Read the string from the user line = input("Enter a string: ") is_palindrome = True i = 0 #While loop to scroll through the string while i < len(line) / 2 and is_palindrome: # If the characters do not match then mark that the string is not a palindrome if line[i] != line[len(line) - i - 1]: is_palindrom...
true
677e1fa22ecacc625f85aef5b2d586b202e0b9fe
muondu/datatypes
/megaprojects/strings/st4.py
429
4.125
4
print("Enter your name in small letters") a = input("Enter your first word of your name: ") print(a.upper()) b = input("Enter your second word of your name: ") print(b) c = input("Enter your third word of your name: ") print(c.upper()) d = input("Enter your fourth word of your name: ") print(d) e = input("Enter you...
true
5766ba5c7fd8c06a386984124c24074d19f06764
sacheenanand/pythonbasics
/quick_sort.py
1,231
4.3125
4
#Quick sort is a highly efficient sorting algorithm and is based on partitioning of array of data into smaller arrays. #A large array is partitioned into two arrays one of which holds values smaller than the specified value, say pivot, based on which the partition is made and #another array holds values greater than ...
true
58fbd02b4bd79c57b9ec7d5a52016ca6689bab8c
Judy-special/Python
/02-basic-201807/is_Palindrome.py
576
4.15625
4
# coding = utf8 def is_Palindrome(the_str): """ 本函数用来判别是否为回文字符串 """ l = len(the_str) - 1 n = int(l/2) if len(the_str) == 0: print("The String is Null") elif len(the_str) > 0: temp = [] for i in range(n): if the_str[i]==the_str[l-i]: temp.ap...
true
e343c335766ff26481a4daf445d7bf5615de2486
Pajace/coursera_python_miniproject
/miniproject2.py
2,442
4.125
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 simplegui import random # 1. initialize global variable num_range = 100 remaining_guesses = 7 user_guesses = 0 secret_number = random.randrange(0, num_range)...
true
d4be5236a64fdc4114e017a4b5e65da20a4b6f18
aronaks/algorithms
/algorithms/gfg_arrays2.py
543
4.34375
4
def find_leaders(keys): """ Write a function that prints all the LEADERS in the array. An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. For example int the array {16, 17, 4, 3, 5, 2}, leaders are 17, 5 and 2. """ ...
true
e1dbe97738f28b03916540a49a6ebe0db0e25bbd
nicholas0417/python-tutorial
/data_types/product.py
238
4.15625
4
# Q1 num1 = int (input("please enter number1:")) num2 = int (input("please enter number2:")) product = num1 * num2 # If product is greater than 1000 if (product < 1000): print("The product is : " product) else: print(num1 + num2)
true
91cc8136c752f5397b51511012fe2be70a3993fd
AaronAikman/MiscScripts
/Py/AlgorithmsEtc/BuildingHeight.py
351
4.15625
4
# CalculateBuildingHeight.py # Aaron Aikman # Calculate height of a building based upon the inputted number of floors while True: numFloors = input("Enter a number of floors (returns cm):") if (numFloors == ""): break buildingHeight = ((3.1 * numFloors) + 7.75 + (1.55 * (numFloors / 30))) print...
true
2d635fb9dd499cd344039e1b980c938188e08b09
Gaurav715/DDS1
/main.py
2,596
4.28125
4
# Python program for implementation of BubbleSort def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # traverse the array from 0 to n-i-1 # Swap if the eleme...
true
de3fa85ee012acb070b0023e2be345d43f3aab43
CaptainCrossbar/CodeWars
/(8) Is it a number?.py
348
4.1875
4
def isDigit(string): #Check to see if string is an integer try: int(string) return True #String was no an integer except: #Check to see if string is a float try: float(string) return True #String is no a valid integer or float excep...
true
c1dbde41aa30ce350a1ef3266c92f8ec8cec96bd
melissav00/Python-Projects
/project_exercise2.py
479
4.1875
4
start = int(input("Pick a starting number for a list:")) end = int(input("Pick a ending number for a list:")) def generateNumbers(start,end): num_list=[] if start == end: print("Both values are equal to each other. Please input opposite values.") elif start > end: print("Enter a start val...
true
bdd47bd94d25de8b95debacc99fbed3fc14f294a
Moiz-khan/Piaic_Assignment01
/copiesof string.py
208
4.21875
4
#program to print copies of string str = input("Enter String: ") n = int(input("How many copies of String you need: ")) print(n, "copies of",str,"are ",end=" ") for x in range(1,n+1): print(str,end=" ")
true
5e48ffd4a519bf0a0a5e2f42f645f2ae37f9cb22
heis-divine/PythonCalculator
/main.py
1,309
4.28125
4
# Calculator project print("What Calculation would you like to perform?") print("1)Addition\n2)Subtraction\n3)Multiplication\n4)Division") choice = int(input("Enter preferred Option: ")) if choice == 1: print("Addition") num1 = int(input("Enter first number:")) num2 = int(input("Enter second number:"...
true
75752fa8139a12de337fa40553785211469139d2
Zahidsqldba07/PythonPrac
/Time & Calendar.py
618
4.25
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import time import datetime import calendar # In[2]: ### Get the current date and time print(datetime.datetime.now()) # In[3]: ### Get just the current time print(datetime.datetime.now().time()) # In[4]: start = time.time() print("hello") end = time.time() p...
true
5e4f7196eece576d7a5cc69017c35eeee6056d75
Zahidsqldba07/PythonPrac
/Logic 1.py
2,303
4.21875
4
#!/usr/bin/env python # coding: utf-8 # # You and your date are trying to get a table at a restaurant. The parameter "you" is the stylishness of your clothes, in the range 0..10, and "date" is the stylishness of your date's clothes. The result getting the table is encoded as an int value with 0=no, 1=maybe, 2=yes. If ...
true
38c45a4fbd57093e586ed9c1fe820b958a1d0343
codevr7/samples
/one-bit_binary_adder.py
275
4.15625
4
#binary adder choices = ['0','1'] problem = input("select 2 numbers between 0 and 1(0,1)") if problem != '0' or problem != '1': print("binary adder cannot process numbers other than 1 and 0") if problem_1 != : print("binary adder cannot process numbers more than 1")
true
1b36b1abc616005a72e5b7bd72dbf081152b62e1
codevr7/samples
/odd_sort.py
536
4.28125
4
# A function for sorting only odd numbers from a list of mixed numbers def odd_sort(n): l = len(n)# The length of the input for i in range(0, l):# A range for 0 to length of input for j in range(i, l):# A second range for evaluating for each number if n[i]%2 != 0:# Evaluating each number, wh...
true
3ece7ee246f9e1367949690c1c38ddabac94a198
pragyatwinkle06/Python_patterns_and_codes
/ZIGZAG PATTERN CHALLENGE3.py
1,149
4.40625
4
# Python3 ZIGZAG PATTERN CHALLENGE3 # Function to print any string # in zigzag fashion def zigzag(s, rows): # Store the gap between the major columns interval = 2 * rows - 2 # Traverse through rows for i in range(rows): # Store the step value for each row step = interval - 2 * i # Itera...
true
6dbaeac22713d2537bc8eae746781641e8b0a86a
NoahNacho/python-solving-problems-examples
/Chapter7/Exercise1.py
308
4.28125
4
# Write a function to count how many odd numbers are in a list. # Base of function was taken from Chap6 Exercise14 def is_even(n): num = 0 for odd in n: if (odd % 2) == 0: pass else: num += 1 return num odd_list = [1, 2, 3, 4, 5] print(is_even(odd_list))
true
8cb6d0552df6cbd44d7462aa9a0fdc5b91f90474
denny61302/100_Days_of_Code
/Day19 Racing Game/main.py
1,371
4.1875
4
from turtle import Turtle, Screen import random colors = ["red", "yellow", "green", "blue", "black", "purple"] turtles = [] for _ in range(6): new_turtle = Turtle(shape="turtle") turtles.append(new_turtle) is_race_on = False screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(ti...
true
c0f64d4b90693d45bfe23da72c3cba4a2632bd61
darrenredmond/programming-for-big-data_10354686
/CA 1/TestCalculator.py
2,884
4.15625
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 16 19:08:49 2017 @author: 10354686 """ # Import the Python unittest functions import unittest # Import the functions defined in the 'Calculator' file from Calculator import * # Create a class which extends unittest.TestCase class TestCalculator(unittest.TestCase): ...
true
af68068c121d2eeebb9a1f1e1daaadb89af9b634
abby-does-code/machine_learning
/quiz2.py
2,781
4.5
4
# Start# """You are to apply skills you have acquired in Machine Learning to correctly predict the classification of a group of animals. The data has been divided into 3 files. Classes.csv is a file describing the class an animal belongs to as well as the name of the class. The class number and class type are the two...
true
b883911a98cd09445da07329c1cdca5ebb24391e
joedo29/DataScience
/MatplotlibPractices.py
733
4.25
4
import numpy as np import matplotlib.pyplot as plt x = np.arange(0, 100) y = x*2 z = x**2 # Exercise 1: Create a single plot fig1 = plt.figure() ax1 = fig1.add_axes([0.1, 0.1, 0.8, 0.8]) ax1.set_xlabel('X') ax1.set_ylabel('Y') ax1.set_title('Outer Plot') ax1.plot(x,y) # Exercise 2: plot inside a plot ax2 = fig1.add_...
true
737baea08cfb3099f127d972318818e92f915437
mattyice89/LearnPythonTheHardWay
/ex19.py
1,243
4.15625
4
# defining the argument Cheese and crackers and naming your variables def cheese_and_crackers(cheese_count,boxes_of_crackers): # printing out the first variable, named "cheese_count" print(f"You have {cheese_count} cheeses!") # printing out the second variable, named "boxes_of_crackers" print(f"You have...
true
96c2ccd7e834bb194bb50973e772580784ee9455
trustme01/PythonCrashCourse2
/ch_3/cars.py
753
4.59375
5
# Sorting a list PERMANENTLY with the sort() method. # Alphabetically: cars = ['bmw', 'audi', 'toyota', 'subaru'] cars.sort() print(cars) # Reverse alphabetically: cars.sort(reverse=True) print(cars) # Sorting a list TEMPORARILY with the sort() method. cars2 = ['bmw', 'audi', 'toyota', 'subaru'] print('\nHere is th...
true
9be69557321c8e1c498e26371acb00e06fc3bad5
MDCGP105-1718/portfolio-S191617
/ex8.py
730
4.25
4
portion_deposit = 0.20 current_savings = 0 r = 0.04 monthly_interest = current_savings*(r/12) monthly_salary= annual_salary/12 total_cost = float(input("Total cost of the house")) annual_salary= float(input("Enter the starting annual salary:")) portion_saved= float(input("How much money do you want to save?")) semi_an...
true
2288678a651b13e959bcb43c28771c64a2ec3dd8
amey-kudari/NN_nLines
/I_am_trask/basic-python-network/2-layer-simple.py
2,282
4.15625
4
""" code taken from "https://iamtrask.github.io/2015/07/12/basic-python-network/" I learnt about neural networks from here, but I feel this is a little complicated as it needs you to actually compute the matricies on paper to see what is happening. I made a simpler model that isnt full batch training, and in my opini...
true
eb48a58c8578f145a0b9a892c5b4efb100314fdd
Ridwanullahi-code/basic-python
/exercise1.py
313
4.4375
4
# write a python program which accepts the users's first and last name # and print them in reverse order with space between them # assign first name value first_name = 'Ridwanullahi' last_name = 'Olalekan' # To display the input values print(f'{last_name} {first_name}') print(name) print("school")
true
181165441ccf08e506b38f64ad9b5dea8de93f33
jesusdmartinez/python-labs
/14_list_comprehensions/14_04_fish.py
277
4.15625
4
''' Using a listcomp, create a list from the following tuple that includes only words ending with *fish. Tip: Use an if statement in the listcomp ''' fish_tuple = ('blowfish', 'clownfish', 'catfish', 'octopus') list = [w for w in fish_tuple if w[-4:] == 'fish'] print(list)
true
fef717e2f35131316bf6f6d9bfd2b4f69df91e53
jesusdmartinez/python-labs
/03_more_datatypes/1_strings/03_04_most_characters.py
445
4.40625
4
''' Write a script that takes three strings from the user and prints the one with the most characters. ''' string1 = str(input("please input a string1")) string2 = str(input("please input a string2")) string3 = str(input("please input a string3")) len1 = len(string1) len2 = len(string2) len3 = len(string3) big = max...
true
1c6d7f8e10eee6f71804df3c4847cacb24e60966
jesusdmartinez/python-labs
/13_aggregate_functions/13_03_my_enumerate.py
333
4.25
4
''' Reproduce the functionality of python's .enumerate() Define a function my_enumerate() that takes an iterable as input and yields the element and its index ''' def my_enumerate(): my_num = input("create a list of anything so I can enumerate") new_num = my_num.split() print(list(enumerate(new_num))) m...
true
347b7a7baabf1a8713e4a30df0bbc95ed1c179b0
ankitpatil30/Ankit_Python_Projects
/Python_Assignments/Task 4/11.py
592
4.125
4
# TASK FOUR # TRADITIONAL FUNCTIONS,ANONYMOUS FUNCTIONS & # HIGHER ORDER FUNCTIONS # 11. Write a program which uses map() and filter() to make a list whose elements are squares of even # numbers in [1,2,3,4,5,6,7,8,9,10]. # Hints: Use filter() to filter even elements of the given listUse map() to generate a list o...
true
b8d6cefaa900afdff0cb72b063f2b8d3f2e55f38
ankitpatil30/Ankit_Python_Projects
/Python_Assignments/Task 2/4.py
499
4.15625
4
#TASK TWO #OPERATORS AND DECISION MAKING STATEMENT #4. Write a program in Python to break and continue if the following cases occurs: #If user enters a negative number just break the loop and print “It’s Over” #If user enters a positive number just continue in the loop and print “Good Going” x = int(input("Enter...
true
7e0b5ce3a86eae805fad3f1de40b0340c8978032
ankitpatil30/Ankit_Python_Projects
/Python_Assignments/Task 1/4.py
263
4.34375
4
#TASK ONE NUMBERS AND VARIABLES #4. Write a program that takes input from the user and prints it using both Python 2.x and Python 3.x Version. color = raw_input("Enter the color name: ") #print(color) color = input("Enter the colour name: ") print(color)
true
5154b91ee876350111fd6f0a8c35d268798ee742
ankitpatil30/Ankit_Python_Projects
/Python_Assignments/Task 4/9.py
624
4.34375
4
# TASK FOUR # TRADITIONAL FUNCTIONS,ANONYMOUS FUNCTIONS & # HIGHER ORDER FUNCTIONS # 9. Write a function called showNumbers that takes a parameter called limit. It should print all the # numbers between 0 and limit with a label to identify the even and odd numbers. # Sample input: show Numbers(3) (where limit=3) ...
true
4fcadc2b4105a17dc95f54cca290644e3436b75a
ujwalnitha/stg-challenges
/learning/basics12_number_converter_class.py
1,108
4.15625
4
'''' This file is to wrap number to words code in a class Reference: https://www.w3schools.com/python/python_classes.asp If we have to use a method from Class, outside calling file -we have to import the class in calling file -create an object and call function -if it is a static function, call ClassName.function_na...
true
289cc536fb1d4a594155fd8f2ae37bb669feba57
vishwasanavatti/Interactive-Programming-with-python
/Interactive Programming with python/second_canvas.py
397
4.21875
4
# Display an X ################################################### # Student should add code where relevant to the following. import simplegui # Draw handler def draw(canvas): canvas.draw_text("X",[96, 96],48,"Red") # Create frame and assign callbacks to event handlers frame=simplegui.create_frame("Test", 200,...
true
fd503ae0aae52dff9f8d209d72ff86af9943ec63
j0sht/checkio
/three_words.py
467
4.21875
4
# You are given a string with words and numbers separated by whitespaces. # The words contains only letters. # You should check if the string contains three words in succession. import re def checkio(s): return re.search(r'[a-zA-Z]+\s[a-zA-Z]+\s[a-zA-Z]+', s) != None print(checkio("Hello World hello") == True) p...
true
c2991ed8c969b799c5458bac865e478122ec04af
panmari/nlp2014
/ex1/task3.py
334
4.15625
4
#!/usr/bin/python3 print("Please enter an integer") try: input_int = eval(input()) except NameError as e: print("Oops, that was not an integer!") exit(1) print("The first {} numbers of the fibonacci sequence are: ".format(input_int)) fib = [1,1] for i in range(input_int): fib.append(fib[-1] + fib[-2]...
true
52d504ec91089e3b0eb747b99bf580e08883dc73
cesarg01/AutomateBoringPythonProjects
/collatz.py
973
4.4375
4
# This program take any natural number n. If n is even, divide it by 2 to get n/2, # if n is odd multiply it by 3 and add 1 to obtain 3n+1. Repeat the process indefinitely. # The conjecture is that no matter what number you start with, you will always eventually reach 1. # This is known as the Collatz conjecture. d...
true
729f00cf4e463f39588ac965b873b52ba9baf5c4
CWMe/Python_2018
/Python_Learn_Night/Python_Dictionaries.py
729
4.46875
4
# Dictionaries in Python # { } # Map data type in Python # key : value paris for data. my_dictionary = {"name": "CodeWithMe", "location": "library", "learning": "Python"} # dictionaries may not retain the order in which they were created (before python 3.6.X). # print(my_dictionary) # accessing VALUES from a diction...
true
ac4062b52a08a61400ae7eb41b1554b907b23887
thewchan/python_oneliner
/ch3/lambda.py
637
4.28125
4
"""Lambda function example. Create a filter function that takes a list of books x and a minimum rating y and returns a list of potential bestsellers that have higher than minimum rating, y' > y. """ import numpy as np books = np.array([['Coffee Break Numpy', 4.6], ['Lord of the Rings', 5.0], ...
true
14f266de9648b45e70a6d58b35e3f44be4611047
Adriana-ku06/programming2
/pythom/exercise26.py
2,959
4.125
4
#Adriana ku exercise 26 from sys import argv print("How old are you?", end=' ') age = input() print("How tall are you?", end=' ') tall=input() #undeclared tall variable print("How much do you weigh?", end=' ')#first error missing closing parentheses weight = input() print(f"So, you're {age} old, {tall} height...
true
b7d01a00f0161216a6e5205b31638c9a8ac0a8ca
DavidM-wood/Year9DesignCS4-PythonDW
/CylinderVolCon.py
377
4.21875
4
import math print("This program calculates the volume of") print("a cylinder given radius and height") r = input("what is the radius: ") r = float(r) h = input("what is the height: ") h = float(h) v = math.pi*r*r*h v = round(v,3) print("Given") print(" radius = ",r," units") print(" height = ",h," units") print("...
true
1a49be8a93de2ed7e8f6136933bcb194d62c168a
DavidM-wood/Year9DesignCS4-PythonDW
/LoopDemo.py
1,509
4.25
4
#A loop is a programjnf structure that can repeat a section of code. #A loop can run the same coede exactly over and over or #with domr yhought it can generate a patter #There are two borad catagories of loops #Conditional loops: These loop as long as a conditon is true #Counted Loops (for): These loop usikng a cou...
true
9b7fa70f9b7c0cf967d63a5ea24afdaa38e5acdd
shach934/leetcode
/leet114.py
974
4.21875
4
114. Flatten Binary Tree to Linked List Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ ...
true
5cfb176a07bdb5473c6317586573525306cba589
shach934/leetcode
/leet403.py
2,213
4.1875
4
403. Frog Jump A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. Given a list of stones' positions (in units) in sorted ascending order, determine if the frog is able to cross the ri...
true
65dc7d8c342a8da41493e7dfc1459e1d468359d6
Larry-Volz/python-data-structures
/17_mode/mode.py
1,038
4.21875
4
def mode(nums): """Return most-common number in list. For this function, there will always be a single-most-common value; you do not need to worry about handling cases where more than one item occurs the same number of times. SEE TEACHER'S SOLUTION He uses a dictionary, {}.get(num, 0)+1 to ad ...
true
843b0e4e5ae83c783df4ddb4518f56bd974a1ccf
abigailshchur/KidsNexus
/hangman_complete.py
2,609
4.125
4
import random # we need the random library to pick a random word from list # Function that converts a list to a string split up be delim # Ex) lst_to_str(["a","b","c"],"") returns "abc" # Ex) lst_to_str(["a","b","c"]," ") returns "a b c" # Ex) lst_to_str(["a","b","c"],",") returns "a,b,c" def lst_to_str(lst, delim): ...
true
6b45fe344565cb148d4b0baa4b3ed2b6fe75d583
heasleykr/Algorithm-Challenges
/recursion.py
843
4.25
4
# Factorials using recursion def fact(n): # base. If n=0, then n! = 1 if n == 0: return 1 # else, calculate all the way until through return n*fact(n-1) # one liner # return 1 if not n else n*fact(n-1) def fact_loop(n): # base case return n if 0 # if n == 0: # return ...
true
f374c8b57722d4677cbf9cc7cde251df8896b33d
sreerajch657/internship
/practise questions/odd index remove.py
287
4.28125
4
#Python Program to Remove the Characters of Odd Index Values in a String str_string=input("enter a string : ") str_string2="" length=int(len(str_string)) for i in range(length) : if i % 2 == 0 : str_string2=str_string2+str_string[i] print(str_string2)
true
a2807475320a5bb3849a943dbe5dd9f9331254ed
sreerajch657/internship
/practise questions/largest number among list.py
259
4.34375
4
#Python Program to Find the Largest Number in a List y=[] n=int(input("enter the limit of list : ")) for i in range(0,n) : x=int(input("enter the element to list : ")) y.append(x) y.sort() print("the largest number among list is : %d "%(y[-1]))
true
fdd72acf5565bdee962fed5471249461843d01ab
Neil-C1119/Practicepython.org-exercises
/practicePython9.py
1,511
4.28125
4
# This program is a guessing game that you can exit at anytime, and it will # keep track of the amount of tries it takes for the user to guess the number # Import the random module import random # Define the function that returns a random number def random_num(): return random.randint(1, 10) # Self exp...
true
2c67dd011e851c1e79a23004908cf69bc2c34607
ifegunni/Cracking-the-coding-interview
/arrays1.7.py
1,923
4.3125
4
# Rotate Matrix: Given an image represented by an NxN matrix, where each pixel in the image is 4 # bytes, write a method to rotate the image by 90 degrees. Can you do this in place? #This solution is my O(n2) solution def rotate(matrix): newMatrix = [row[:] for row in matrix] #we have to copy the matrix so we do...
true
238ac35d263a55d451dfd2b0f3fb1cfe4d12363d
ifegunni/Cracking-the-coding-interview
/arrays1.6.py
2,910
4.25
4
# String Compression: 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 assum...
true
a571e0e9e507b15d778cf7c7210864c47422c138
kehsihba19/MINI-PYTHON-Beginner-Project
/Hangman.py
1,190
4.28125
4
import random def word_update(word, letters_guessed): masked_word = "" for letter in word: if letter in letters_guessed: masked_word += letter else: masked_word += "-" print( "The word:", masked_word) # List of words for the computer to pick from words = ("basketball", "football"...
true
6c00f55d6f5c28b24afd48cadf14bfee4add3c26
r121196/Python_exercise
/caluclator/simple calculator.py
668
4.1875
4
operation = input(''' type the required maths operation: + for addition - for substraction * for multiplication / for division ''') n1 = int(input('Enter the first number: ')) n2 = int(input('Enter the second number: ')) if operation == '+': print ('{} + {} = '. format(n1, n2)) print (n1 + n2) ...
true
f32ad9099e69b7a8a70715e988aa2dde959778bf
lengau/dailyprogrammer
/233/intermediate.py
2,816
4.125
4
#!/usr/bin/env python3 # Daily Programmer #233, Intermediate: Conway's Game of Life # https://redd.it/3m2vvk from itertools import product import random import sys import time from typing import List class Cell(object): """A single cell for use in cellular automata.""" def __init__(self, state: str): ...
true
2f395c7039ae26aa8c75b03f3727cd0c9235bcf5
Pavan-443/Python-Crash-course-Practice-Files
/chapter 8 Functions/useralbums_8-8.py
570
4.21875
4
def make_album(artist_name, title, noof_songs=None): """returns info about music album in a dictionary""" album = {} album['artist name'] = artist_name.title() album['song title'] = title.title() if noof_songs: album['no of songs'] = noof_songs return album while True: print('\ntype...
true
f390c30e06bdacc7e29d38fc519c95fb478bd924
zemery02/ATBS_notes
/Lesson_Code/hello.py
631
4.125
4
#! python3 # 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 = input() print('You ...
true
4f8383ae5d0439bb9972f2852623552e65a06527
vik13-kr/telyport-submission
/api/build_api/Q-2(Reverse character).py
494
4.3125
4
'''Reverse characters in words in a sentence''' def reverse_character(p_str): rev_list = [i[::-1] for i in p_str] #reversed characters of each words in the array rev_string = " ".join(map(str,rev_list)) #coverted array back to string return rev_string n_str = 'My name is Vikas...
true
ac9e55e127c2972a737cdbdea7db49847381a993
DonLiangGit/Elements-of-Programming
/data_structure/Linkedlist_Node.py
1,161
4.1875
4
# define a Node class for linked list # __name__ & __main__ # http://stackoverflow.com/questions/419163/what-does-if-name-main-do # http://stackoverflow.com/questions/625083/python-init-and-self-what-do-they-do class Node: def __init__ (self,initdata): self.data = initdata self.next = None def getData (self): ...
true
12d289806c1323503a8a6040bc0a14f8d440711f
samuelbennett30/FacePrepChallenges
/Lists/Remove Duplicates.py
801
4.40625
4
''' Remove the Duplicate The program takes a lists and removes the duplicate items from the list. Problem Solution: Take the number of elements in the list and store it in a variable. Accept the values into the list using a for loop and insert them into the list. Use a for loop to traverse through the elements of the ...
true
390aef3387103d3c30e03d19ff5dcf9985abee3b
tushar8871/python
/dataStructure/primeNumber.py
1,689
4.125
4
#generate prime number in range 0-1000 and store it into 2D Array #method to create prime number def primeNumber(initial,end): #create a list to store prime number in 0-100,100-200 and so-on resultList=[] try: #initialize countt because when we generate prime number between 0-100 then we have to ini...
true
d43783ac3758262be6e636db5da6a2725a1c218a
tushar8871/python
/functioalProgram/stringPermutation.py
1,002
4.28125
4
#Generate permutation of string #function to swap element of string def swap(tempList,start,count): #swapping element in list temp=tempList[start] tempList[start]=tempList[count] tempList[count]=temp #return list of string return tempList #generate permutation of string def strPermutation(Str,...
true
8973a64b33c9587d2b2f5dd4d1aaffcd54d10e17
bezdomniy/unsw
/COMP9021/Assignment_1/factorial_base.py
775
4.25
4
import sys ## Prompts the user to input a number and checks if it is valid. try: input_integer = int(input('Input a nonnegative integer: ')) if input_integer < 0: raise ValueException except: print('Incorrect input, giving up...') sys.exit() integer=input_integer ## Prints factorial base of 0...
true
eb945c57d13c1364f773dd2bf64c3afcacf865ea
gtanubrata/Small-Fun
/return_day.py
1,129
4.125
4
''' return_day(1) # "Sunday" return_day(2) # "Monday" return_day(3) # "Tuesday" return_day(4) # "Wednesday" return_day(5) # "Thursday" return_day(6) # "Friday" return_day(7) # "Saturday" return_day(41) # None ''' days = {1: "Sunday", 2: "Monday", 3: "Tuesday", 4: "Wednesday", 5: "Thursday", 6: "Friday", 7: "S...
true
f306b95eff6714bebe60f7b9a3332ec9f1399853
jackh423/python
/CIS41A/CIS41A_UNITC_TAKEHOME_ASSIGNMENT_1.py
2,654
4.25
4
""" Name: Srinivas Jakkula CIS 41A Fall 2018 Unit C take-home assignment """ # First Script – Working with Lists # All print output should include descriptions as shown in the example output below. # Create an empty list called list1 # Populate list1 with the values 1,3,5 # Create list2 and populate it with the valu...
true
af8dd324cd12deb2647eb541822000c9b377c99b
xurten/python-training
/tips/tip_54_use_lock_for_threads.py
1,317
4.125
4
# Tip 54 use lock for threads from threading import Thread, Lock HOW_MANY = 10 ** 5 class Counter: def __init__(self): self.count = 0 def increment(self, offset): self.count += offset def worker(index, counter): for _ in range(HOW_MANY): counter.increment(1) def thread_exampl...
true
ff37f855eacfc27e1a7b1cd5247facac93f4b3c8
jack-evan/python
/tuples.py
239
4.21875
4
#this is a tuple someval = ("one","two",345,45.5,"summer") #print tuple print someval #prints tuple print someval[0] #prints first element of the tuple print someval[2:] #prints third element and on print someval * 2 #prints tuple twice
true
15498baa6391c1f3976f9ac752e66028ae67c632
jann1sz/projects
/school projects/python/deep copy of 2d list.py
1,215
4.25
4
def deep_copy(some_2d_list): #new_copy list is the list that holds the copy of some_2d_list new_copy = [] #i will reference the lists within some_2d_list, and j will reference the #items within each list. i = 0 j = 0 #loop that creates a deep copy of some 2d list for i in ...
true
cd6d6f7b6b9b4e5e7fc39d1fb56c0995147d33cc
mskaru/LearnPythonHardWay
/ex15.py
791
4.3125
4
# -*- coding: utf-8 -*- from sys import argv # script = py file name that I want to run # filename = the txt or word or whichever other file type # i want to read the information from script, filename = argv # command that calls the content of the file as txt txt = open(filename) print "Here's your file %r:" % filen...
true
87e1314624ce2cfd7672d3f8781b94135aca3796
rumbuhs/Homeworks
/HW6/hw6_t2.py
1,046
4.4375
4
from math import pi from math import sqrt def calculator(shape): """ This funktion will find the square of a rectangle, triangle or circle. depending on the user's choice. Input: name of shape Otput: the square of the shape """ shape = shape.upper() if shape == "RECTANGLE": ...
true
42959f7f25f93f11e5edf0f200d0f74b2dcf724d
Hunt-j/python
/PP02.py
546
4.15625
4
num = int(input("Pick a number:")) check = int(input("Pick a second number:")) if (num % 2 == 0): print("The number you've chosen is even") else: print("The number you've chosen in odd") if (num % 4 ==0): print("The number you've chose is divisible by 4") else: print("The number you've choses is not d...
true
bd320410d6462d80f43620755a40495baa53bc0b
sshridhar1965/subhash-chand-au16
/FactorialW3D1.py
201
4.34375
4
# Factorial of a number num = int(input("Please Enter a number whose factorial you want")) product=1 while (num>=1): product = num*product num = num-1 print("The Factorial is ",product)
true
771576a2ea6f1e99200c242e3d53ea510e4a51e5
DanielVasev/PythonOnlineCourse
/Beginner/most_common_counter.py
1,244
4.34375
4
""" How to count most common words in text """ from collections import Counter text = "It's a route map, but it's only big enough to get to the starting point. Many businesses have been asking\ when they will be allowed to reopen. Now they have some rough indication, pencilled in to the calendar, but far from\ a...
true
4e2005cd521e0d50e46f64e26530224ceedd53c8
515ek/PythonAssignments
/Sample-2-solutions/soln20.py
1,343
4.3125
4
## Name: Vivek Babu G R ## Date: 26-07-2018 ## Assignment: Sample 2 ## Question: A simple substitution cipher is an encryption scheme where each letter in an alphabet to replaced by a different letter in the same alphabet ## with the restriction that each letter's replacement is unique. The template for this questio...
true
cd4e8d94167d991aacdc132a2ca3f22a107e4c16
515ek/PythonAssignments
/Sample-1-solutions/soln18.py
385
4.1875
4
## Name: Vivek Babu G R ## Date: 26-07-2018 ## Assignment: Sample 1 ## Question: Python Program to Take in a String and Replace Every Blank Space with Hyphen. ############################################################################################ str1 = input('Enter the string\n') str2 = '' for s in str1.split(' '...
true
64d72e038c18c73bcc5ead26b026a6c3d4826e3d
ClntK/PaymentPlanner
/paymentPlanner.py
2,030
4.1875
4
""" File: paymentPlanner.py Author: Clint Kline Last Modified: 5/30/2021 Purpose: To Estimate a payment schedule for loans and financed purchases. """ # input collection price = (float(input("\nPurchase Price: "))) months = (float(input("Loan Duration(in months): "))) # example "12" for one year, "120" for 10 y...
true
9731d705b7cb3fdf08c13bb6790daac74765d754
ManavParmar1609/OpenOctober
/Data Structures/Searching and Sorting/MergeSort.py
1,275
4.34375
4
#Code for Merge Sort in Python #Rishabh Pathak def mergeSort(lst): if len(lst) > 1: mid = len(lst) // 2 #dividing the list into left and right halves left = lst[:mid] right = lst[mid:] #recursive call for further divisions mergeSort(left) mergeSort(right) ...
true
b44d519c3cf9f4dd9f741d710eff3447d9991a22
ManavParmar1609/OpenOctober
/Algorithms/MemoizedFibonacci.py
927
4.3125
4
""" @author: anishukla """ """Memoization: Often we can get a performance increase just by not recomputing things we have already computed.""" """We will now use memoization for finding Fibonacci. Using this will not only make our solution faster but also we will get output for even larger values such as 1...
true
f107b6b4d03e7557bfd26597d75acd953d1e5cda
EvgenyKirilenko/python
/herons_formula.py
320
4.4375
4
#this code calculates the area of triangle by the length of the given sides #by the Heron's formula from math import sqrt a=int(input("Enter side A:")) b=int(input("Enter side B:")) c=int(input("Enter side C:")) p=float((a+b+c)/2) s=float(sqrt(p*(p-a)*(p-b)*(p-c))) print ("Area of the triangle is : ",s)
true
c0e3604aff31861c0e38f030e91b3a5b82c29049
pratikpwr/Python-DS
/strings_6/lenghtOfStrings.py
329
4.34375
4
# length of string can be calculated by len() name = input("Enter string: ") length_of_string = len(name) print("string:", name) print("length of string:", length_of_string) # max and min of String or others maxi = max(name) mini = min(name) print("maximum:", maxi + "\nminimum:", mini) # slicing a String print(na...
true
427601166ccc5624317e9fea05adc163236321ae
ARAV0411/HackerRank-Solutions-in-Python
/Numpy Shapes.py
257
4.1875
4
import numpy arr= numpy.array(map(int, raw_input().split()) print numpy.reshape(arr, (3,3)) # modifies the shape of the array #print arr.shape() --- prints the rows and columns of array in tuples # arr.shape()= (3,4) --- reshapes the array
true
1c9ab653a40c59ba50f04719d8950a2656fdd6f5
ybharad/DS_interview_prep_python
/prime_factors.py
736
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Apr 26 20:43:26 2020 @author: yash this function calculates the factors of any number which are only prime numbers it reduces the factors of a number to its prime factors """ import math def primeFactors(n): # Print the number of two's that divid...
true
db6ef77f8dd537603785af1ca4ff554cb837e9c7
arshad-taj/Python
/montyPython.py
260
4.28125
4
def reverse(s): if len(s) == 0: return s else: return reverse(s[1:]) + s[0] s = "Geeksforgeeks" print("The original string is : ", end="") print(s) print("The reversed string(using recursion) is : ", end="") print(reverse(s))
true