blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
9dd98b9562147e6572882d28e8a278d3438bc6b7
plasticroad/DataCamp
/Python/07.Cleaning-Data-in-Python/02.Tidying-data-for-analysis/01.Reshaping-your-data-using-melt.py
1,553
4.65625
5
''' Reshaping your data using melt Melting data is the process of turning columns of your data into rows of data. Consider the DataFrames from the previous exercise. In the tidy DataFrame, the variables Ozone, Solar.R, Wind, and Temp each had their own column. If, however, you wanted these variables to be in rows i...
true
33b4e0192e47b7663d885d4ba979de6fcbf07ae8
plasticroad/DataCamp
/Python/02.Intermediate-Python-for-Data-Science/02.Dictionaries - Pandas/11.Square-Brackets-(1).py
1,169
4.375
4
''' Square Brackets (1) In the video, you saw that you can index and select Pandas DataFrames in many different ways. The simplest, but not the most powerful way, is to use square brackets. In the sample code on the right, the same cars data is imported from a CSV files as a Pandas DataFrame. To select only the ca...
true
3798e3ba516bf917dddf08092c7eb552ae5f5df0
plasticroad/DataCamp
/Python/02.Intermediate-Python-for-Data-Science/03.Logic-Control-Flow-and-Filtering/09.Driving-right-(1).py
1,119
4.46875
4
''' Driving right (1) Remember that cars dataset, containing the cars per 1000 people (cars_per_cap) and whether people drive right (drives_right) for different countries (country)? The code that imports this data in CSV format into Python as a DataFrame is available on the right. In the video, you saw a step-by-s...
true
b8cdcbfe37ad6f39ad407ab946eafc02e5ef1dd2
JennieOhyoung/interview_practice
/stack.py
1,015
4.15625
4
"""Implement a stack using list that includes the following operations - Stack(): creates stack - push(item): adds new item - pop(): remoes top item - peek(): returns top item w/out removing it - isEmpty(): tests to see if stack is empty - size(): returns number of items on stack - print ...
true
63dc2b73de9c0bc312d128ca8266cea413280489
JennieOhyoung/interview_practice
/is_rotation.py
631
4.5625
5
#1.8 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings s1 s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring ( waterbottle is rotation of erbottlewat) s1 = "waterbottle" s2 = "bottlewater" def is_substring(s1, s2): return...
true
de671d2975dd7e6848be3ae68e86e57750669393
JennieOhyoung/interview_practice
/balanced_string.py
2,241
4.21875
4
#151 Given an array of strings containing three types of braces: round (), square [] and curly {} Your task is to write a function that checks whether the braces in each string are correctly matched prints 1 to standard output (stdout) if the braces in each string are matched and 0 if they're not (one result per line...
true
b207e9f847f03d1a8081f0e96cb290d06fcf8cce
blemay360/CS-UY-1114
/Homework/hw5/bl2448_hw5_q6.py
337
4.15625
4
string_in=input("Please enter a string of lowercase letters: ") increasing=1 for letter in range(len(string_in)-1): if (ord(string_in[letter]) <= ord(string_in[letter+1])) and (increasing == 1): increasing=1 else: increasing=0 if (increasing == 1): print(string_in, "is increasing.") else: print(string_in, "is n...
true
7806aab38a09515cead2aef86205bdaa22400622
vmurali100/prudvi
/data-collections.py
839
4.28125
4
# Lists # Tuple # Set # Disctionary # List friends = ["Murali","Krishna","Pridvi","Ram"] # print(friends[2]) # friends[0] = "Murali Krishna" # print(friends[0]) # Looping through all its in List # for a in friends: # print(a) # Checking value is exist or not in the list # if "Mural" in friends: # print("Yes ...
true
9db278f0dc7a46f514c0d43a669b72f69524f7a0
tlake/advent-of-code
/2016/day01_no_time_for_a_taxicab/python/src/part1.py
1,396
4.1875
4
#!/usr/bin/env python """Find shortest taxicab distance.""" import re from common import get_input class Walker(object): """Class for turning walking directions into distance from start.""" def __init__(self, input_string): """Initialize.""" self.directions = self._listify_input(input_strin...
true
cf4e77f16241a040dac1023d9501ca8442d54f6b
sookoor/PythonInterviewPrep
/search_with_empty_strings.py
2,104
4.21875
4
# Given a sorted array of strings which is interspersed with empty # strings, finds the location of a given string. def _search_with_empty_strings(query, string_array, lower, upper): if upper < lower: return -1 mid = lower + ((upper - lower) // 2) mid_val = string_array[mid] if mid_val != "":...
true
2f4b682f22cc955fd731c5d2b1a8773000d37e95
sookoor/PythonInterviewPrep
/check_rotation.py
544
4.3125
4
def check_rotation(s1, s2): """Assuming method isSubstring checks is one word is a substring of another, given two strings, s1 and s2, checks if s2 is a rotation of s1 using only one call to isSubstring""" s1_len = len(s1) if s1_len > 0 and s1_len = len(s2): return isSubstring(''.join([s1, ...
true
e673e796ef1a379d5333302472f015447f77614d
spoty/Py_builtins
/builtins/input.py
1,060
4.28125
4
""" The difference is that raw_input() does not exist in Python 3.x, while input() does. Actually, the old raw_input() has been renamed to input(), and the old input() is gone (but can easily be simulated by using eval(input())). In Python 2, raw_input() returns a string, and input() tries to run the input as a Pytho...
true
80b75ee974e79789f9400940cdfb52e27107aa50
spoty/Py_builtins
/builtins/tuple.py
1,800
4.28125
4
""" tuple([iterable]) Return a tuple whose items are the same and in the same order as iterable‘s items. iterable may be a sequence, a container that supports iteration, or an iterator object. If iterable is already a tuple, it is returned unchanged. For instance, tuple('abc') returns ('a', 'b', 'c') a...
true
8382de9ba6e42bd6f4d0084ba428f61c3923bcd7
spoty/Py_builtins
/TOPICS/Lazy_evalution.py
1,612
4.3125
4
The object returned by range() is known as a generator. Instead of storing the entire range, [0,1,2,..,9], in memory, the generator stores a definition for (i=0; i<10; i+=1) and computes the next value only when needed (AKA lazy-evaluation). Essentially, a generator allows you to return a list like structure, but he...
true
bafaae55131f60d5675a3f83365e1a1c571eec90
spoty/Py_builtins
/builtins/divmod.py
1,163
4.125
4
""" divmod(a, b) Takes two (non complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using long division. With mixed operand types, the rules for binary arithmetic operators apply. For plain and long integers, the result is the same as (a // b, a % b). For floating...
true
0e4c74aa6256d8cfa395331aafe7c3dfd266bab5
LukazDane/CS2.1
/sorting_integer.py
2,893
4.21875
4
from sorting_iterative import insertion_sort def counting_sort(numbers): """Sort given numbers (integers) by counting occurrences of each number, then looping over counts and copying that many numbers into output list. TODO: Running time + Memory usage: O(n+k) goes through input at least twice, and uses ...
true
7d91fbf9c01643d583fb638d4b48824c0717b40d
GlaceonDude/Projects
/Project_5_AB.py
1,602
4.46875
4
#Anthony Barrante #ITP 100 #Chapter 5 Project #This program uses functions to convert numbers #from different bases baseDictionary = {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'A':10,'B':11, 'C':12,'D':13,'E':14,'F':15} def repToDecimal(fromNumber, fromBase): ...
true
eaa9785516a122c036b770e526a7d9815d943e8f
JesseNicholas00/IdeaBag
/RandomNumberGen.py
561
4.25
4
import random def CoinFlip(iteration): #this function does a coin flip the number #of times the user has requested --> iteration result = {'heads':0,'tails':0} for i in range(iteration): flip = random.randint(0,1) if flip == 0: result['heads'] += 1 else: ...
true
bfa1613301fbeb5781e54fb4e2f91b319b90a865
dhavalKalariya/The-Art-of-Doing-Projects
/Loop_through_elements.py
710
4.4375
4
#Looping through a list of Elements with a for loop teams = ["Dhaval","Ritu","Pooja","Payal"] print(teams) print(type(teams)) #print each attribute print(teams[0].title()) print(teams[1].title()) print(teams[2].title()) print(teams[3].title()) #Using the loop print each elements for i in teams: print(i.title()...
true
78dfc92071a5a41072bc2b1fb1bf2f8e7fbc5c3c
dhavalKalariya/The-Art-of-Doing-Projects
/Problem15-AverageCalculator.py
2,962
4.3125
4
# Average Calculator print("Welcome to the Average Calculator App") #Get the User input name = input("\nWhat is your name: ").title() gradeNum = int(input("How many grades would you like to enter: ")) #Empty list to store the input values realGrade = [] #loop the input values and append to the list for i in range(gr...
true
d21e8ddb3c1d5262c0dfc421d7d134f9c66be48c
O-Okasha/Algorithms
/Knapsack - python - recursive.py
1,413
4.125
4
# Knapsack problem - recursive from timeit import default_timer as timer weight = [3, 1, 3, 4, 2] # weight of the items value = [2, 2, 4, 5, 3] # Value of the items def knapsack(C, W, V): cache = [[0] * (C + 1) for y in range(len(W) + 1)] start = timer() answer = knapsack_cached(C, W, V, cach...
true
5ef55e086a1d33ac746e994d802df419db904197
VargheseVibin/dabble-with-python
/Day19_02(TurtleRace)/main.py
1,040
4.21875
4
import turtle as t from turtle import Screen import random colors =["red", "orange", "yellow", "green", "blue", "purple"] screen = Screen() screen.setup(width=500, height=400) your_bet = screen.textinput(title="Make your bet", prompt="Which turtle are you betting on to win the race? Enter a color:") turtles = [] x = ...
true
a9bf093655384d0235735d9202fcdd63ff9c65fe
duchezbr/DataWrangling
/replace_nans.py
928
4.28125
4
# -*- coding: utf-8 -*- """ Impute values to pandas DataFrame Returns a dataframe that replaces NaN values with either the mean, median, or mode for specified columns. If catagorical variables are present the 'mode' function must be used to impute values. Input: df - pandas DataFrame columns - list of col...
true
624ac0f93d0c414ce53ebb4455e0079e3920cffa
snowleo208/mooc-coursework
/6.00.1x/week2/set2.py
2,000
4.3125
4
#Problem 2 - Paying Debt Off in a Year # Now write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months. By a fixed monthly payment, we mean a single number which does not change each month, but instead is a constant amount that will be paid each mo...
true
b92d082c295ab799305562cd95982e84b9c60700
rsedlr/Python
/Menu example.py
676
4.125
4
menu ="what would you like:\n\ 1.A compliment?\n\ 2.An insult?:\n\ 3.A proverb?\n\ 4.An idiom?\n\ Q.Quit\n"#prints when ran answer = input(menu)#states 'answer' is text so numbers, decimals and letters can be used if answer =="1": print("you look lovely today") elif answer == "2": print("You smell funny") elif ...
true
fb319a936636622a021f782650a43532cc12f1f1
sabrinsingh/Python
/Caesar_cipher.py
880
4.21875
4
# 1. A Caesar Cipher (or Cipher Wheel) is an ancient mechanism for encrypting text and a popular children's toy. # It encrypts a message by shifting each alphabetic character in the text by a fixed amount. # For example, a Caesar cipher with a shift of 4 translates a to e, b to f etc. # abcdefghijklmnopqrs...
true
05f38a3a817fa52a7b70d074d181a43aca5fb655
juborajnaofel/My_Random_Python_Programming
/Python Classes and Objects/5. del object properties and object.py
451
4.125
4
class Car: def __init__(c,wheels,color): c.wheels = wheels c.color = color def fun(abc): print("Car color is: "+ abc.color) car_1 = Car(4,"Red") print("Car1: "+"Wheels = "+str(car_1.wheels)+", Color = "+str(car_1.color)) #Now lets delete the color property del car_1.color #The color property is deleted from ca...
true
54d077d68756409a2e1d6b27eb9d2e223ece08f9
payne/longbaonguyen.github.io
/courses/apcsp/processing_arcade/Labs/bouncing_ball/objects.py
1,772
4.28125
4
""" Bouncing Ball Lab In the video Bouncing Ball, we saw how to simulate a ball bouncing back and forth in one dimension. Fill in the code below so that the ball bounces in two dimension by adding both x and y velocity components. Make it bounce off the four boundary walls. """ from __future__ import division, print_...
true
c603c3cc4282fd54bc3dff1c003947e57eac70f8
drsstein/PyRat
/Examples/LinearRegression.py
1,611
4.28125
4
# short lecture on learning linear neurons by Geoffrey Hinton: # https://www.youtube.com/watch?v=WqQivCl8dmQ import matplotlib.pyplot as plt import numpy as np from numpy.random import rand def run(): #generate n samples of random data n = 100 x = rand(n) #transform data linearly a = 2 b = 0...
true
41a37ef761298e0d12281e811ef1c37264172f1e
pnguyenduong/examples
/lpthw/ex5.py
579
4.15625
4
""" Example using "format string" """ name = "Phong Nguyen Duong" age = 27 # not a lie height = 172 # centimeter weight = 70 # lbs eyes = "Black" teeth = "White" hair = "Black" print(f"Let's talk about {name}.") print(f"He's {height} meters tall.") print(f"He's {weight} pounds heavy.") print("Actually that's not t...
true
db152e1a0c5bfb1ddd9cdd4d71155df54b0a9946
YankeeSoccerNut/python101
/dayofweek.py
353
4.15625
4
daysOfTheWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] userDay = int(raw_input("What day of the week do you want (0-6)?")) print "You picked %s." % daysOfTheWeek[userDay] if userDay == 0 or userDay == 6: print "It's the weekend...you should sleep!" else: print "It's a ...
true
73dcd288fca24a2beb9d13e3d576c97fe638cd27
ngoccuong1999/StudyPython
/ExercisePython/ConditionalStatements.py
898
4.375
4
# #Write a program to prompt the user for hours # # and rate per hour using input to compute gross pay. # Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. # # Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). # # You ...
true
82225f053b6d3c75e797a23824701035f5302489
relydda20/CS-Exercise-Week-2
/problem 1.py
254
4.65625
5
#This program converts an angle from degrees into radians def conversion(degree): pi = 3.14 return (degree * (pi / 180)) degree = 150 radian = conversion(degree) print("The value in degrees is:", degree) print("The Value in radians is:", radian)
true
97b47faa4879fe01186a6c412eeca120b1356eb2
AxayPatoliya/TCS-preparation
/inheritance.py
1,099
4.3125
4
# inheritance means to inherent something to others # like a child can have the behaviour like his parent so we can simply say that behaviour of the parents were inhereted to the ChildProcessError # so we can inheret the nehaviour of Parent class to the Child class # parent class class Dad: def __init__(self, bi...
true
feffa244ee956650775a7eaab7f02ef9d333a593
riedlblower/ud036-python
/mp1-decrypt_secret_msg.py
947
4.1875
4
import os def rename_files(): #1 get file names from a folder file_list = os.listdir(r"D:\udacity\ud036-python\mini-project-1\files") #r for raw path # sample files are f09beijing.jpg, p04chennai.jpg, p02beijing.jpg, etc print file_list saved_path = os.getcwd() print saved_path #2 for...
true
ff023520142e844cb8b1e2303953032e9df75467
ypmagic/algorithms
/python/recursion_reverselist.py
212
4.15625
4
def reverseList (list, new): if list == []: return new else: new = new + [list.pop()] reverseList(list, new) print(reverseList([1, 2, 3, 4, 5], [])) # why isn't this working idk
true
311dcbd96c1a3b7c6ffd728dc5191e6e09c3c7c5
Chandrahas-Soman/Data_Structures_and_Algorithms
/Python/Arrays/Rotate_2D_array.py
1,673
4.46875
4
# Rotate_a_2D_array ''' Image rotation is fundamental operation in computer graphics. 1,2,3 90 degrees 7,4,1 4,5,6 --> Clockwise --> 8,5,2 7,8,9 rotation 9,6,3 write a function that takes input as an n*n 2D array, rotates the array by 90 degrees clockwise. hint: focus on boun...
true
ce80992ad2608764545a4d515b89939a451014d7
Chandrahas-Soman/Data_Structures_and_Algorithms
/Python/Binary_Trees/Implement_preorder_traversal_without_recursion.py
836
4.1875
4
# Implement_preorder_traversal_without_recursion ''' write a program which takes as input a binary tree and performs a preorder traversal of the tree. Do not use recursion. Nodes do not contain parent references. ''' ''' best way to perform preorder traversal without recursion by noting that preorder traversal visit ...
true
c0d8b429ba769d458d2c3461ba4433b1de9656b7
Chandrahas-Soman/Data_Structures_and_Algorithms
/Python/Arrays/sample_offline_data.py
2,065
4.125
4
# sample_offline_data ''' motivation: need for company to select a random subset of its customers to roll out a new feature to. e.g. social networking company may want to see the efect of a new UI on page visit duration without taking the chance of aleinating all its users if the roll out is unsuccessful. ''' ''' i...
true
caa363da93d55172c3d93ca9706df927985c49cf
masoodaqaim/mini-projects
/pigLatin.py
273
4.125
4
''' create a program that takes the first letter of a word and places it at the end and adds 'ay' ex. banana = anana-bay ''' userInput = input('Please enter a word to be converted to pig latin: ') newWord = userInput[1:] print(newWord + '-' + userInput[0] + 'ay')
true
9d2a9a33a3e5f080f4875f7f84644d6599a5d645
masoodaqaim/mini-projects
/diceRollSimulator.py
408
4.1875
4
import random def diceRoll(): dice = random.randrange(1, 7) # a six sided die. print(dice) print('This game will stimulate a dice roll game.\nWith each turn, you will roll a new dice.') userInput = input('Would you like to play (y/n)?: ') while 'y' is userInput: diceRoll() userInput =...
true
258c19ab1da9cfca0c286653e9040df0c37e19d7
allensam88/Sorting
/src/iterative_sorting/iterative_sorting.py
1,457
4.25
4
def selection_sort(arr): # Loop through n-1 elements for i in range(len(arr)): # Start with current index = 0 cur_index = i smallest_index = cur_index # For all indices EXCEPT the last index: # Loop through elements on right-hand-side of current index for item in ...
true
a971818c2504a3892194b45ddc483810146657f7
thesparkvision/DS-Algo
/Graph/Graph1.0/graph.py
2,172
4.21875
4
'''This module contains the code to create a Graph class and also tests it ''' class Graph: '''This class is used to make a blueprint of a Graph ''' def __init__(self,gdict=None): """Constructor to create Graph object, it takes a default argument set to None, to take the graph dictionary""" if gdict is ...
true
d5cfd4cb2415c359d12f09bf706b11ca08372923
thesparkvision/DS-Algo
/Stack/DecToBaseConverter.py
828
4.25
4
from stack import Stack def BaseConverter(num,base): '''This function converts a decimal value to any base value mentioned between 2 to 36''' digits="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rem_stack=Stack() #Pushing remainders to remainder stack while(num!=0): rem=num%base rem_converted=digits[rem] rem_s...
true
5bb771927185c2a12d2d49c112989ca363bd5f73
DanielJBurbridge/Jetbrains-Academy
/Hyperskill/Python/Easy/Coffee Machine/Coffee Machine/3.0/coffee_machine.py
753
4.28125
4
# Write your code here required_water = 200 required_milk = 50 required_beans = 15 water = int(input("write how many ml of water the coffee machine has:\n")) milk = int(input("write how many ml of milk the coffee machine has:\n")) beans = int(input("write how many grams of coffee beans the coffee machine has:...
true
6c5e0eb95ddb265b15163ba135fd5f33f9421f06
aashaanX/Python_Excer
/List_comp.py
326
4.1875
4
"""Let’s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write one line of Python that takes this list a and makes a new list that has only the even elements of this list in it.""" a=[1,2,3,4,5,6,7,8,9] b=[num for num in a if num%2=0] #b is the list cnsisting of only even number...
true
723773aa7f404c0dba7c66e1d77ab5bc01872da6
koleau24/Machine-Learning-And-Deep-Learning
/assignment1.py
703
4.15625
4
#!/usr/bin/env python # coding: utf-8 # # Assignment # # Write a program which will find all such numbers which are divisible by 7 but are not a # multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed # in a comma-separated sequence on a single line. # In[ ]: l=[x for x in ...
true
4f9e78088b7303c79df78a9ca5d62c58f77f378e
ChrisMiller83/Functions
/longest_string.py
279
4.21875
4
# Write a function longest that accepts a List of Strings as an argument. # It should return the longest String in the List. def longest(e): return len(e) list1 = ["Toyota", "Ford", "Chevrolet", "BMW", "Lexus", "Dodge", "Honda"] list1.sort(key=longest) print(list1[-1])
true
9960ca2b13b670fa70b92c723787fa9b34b92c3f
ChrisMiller83/Functions
/largest_num.py
319
4.1875
4
def largest_num(e): return (e) list1 = [200, 12, 33, 56, 7, 890, 0.1, -100] list2 = [3, 22, 45, 2, 435, 67, 5, 89, -20] final_list = list1 + list2 final_list.sort(key=largest_num) print(final_list, end = " ") print(" Is the list of all numbers.") print(final_list[-1], " Is the largest number in the list.")
true
28e17028aa1e5b535313402035244611c073210c
RamtinKosari/Andrew_NG_ML_python
/12.neural_network_logical_XOR_back_prop/main.py
1,673
4.1875
4
import sys from neuron import * from neuralNetwork import * from neuronLayer import * from dataset_multi import * def main(): ''' The objective of this neural network is to use backProp and gradient descent to update a NN design to return XNOR, to return XOR instead ''' dataset = createDataset(); and_nrn = n...
true
d467e1354476744fa7bf7520f98bd4cf71c9bc41
kevinjzheng/CS-UY-1114
/Homeworks/Homework5/kjz233_hw5_qy2a.py
339
4.21875
4
#Problem 2a string = input("Please enter a character: ") if(string.isdigit()==True): type = "digit" else: if (string.islower() == True): type = "lower case letter" elif (string.isupper() == True): type = "upper case letter" else: type = "non-alphanumerical character" print(str...
true
b176e79033131867447570e50663fa4d997812e2
kevinjzheng/CS-UY-1114
/Homeworks/Homework5/kjz233_hw5_qy8.py
210
4.25
4
#Problem 8 line = input("Please enter a line of text: ") ch = input("Please enter the character you want to remove: ") newLine = "" for char in line: if(char != ch): newLine += char print(newLine)
true
6bdc7fba7f5cefe06a860a481fb542c53eb8abae
samishken/python-refresh
/main.py
2,640
4.53125
5
# print("Hello World") # # color = "Red" # thing = "Liverpool FC" # print(color + " is the color of " + thing) # # # print is a python function "the PRINT function" # # whenever we use keywords or functions that are part of the language, # # we're using the programming language's syntax to tell the computer what to do....
true
2f557dd26b22dab36fcc4e4add112a64e32535ed
akshay-sahu-dev/PySolutions
/Leetcode/Hard/Merge K sorted list.py
2,911
4.15625
4
""" You are given an array of k linked-lists lists , each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lists = [[1,4,5],[1,3,4],[2,6]] Output: [1,1,2,3,4,4,5,6] Explanation: The linked-lists are: [ 1->4->5, 1->3->4, 2->6 ] merging the...
true
5af84a821edb2e231afeb34693e798cbadea2a23
clarkfitzg/junkyard
/combinations.py
1,533
4.6875
5
''' combinations.py Demonstrate itertools using basic statistical concepts In this simple card game each card has a value. A player draws 5 cards without replacement and sums their values to determine their final score. Task: Visualize the probability distribution for scores from this card game ''' import itertools...
true
ca706db8ed870ff31d3b92e5a38b9fb8be52ea4b
geomaar/euler
/euler4.py
628
4.1875
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. #Test case, just to verify my result is correct (which it is) for i in range(10,100): for j in range(...
true
aa26f9181fcbea80b5e5de23da50b89c94b26192
vaniroo/intro_class
/contact_ui.py
1,366
4.125
4
import contact_manager def main_menu(): print """ Choose a menu item: 0 - Main Menu 1 - Show all contacts 2 - Add a new contact 3 - Edit a contact 4 - Delete a contact 5 - Exit the program """ def main(): while True: main_menu() choice = user_choice() ...
true
7224a70f9bdce20caa1f60408236b0cba161cba6
mfaibish/rock-paper-scissors-exercise
/game.py
1,174
4.21875
4
#game .py import random print("-----------------------------") print("Rock, Paper, Scissors, Shoot!") print("-----------------------------") options = ["rock", "paper", "scissors"] response = "y" while response == "y": choice = input("Let's play a game! Select rock, paper or scissors: ") # user input if choi...
true
17cbbd2358f89ca95231dc1f1f1ac5f0e27049fe
serenelc/python-tutorials
/6-standard-input.py
258
4.1875
4
name = input("Tell me your name: ") age = input("What is your age: ") print(name, "you are", age) # Function to calculate the area of a circle radius = input("What is the radius of your circle: ") area = 3.142 * (int(radius) ** 2) print("The area is", area)
true
5649ed87f20e89b3119e2acee65eef0bfca58a84
selanifranchesca/Python-Practice-w.-Josh
/lesson6.py
328
4.1875
4
given_string = input("Give me a string: ") print(given_string) count = len(given_string) - 1 for element in given_string: if element == string: count += 1 if element == string: count += -1 print("This string is a palindrome.") else: print("This string is NOT a palind...
true
56dc75c1d5a35dfed4f35628882023d99db9bef0
antiface/lpthw
/ex3.py
713
4.46875
4
print "I will now count my chickens:" # Counting hens and roosters. print "Hens", 25.0 + 30.0 / 6.0 print "Roosters", 100.0 - 25.0 * 3.0 % 4.0 print "Now I will count the eggs:" # Counting eggs. print 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0 print "Is it true that 3 + 2 < 5 - 7?" # Boolean statement! Bo...
true
f4a6b921e027f8c615813ffed283a25645047b83
Gerdie/restaurant-ratings
/restaurant-ratings.py
1,719
4.1875
4
import sys from random import choice def add_restaurant(restaurant_ratings): """"Prompts user for additional restaurants""" new_restaurant = raw_input("Please add a restaurant: ").title() restaurant_ratings[new_restaurant] = \ int(raw_input("Review score for added restaurant:...
true
09ce16e9b3a7b5eda1312f3671f17ed53a46541e
takeahsiaor/budget
/budget/utilities.py
517
4.1875
4
import datetime def get_whole_month(date): ''' Given a single date, will return start and end date representing the first day of the current month and the first day of the next month. Meant to be used as a greater than or equal for start_date and a less than for end_date ''' #Very naive. ...
true
e3a7620e309845b9b06900750fd2dc160335d01a
Qunfong/CodeWars
/find_outlier.py
1,355
4.21875
4
# My solution # Checks if the pattern is odd or even. def find_pattern(integers): odd_or_even = False odd = [] even = [] for integer in integers: if integer % 2 == 0: even.append(integer) else: odd.append(integer) if len(even) >= 2: odd_or_even = T...
true
a20f3c5722463c502798e5ee23ab592af95ba5d0
sathayas/PythonClassFall2019
/stringExamples/InputCheck.py
532
4.25
4
while True: print('Please enter your 5-digit ZIP code') yourZIP = input() if yourZIP.isdecimal(): break print('A ZIP code can only have numbers') while True: print('Please enter a word') yourWord = input() if yourWord.isalpha(): break print('That is not a proper word. T...
true
1a55bc72c2fba23fdc9ea888842d4b413dfbcd57
sathayas/PythonClassFall2019
/ifExamples/IfExample2.py
585
4.34375
4
# Example of 'and' operator age = 23 hand = 'right' # evaluating the age and handedness requirements at once if (age>=18) and (hand=='right'): print('The age is ' + str(age) + ' years old.') print('The handedness is ' + hand + '-handed.') print('Meeting all the requirements.') # Example of 'or' operator...
true
9cd2ccfa8be18a149feeaa46727774e8478d5cf3
sathayas/PythonClassFall2019
/stringExamples/FavoriteFruits.py
449
4.1875
4
# case sensitive version (original) print('What is your favorite fruit?') userFruit = input() if userFruit == 'apple': print('I like ' + userFruit + ' too.') else: print('I eat ' + userFruit + ' occasionally') # converting the input to lower case print('What is your favorite fruit?') userFruit = input().lowe...
true
84048da74b550d51ff273b1d361a3a788680fa01
sathayas/PythonClassFall2019
/operatorExamples/F2C.py
216
4.15625
4
# input of temperature in Fahrenheit tempF = int(input('What is the temperature [F]? ')) # the formula for conversion tempC = (tempF - 32) * 5 / 9 # the output print('The temperature is ' + str(tempC) + ' Celsius.')
true
a70b97ab056822ea140236b02f6f296519ed367e
mmarder96/miscpython
/birthdays.py
2,222
4.28125
4
### Created by Max Marder import math import random instr =""" Now that we've talked about numerical simulations, you can write a program to analyze the probability that two people in a group of people share a common birthday (month + day). Q1. In a group of five people, what's the approximate probability that tw...
true
cfc3743ed4a1ea555ea6760f21605ddc99312acd
jetbrains-academy/introduction_to_python
/Condition expressions/If statement/if_statement.py
366
4.1875
4
name = "John" age = 17 if name == "John" or age == 17: # Check that name is "John" or age is 17. If so print next 2 lines. print("name is John") print("John is 17 years old") tasks = ["task1", "task2"] # Create new list if len(tasks) != 0: print("Not an empty list!") tasks.clear() # Empty the list...
true
79463a06e791907beddcecb0db526a7dd73e6115
jetbrains-academy/introduction_to_python
/Classes and objects/Definition/class_definition.py
418
4.25
4
class MyClass: variable = 42 def foo(self): # We'll explain self parameter later print("Hello from function foo") # `my_object` holds an object of the class "MyClass" that contains # the `variable` and the `foo` function my_object = MyClass() my_object.foo() # Calls the `foo` method defined in MyC...
true
930ec7f88e6768becb06000b3f580aa3ab85096c
jetbrains-academy/introduction_to_python
/Loops/While loop/while_loop.py
379
4.1875
4
square = 1 # Variable introduced to keep track of the iterations while square <= 10: print(square) # This code is executed 10 times square += 1 # This code is executed 10 times print("Finished") # This code is executed once square = 0 number = 1 # Print all squares from 1 to 81. while number < 10:...
true
c9c3c812a6db03da3805541a5d8357c06aa291d3
wsl222000/Python
/str_methods.py
295
4.125
4
#!/usr/bin/python name='hello' if name.startswith('he'): print 'yes,the string starts with "he"' if 'o' in name: print 'yes,it contaings the string "o"' if name.find('ll') != -1: print 'yes,it contains the string "ll"' delimiter='_*_' mylist=['a','b','c','d'] print delimiter.join(mylist)
true
d0bf5f505da2c6e01b0245cbaae2ffe452210859
wsl222000/Python
/func_doc.py
251
4.25
4
#!/usr/bin/python def printMax(x,y): ''' Prints the maximum of two numbers. The The two values must be integers.''' x=int(x) y=int(y) if x>y: print x, 'is maximum' else: print y, 'is maximum' printMax(3,5) print printMax.__doc__
true
8e0ef5000b9bfbf1d3719abc7157281da9b81f5e
Jackson1407/python
/Chapter03/hw 3-7.py
947
4.1875
4
# Chapter 3 Homework 3-7 names = [ "Hezz", "Eli", "Jay"] print(names) message = f" {names[0]}, you are invited to dinner today at 6:00." print(message) message = f" {names[1]}, you are invited to dinner today at 6:00." print(message) message = f" {names[2]}, you are invited to dinner today at 6:00." print(message)...
true
c30ec5ec03c92d712fa215584d834ad2789ca967
Jackson1407/python
/Chapter04/hw 4-2.py
321
4.25
4
# Chapter 4 Homework 4-2 animals = [ "Fox", "Wolf", "Dog"] for animal in animals: print(animal) print("\n") print(f"I would love to have a {animals[2]}.") print(f"It would be cool to see a {animals[1]}.") print(f"A {animals[0]} would be a cool pet.\n") print("It would be cool to have any of these animals as pets."...
true
51f52ac1c9a1ab9612f45f9071b498ce63202578
amitamola/Hackerrank-codes
/Map and Lambda Function.py
515
4.25
4
''' https://www.hackerrank.com/challenges/map-and-lambda-expression/problem ''' cube = lambda x:x**3 # complete the lambda function def fibonacci(n): # return a list of fibonacci numbers p = [0,1] if n==0: return [] elif n==1: return p[0:1] elif n==2: return...
true
d8aa6165e447d92c2219b9b48d380fe2b26712da
brogan-avery/MyPortfolio-AndExamples
/Python/Databases and Data Manipulation (Pandas, Plottly, etc.)/NumPy Examples/numPyPartTwo.py
1,468
4.15625
4
'''' Author: Brogan Avery Date: 2020/09/14 Project Title: numPy demo part 2 ''' from numpy import * #———————————————————————————————————————————————————————————————————————————————————— if __name__ == '__main__': myArr = array([[1,2,5],[8,0,-7], [7,3,9]]) print('Here is the array: \n', myArr) print('tran...
true
101231513cadb624fe771ecdea0dc5f611c689fa
Giorgos-Glvs/Number-Theory
/odd-even-numbers.py
419
4.3125
4
number = int(input("Give an integer number: \n")) while True: if number<0: number = int(input("The number should be greater than zero. Try again: \n")) else: break if number%2==0: print("The number {} is even!".format(number)) else: print("The number {} is odd!".format(number)) print...
true
e1ac53236209b722fc8c230fc4f1bf3946c05428
viewabhi/PythonL1
/Lambda expression, map and filter.py
1,456
4.6875
5
#lambda expressions are functions that are named one time and used once and not used again #map and filter are built into python print('Learning about map function now') def square_num(num): return num**2 my_nums = [1,2,3,4,5] for item in map(square_num,my_nums): print(item) my_nums = [1,2,3,4,5,6,7,8,9] ...
true
7667074656a47a763aec5528da2ec38f07031e1a
Ardvb/pands-problem-set
/Pythonproblem10Plot.py
1,335
4.15625
4
# Ard van Balkom, 13-3-19 # Problem 10. This program will display a plot of the functions x, x*x and 2**x, in the range[0,4] import matplotlib.pyplot as plt # Import matplotlib so we can plot functions. import numpy x = numpy.linspace(0,4,5) # Set the min(0) and max(4) values for the x axis, and the number(5) of e...
true
d2cfe1afc86f1ede210ec81b65f5009621e226f3
Ghayyas/python
/4.Prompts-Input/index.py
316
4.5
4
#Lets prompt any number and print it. x = input('Enter any number: '); print "The value of x is " + str(x); # What about if we want to print string the above code will only print numbers if you try to print string it will gives you error. x = raw_input('Please Enter your name : '); print "Your Name is : " + x;
true
6f13de97f40aa87e06d68314ca240343d7bec84d
UjalaJha/Python
/Q8fact.py
485
4.1875
4
def factorial(num): if num < 0: print("Sorry, factorial does not exist for negative 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("factorial is : ") print(fact) def recur_factoria...
true
976e104169473a7df012dcb02136b755a8881028
miguelfajardoc/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
482
4.28125
4
#!/usr/bin/python3 """Number of lines in a file""" def read_lines(filename="", nb_lines=0): """function that count the lines of a file and print it""" lines = 0 with open(filename, encoding='utf-8') as a_file: if nb_lines <= 0: print(a_file.read(), end="") else: for...
true
33327ee00272b8fe4f260959563eff8ce22208c4
justinfarq/COP2500C
/daySeven.py
1,145
4.1875
4
#Justin Farquhharson #09/16/2021 #COP 2500C subCost = float(input("How much does the sub cost?\n")) while(subCost < 3 or subCost > 15): print("The sub cost needs to be between 3 and 15 dollars") subCost = float(input("How much are you going to pay?\n")) money = float(input("How much are you going t...
true
482a789c027a5854fd57e96b5af6878e8f6eabfb
justinfarq/COP2500C
/midTerm9.py
374
4.125
4
grade = int(input("What grade did you receive on the assignment\n")) late = int(input("How many hours late did you turn in the assignment\n")) if(late >= 1 and late <= 12): grade = grade*0.90 print(grade) elif(late >= 13 and late <= 48): grade = grade*0.80 print(grade) elif(late == 0): pr...
true
ece0dc716d7dd03d29ecbcfc5bbcfedc32b81284
micro1985/pythonlrn
/homework/home2/homework2_3.py
362
4.15625
4
def check_polindrome(string=""): #Converting string to list ls = [] for i in range(len(string)): ls.append(string[i]) #Cheking for polindrome for j in range(len(ls)//2): if ls[j] != ls[-1-j]: return "It`s not polindrome" return "It`s polindrome" a = input("Enter sequence:...
true
fc12ed5e2fe8e68654a1e9ec51ce9f49da282262
pfsmyth/Cambridge
/code/lists.py
694
4.625
5
# Lists #create an empty list myList = [] #create list with values myList2 = [ 5,8,9] # Items in the list don't all have to be the same type myList3 = ['Hello', 42, 3.142 ] # individual elements in the list can be referenced print myList3[0] # to iterate over all of the elements in a list for x in m...
true
9b3fab0f4061aceffcefdee126e9a9ed3ba93ce5
Ester-Ramos/Exercises
/move_zeroes.py
827
4.3125
4
def move_zeroes(nums): """given an array move all the zeroes to the end while maintaining the relative order of the non-zero elements Example: nums = [0,1,0,3,12] output = [1,3,12,0,0] """ #I create a counter of zeroes and then add it at the end of a new list zeros = 0 new_nums = [] ...
true
bb274cfa95a84a4111ee9a2a53d1cebb7fb47535
jennystarr/GWCProjects
/hangman.py
1,376
4.21875
4
import random # A list of words that potential_words = ["music", "nap", "girl", "code"] word = random.choice(potential_words) lengthofword = (len(word))# Use to test your code: #print(word) # Converts the word to lowercase # Make it a list of letters for someone to guess current_word = [] # TIP: the number of let...
true
ba9899a5cb0fd8e04f995756505199e1b5dc74dc
jennystarr/GWCProjects
/pooh.py
2,580
4.1875
4
# Update this text to match your story. start = ''' One day Christopher Robina and Pooh were bored. They had to make a decision to go to the park or a tea party. ''' print(start) print("Type 'park' to go to the park or 'tea party' to go a tea party.") # Update to match your story. user_input = input() if user_input ...
true
3ec468159f445add152c90c1a3321777db4d0b7a
David-Sangojinmi/Algorithms
/peakFinder.py
1,088
4.40625
4
# Author: David Sangojinmi # #==========================================================================# # This algorithm can be used to find a peak in a given set of numbers # # which are inputted. A number is a peak if it is greater than or equal # # to the num...
true
71b724a86cda7e15fdb70b05103abd2f3b15a348
conor-baird/PRACTICALS
/ASCII_TAB.py
713
4.15625
4
LOWER_LIMIT = 33 UPPER_LIMIT = 127 def main(): character_test = str(input("Enter a character: ")) char_ASCII = ord(character_test) print("The ASCII code for {} is : {}".format(character_test, char_ASCII)) number = get_number(LOWER_LIMIT,UPPER_LIMIT) num_ASCII = chr(number) print("The Characte...
true
96ac48b4b04cfd70a36d210a12d96432e70af1c4
ViSci/6.00.1x-Files
/L2Problem11.py
640
4.21875
4
""" L2 Problem 11 Assume that two variables, varA and varB, are assigned values, either numbers or strings. Write a piece of Python code that prints out one of the following messages: "string involved" if either varA or varB are strings "bigger" if varA is larger than varB "equal" if varA is equal to ...
true
fc0fcea20827ce3cfbb9fea28286ea50cfebcc34
JoseR98/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
756
4.375
4
#!/usr/bin/python3 """This module contain a function called read_lines""" def read_lines(filename="", nb_lines=0): """read_lines function that read nb_lines of a file Args: filename (str, optional): file name. Defaults to "". nb_lines (int, optional): lines to read from the file. Defaults to ...
true
6821b5788dc3b79b05e2fc8fe77839113da3af8f
JoseR98/holbertonschool-higher_level_programming
/0x06-python-classes/2-square.py
786
4.40625
4
#!/usr/bin/python3 """This module contains a class that defines a square. In the Square class we initialize each object by the __init__ method with a private instance variable called __size that takes the size variable's value passed as argument. Also we check if the size arg has a valid value. """ class Square: ...
true
d468df55f7f564f698660e69753471acecdad356
ZJmitch/Creating-and-Using-Python-Functions
/Problem 3 - MultipleList.py
383
4.21875
4
#Justin Mitchell #2/23/2021 #Problem 3 multiple all the numbers in a list import math def multiplyList(myList): result = 1 for x in (myList): result = result * x return result list1 = [5, 2, 7, -1] val = multiplyList(list1) print(val) #Program reads created multip...
true
274fdf8e6d79620158d64c8fa3fa731795397261
sanjay-3129/Python-Tutorial
/28.Write_File.py
1,268
4.28125
4
#When a file is opened in write mode, the file's existing content is deleted. file = open("newfile.txt",'w') #if there is no file then a new file will be created. Check your current directory where you saved ur python file. msg = input(); print() abd = file.write(msg) print(abd) #printing of...
true
f92e60c85605c4572bde97eb1788dcbb31d1220a
PlamenVasilev/python_cource
/Homeworks/2. Functions and debugging/04. Draw a Filled Square.py
514
4.125
4
def print_side(length): print('-', end='') for c in range(1,length-1): print("-", end='') print('-') def print_row(length): print('-', end='') for col in range(1, length-1): if col % 2: print('\\', end='') else: print('/', end='') print('-') def...
true
37377b2897fb65f7676e5f678d6fe95710eb5518
Olu-wafemi/First-repository-at-Dsc
/common.py
629
4.375
4
def common_elements(my_dict): #Declares a function that accepts a dictionary as an argument g = [] #An empty list that stores a common element that appears as a key and value for i in my_dict: #Implementation of the program that checks if an element appears as a key and a value then prints the element/elements ...
true