blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f9b7c11118c0e2ccf65dab75f01d0cdb1001532a
nrglll/katasFromCodeWars
/string_example_pigLatin.py
1,052
4.375
4
# -*- coding: utf-8 -*- """ Created on Sat May 9 15:44:33 2020 @author: Nurgul Aygun """ # ============================================================================= # Kata explanation: # Move the first letter of each word to the end of it, then add "ay" to # the end of the word. Leave punctuation marks untouched...
true
2fdb8c0b1434cf8ce72e7c6f6840166c8d72ffd5
azka97/practice1
/beginner/PrintInput.py
642
4.125
4
#input() will by default as String #basic math same as other language, which is +,-,/,* #exponent in python notated by '**' #There's '//' which is used for devided number but until how many times it will be reach the first number. Was called ' Integer Division' #Modulus operator notated by '%'. This is the remain n...
true
b2a2f7598364273be0ca0a62e3339fe7cf4f2695
LalitGsk/Programming-Exercises
/Leetcode/July-Challenge/prisonAfterNDays.py
1,700
4.125
4
''' There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to the following rules: If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied. Otherwise, it becomes vacant. We de...
true
5409e790168cb5f59ad3e1f4ef8dc63914cf2245
MadhanBathina/python
/odd even count of in between intigers of two numbers.py
519
4.21875
4
Start=int(input('Starting intiger :')) End=int(input('Ending intiger :')) if Start < 0 : print('1 ) The numbers lessthan 0 is not supposed to be count as either odd or even.') print('2 ) {0} to -1 are not considered as per the above statement.'.format(Start)) Start = 0 oddcount = 0 evencount= 0 for i ...
true
84b5d6b336751efd0e7f9a6bde1a8ad50e5631f2
RohiniRG/Daily-Coding
/Day39(Bit_diff).py
896
4.28125
4
# You are given two numbers A and B. # The task is to count the number of bits needed to be flipped to convert A to B. # Examples : # Input : a = 10, b = 20 # Output : 4 # Binary representation of a is 00001010 # Binary representation of b is 00010100 # We need to flip highlighted four bits in a # to make it b. # I...
true
f35713a8ec7b2fbf0a0c957c023e74aa58cd55db
randyarbolaez/codesignal
/daily-challenges/swapCase.py
232
4.25
4
# Change the capitalization of all letters in a given string. def swapCase(text): originalLen = len(text) for i in text: if i.isupper(): text += i.lower() else: text += i.upper() return text[originalLen:]
true
89f316d8298d5ccbdbac841a9a6f3eea5d67d8e4
randyarbolaez/codesignal
/daily-challenges/CountDigits.py
259
4.1875
4
# Count the number of digits which appear in a string. def CountDigits(string): totalNumberOfDigits = 0 for letterOrNumber in string: if letterOrNumber.isnumeric(): totalNumberOfDigits += 1 else: continue return totalNumberOfDigits
true
d008f4f9d0f64f72bbda7be1909e5ae71f2cf1fc
Fittiboy/recursive_hanoi_solver
/recursive_hanoi.py
707
4.25
4
step = 0 def move(fr, to): global step step += 1 print(f"Step {step}:\tMove from {fr} to {to}") def hanoi(fr, to, via, n): if n == 0: pass else: hanoi(fr, via, to, n-1) move(fr, to) hanoi(via, to, fr, n-1) n = input("\n\nHow many layers does your tower of Hanoi hav...
true
7aa978fad9e053f9d0541bb07585ba90027fcd6e
Digit4/django-course
/PYTHON_LEVEL_ONE/Part10_Simple_Game.py
2,536
4.21875
4
########################### ## PART 10: Simple Game ### ### --- CODEBREAKER --- ### ## --Nope--Close--Match-- ## ########################### # It's time to actually make a simple command line game so put together everything # you've learned so far about Python. The game goes like this: # 1. The computer will think o...
true
d05dd4b1903d781d594e0b125266c3a58706382b
jon-moreno/learn-python
/ex3.py
769
4.34375
4
print "I will now count my chickens:" print "Hens", 25 + 30 / 6 print "Roosters", 100 - 25 * 3 % 4 print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 print "Is it true that 3 + 2 < 5 - 7?" print 3 + 2 < 5 - 7 print "What is 3 + 2?", 3 + 2 print "What is 5 - 7?", 5 - 7 print "Oh that's why...
true
631922ad9ea661de547af2af1a1500fb5ec4c065
maahokgit/Python-Assignments
/Assigments/Assignment4/AManNamedJed/aManNamedJedi.py
2,037
4.28125
4
""" Student Name: Edward Ma Student ID: W0057568 Date: November 16, 2016 A Man Named Jedi Create a program that will read in a file and add line numbers to the beginning of each line. Along with the line numbers, the program will also pick a random line in the file and convert it to all capital letters. All ot...
true
55701fa458fc998a4d3fe5e38afec0808d36e88f
matthewlee1/Codewars
/create_phone_number.py
484
4.125
4
# Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number. #Example: # create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # => returns "(123) 456-7890" def create_phone_number(n): f = "".join(map(str, n[:3])) s = "".join(ma...
true
9116283a58b98e8debeea1bb279fc1988d9e0f1a
Ahameed01/tdd_challenge
/weather.py
1,015
4.125
4
# Assume the attached file port-harcourt-weather.txt contains weather data for # Port Harcourt in 2016. Download this file and write a program that returns the # day number (column one) with the smallest temperature spread (the maximum # temperature is the second column, the minimum the third column). filename = "p...
true
225160859f926e7f08af188dbceb46c9c81a35b1
carrba/python-stuff
/pwsh2python/functions/ex1.py
369
4.125
4
#!/usr/bin/python3.6 def divide (numerator, denominator): myint = numerator // denominator myfraction = numerator % denominator if myfraction == 0: print("Answer is", myint) else: print("Answer is", myint, "remainder", myfraction) num = int(input("Enter the numerator ")) den = int(i...
true
ca02219c4ec546314f18f7f2779f815833e13951
arohigupta/algorithms-interviews
/hs_interview_question.py
1,794
4.21875
4
# def say_hello(): # print 'Hello, World' # for i in xrange(5): # say_hello() # # Your previous Plain Text content is preserved below: # # This is just a simple shared plaintext pad, with no execution capabilities. # # When you know what language you'd like to use for your interview, # simply choose it from ...
true
b687c97076dba795663606e9dc2c30408cf47d31
arohigupta/algorithms-interviews
/fizz_buzz_again.py
673
4.1875
4
#!/usr/bin/env python """fizz buzz program""" def fizz_buzz(fizz_num, buzz_num): """function to print out all numbers from 1 to 100 and replacing the numbers completely divisible by the fizz number by 'Fizz', the numbers completely divisible the buzz number by 'Buzz' and the numbers completely divisible b...
true
441329bf024a6db66f938d86543d361dba98d2b6
Moondance-NL/Moondance-NL
/ex1.py
792
4.5
4
print("I will now count my chickens:") # we are calulating the number of hens and roosters print("Hens", 25.0 + 30.0 /6.0) print("Roosters", 100 - 25 * 3 % 4) print("Now I will count the eggs:") # we are calculating the number of eggs print(3.0 + 2.0 + 1-5 + 4 % 2-1 / 4.0 + 6.0) # we are attemting to find the ...
true
4733713d4de3ca0f91ff841167162ff8f963c445
chuymedina96/coding_dojo
/chicago_codes_bootcamp/chicago_codes_python/python_stack/python/fundamentals/practice_strings.py
2,028
4.78125
5
print ("Hello world") #Concatentaing strings and variables with the print function. # multiple ways to print a string containing data from variables. name = "zen" print("My name is,", name) name = "zen" print("My name is " + name) #F-strings (Literal String Interpolation) first_name = "zen" last_name = "Coder" a...
true
aa9eb750a1e0c98949015dd27e7d2c5ff2805a75
MrFichter/RaspSort1
/main.py
947
4.375
4
#! /usr/bin/python #sort a file full of film names #define a function that will return the year a film was made #split the right side of the line a the first "(" def filmYear(film): return film.rsplit ('(',1)[1] #load the file into a list in Python memory #and then close the file because the content is now in mem...
true
df80aedb4695956eb49f9be9b4954eaa246f951e
PeaWarrior/learn-py
/ex_07/ex_07_02.py
914
4.28125
4
# Exercise 2: Write a program to prompt for a file name, and then read through the file and look for lines of the form: # X-DSPAM-Confidence: 0.8475 # When you encounter a line that starts with “X-DSPAM-Confidence:” pull apart the line to extract the floating-point number on the line. Count these lines and then comput...
true
469b980fe77547f9eb561ce3f32765d59fe955b7
PeaWarrior/learn-py
/ex_12/ex_12_04.py
716
4.125
4
# Exercise 4: Change the urllinks.py program to extract and count paragraph (p) tags from the retrieved HTML document and display the count of the paragraphs as the output of your program. Do not display the paragraph text, only count them. Test your program on several small web pages as well as some larger web pages. ...
true
066da0f2759113dc0b1289705f92311fe6abb01e
JamieJ12/Team-23
/Functions/Function_6.py
2,655
4.15625
4
def word_splitter(df): """ The function splits the sentences in a dataframe's column into a list of the separate words.: Arguments: The variable 'df' is the pandas input. Returns: df with the added column named 'Splits Tweets' Example: Prerequites: >>> twitter_url = 'https://raw.gi...
true
4617883396bfe24d19ab40f77451291f088721ec
yuanxu-li/careercup
/chapter6-math-and-logic-puzzles/6.8.py
1,714
4.28125
4
# 6.8 The Egg Drop Problem: There is a building of 100 floors. If an egg drops # from the Nth floor or above, it will break. If it's dropped from any floor # below, it will not break. You're given two eggs. Find N, while minimizing the # number of drops for the worst case. # Here I denote floors from 0 to 99 import r...
true
89b2cab05c4ecf1a2a10c60fa306ef7f8ea79bed
yuanxu-li/careercup
/chapter16-moderate/16.24.py
845
4.15625
4
# 16.24 Pairs with Sum: Design an algorithm to find all pairs of integers within # an array which sum to a specified value. from collections import Counter def pairs_with_sum(arr, k): """ put all elements into a Counter (similar to a dict), for each value, search for the complementary value >>> pairs_with_sum([1, ...
true
3bf4269c79a0b223fad38ae3a178a5e7c5212fe2
yuanxu-li/careercup
/chapter10-sorting-and-searching/10.2.py
966
4.46875
4
# 10.2 Group Anagrams: Write a method to sort an array of strings so that all the anagrams are # next to each other. from collections import defaultdict def group_anagrams(strings): """ create a dict to map from a sorted string to a list of the original strings, then simply all strings mapped by the same key will ...
true
7837501cf9c4e8589734f09883875d0fff5c2062
yuanxu-li/careercup
/chapter8-recursion-and-dynamic-programming/8.4.py
1,436
4.25
4
# 8.4 Power Set: Write a method to return all subsets of a set. def power_set(s, memo=None): """ For a set, each we add it to the final list, and run the algorithm against its one-item-less subset >>> power_set(set([1,2,3,4,5])) [{1, 2, 3, 4, 5}, {2, 3, 4, 5}, {3, 4, 5}, {4, 5}, {5}, set(), {4}, {3, 5}, {3}, {3, 4}...
true
858dd659ac6bb2648fca973c6695abcdccddd951
yuanxu-li/careercup
/chapter5-bit-manipulation/5.8.py
1,585
4.28125
4
# 5.8 Draw Line: A monochrome screen is stored as a single array of bytes, allowing eight consecutive pixels # to be stored in one byte. The screen has width w, where w is divisible by 8 (that is, no byte will be split # across rows). The height of the screen, of course, can be derived from the length of the array and ...
true
81a90ce343ff4d49098ada9f12429821aed4e57b
yuanxu-li/careercup
/chapter16-moderate/16.16.py
1,330
4.125
4
# 16.16 Sub Sort: Given an array of integers, write a method to find inices m and n such # that if you sorted elements m through n, the entire array would be sorted. Minimize n - m # (that is, find the smallest such sequence). # EXAMPLE # Input: 1, 2, 4, 7, 10, 11, 7, 12, 6, 7, 16, 18, 19 # Output: (3, 9) import pdb ...
true
b49ddf7666de93c2f767510cc8354e4e556009cb
yuanxu-li/careercup
/chapter8-recursion-and-dynamic-programming/8.10.py
1,215
4.1875
4
# 8.10 Paint Fill: Implement the "paint fill" function that one might see on many image editing programs. # That is, given a screen (represented by a two-dimensional array of colors), a point, and a new color, # fill in the surrounding area until the color changes from the original color. def paint_fill(array, row, co...
true
d62dee378aee2ad5621da0821e3d26bb801e741b
yuanxu-li/careercup
/chapter4-trees-and-graphs/4.3.py
1,264
4.125
4
# 4.3 List of Depths: Given a binary tree, design an algorithm which creates a linked list of all the # nodes at each depth (e.g., if you have a tree with depth D, you'll have D linked lists) from collections import deque class Node: def __init__(self): self.left = None self.right = None def list_of_depths(sel...
true
905d3e94a6e6ab1bcd68bd26b6839baf5b178bd4
yuanxu-li/careercup
/chapter1-arrays-and-strings/1.7.py
1,623
4.34375
4
# 1.7 Rotate Matrix: Given an image represented by an N*N 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? def rotate_matrix(matrix): """ Take a matrix (list of lists), and rotate the matrix clockwise >>> rotate_matrix([[1,2,3],[4,5,6],[7...
true
0db6f0e7aaf5666e4b839fc40d977672988b32cd
yuanxu-li/careercup
/chapter10-sorting-and-searching/10.4.py
1,487
4.15625
4
# 10.4 Sorted Search, No size: You are given an array-like data structure Listy which lacks a size method. It does, however, # have an elementAt(i) method that returns the element at index i in O(1) time. If i is beyond the bounds of the data structure, # it returns -1. (For this reason, the data structure only support...
true
7c0e1d9a77cfb59763f5067ce087deb67eeb2181
w4jbm/Python-Programs
/primetest.py
1,018
4.125
4
#!/usr/bin/python3 # Based on code originally by Will Ness: # https://stackoverflow.com/questions/2211990/how-to-implement-an-efficient-infinite-generator-of-prime-numbers-in-python/10733621#10733621 # # and updated by Tim Peters. # # https://stackoverflow.com/questions/2211990/how-to-implement-an-efficient-infinite-...
true
d2dcd6ce2a0e54b4c95acca0dafb9d3aa95c8920
lxw0109/JavaPractice
/Sort/Bubble/pBubble.py
1,235
4.21875
4
#!/usr/bin/python2.7 #File: pBubble.py #Author: lxw #Time: 2014-09-19 #Usage: Bubble sort in Python. import sys def bubbleSort(array): bound = len(array) - 1 while 1: i = 0 tempBound = 0 swap = False while i < bound: if array[i] > array[i+1]: array[i...
true
b06883d59473eb92521e61b581674978f79755f5
TylorAtwood/Hi-Lo-Game
/Hi_Lo_Game.py
1,455
4.34375
4
#!/usr/bin/env python3 #Tylor Atwood #Hi-Lo Game #4/14/20 #This is a def to inlcude the guessing game. def game(): #Immport random library import random #Declare varibles. Such as max number, generated random number, and user's number guess max = int(input("What should the maximum numbe...
true
14703a10efdf73974802db15a4d644aa7b9854ea
Garima2997/All_Exercise_Projects
/PrintPattern/pattern.py
327
4.125
4
n = int(input("Enter the number of rows:")) boolean = input("Enter True or False:") if bool: for i in range(0, n): for j in range(i + 1): print("*", end=" ") print("") else: for i in range(n, 0, -1): for j in range(i): print("*", end=" ") prin...
true
2587f2a265238875e932ffcbaaa1b028abbf7929
Jakksan/Intro-to-Programming-Labs
/Lab8 - neighborhood/pythonDrawingANeighborhood/testingShapes.py
1,890
4.15625
4
from turtle import * import math import time def drawTriangle(x, y, tri_base, tri_height, color): # Calculate all the measurements and angles needed to draw the triangle side_length = math.sqrt((0.5*tri_base)**2 + tri_height**2) base_angle = math.degrees(math.atan(tri_height/(tri_base/2))) top_angle =...
true
8d6fb45b0bc9753d718e558815a6e70178db88fd
Vasilic-Maxim/LeetCode-Problems
/problems/494. Target Sum/3 - DFS + Memoization.py
1,041
4.1875
4
class Solution: """ Unlike first approach memoization can make the program significantly faster then. The idea is to store results of computing the path sum for each level in some data structure and if there is another path with the same sum for specific level than we already knew the number of path...
true
5fa3c31eda3e66eeb0fb0de5b7d11f90b03eea6e
notsoseamless/python_training
/algorithmic_thinking/Coding_activities/alg_further_plotting_solution.py
1,138
4.15625
4
""" Soluton for "Plotting a distribution" for Further activities Desktop solution using matplotlib """ import random import matplotlib.pyplot as plt def plot_dice_rolls(nrolls): """ Plot the distribution of the sum of two dice when they are rolled nrolls times. Arguments: nrolls -...
true
c2a0a60091658bb900d0fcf3c629c3f284288fa5
dennisjameslyons/magic_numbers
/15.py
882
4.125
4
import random #assigns a random number between 1 and 10 to the variable "magic_number" magic_number = random.randint(1, 10) def smaller_or_larger(): while True: try: x = (int(input("enter a number please: "))) # y = int(x) except ValueError: print("Ever so sorr...
true
779abded16b15cb8eb80fe3dc0ed36309b9cec59
MFahey0706/LocalMisc
/N_ary.py
1,399
4.1875
4
# --------------- # User Instructions # # Write a function, n_ary(f), that takes a binary function (a function # that takes 2 inputs) as input and returns an n_ary function. def n_ary_A(f): """Given binary function f(x, y), return an n_ary function such that f(x, y, z) = f(x, f(y,z)), etc. Also allow f(x) = x...
true
4738082f42766a81e204ce364000a790a959fdf1
JeffreyAsuncion/PythonCodingProjects
/10_mini_projects/p02_GuessTheNumberGame.py
917
4.5
4
""" The main goal of the project is to create a program that randomly select a number in a range then the user has to guess the number. user has three chances to guess the number if he guess correct then a message print saying “you guess right “otherwise a negative message prints. Topics: random module, for loo...
true
ff88f375bd9e0ff5d34a60155fac35faaf3c8329
sec2890/Python
/Python Fundamentals/bike.py
840
4.15625
4
class Bike: def __init__(self, price, max_speed): self.price = price self.max_speed = max_speed self.miles = 0 def displayInfo(self): print("This bike has a price of",self.price,", a maximum speed of",self.max_speed, "and a total of", self.miles, "miles on it.") ...
true
14989dacdda1f7c8cf589f5bdf556c9cbcd6db0e
fhylinjr/Scratch_Python
/learning dictionaries 1.py
1,196
4.1875
4
def display(): list={"ID":"23","Name":"Philip"} print(list)#prints the whole list for n in list: print(n)#prints the keys print(list.keys())#alternative print(list["Name"])#prints a specific value print(list.get("Name"))#alternative '''list["Name"]="Joe"#change a value in a l...
true
4bbadc10900a6ea43dc032411c7d65dca29666e4
aevri/mel
/mel/lib/math.py
2,583
4.375
4
"""Math-related things.""" import math import numpy RADS_TO_DEGS = 180 / math.pi def lerp(origin, target, factor_0_to_1): towards = target - origin return origin + (towards * factor_0_to_1) def distance_sq_2d(a, b): """Return the squared distance between two points in two dimensions. Usage examp...
true
b25a60e2013b9451ba7eb8db5ead8f56e5a59fcd
Pdshende/-Python-for-Everybody-Specialization-master
/-Python-for-Everybody-Specialization-master/Coursera---Using-Python-to-Access-Web-Data-master/Week-6/Extracting Data from JSON.py
1,695
4.1875
4
''' In this assignment you will write a Python program somewhat similar to http://www.pythonlearn.com/code/json2.py. The program will prompt for a URL, read the JSON data from that URL using urllib and then parse and extract the comment counts from the JSON data, compute the sum of the numbers in the file and enter the...
true
17094896a237ce2d5f4cc2e0a3b770058f187bcb
fatihtkale/Term-Todo
/script.py
1,174
4.15625
4
import sqlite3 conn = sqlite3.connect('db.db') query = conn.cursor() def run_program(): def get_info(): query = conn.cursor() query.execute("SELECT * FROM Information") rows = query.fetchall() for row in rows: print(row) run_program() def save_info(valu...
true
8ff6e4d16550bff45f3c2e75d17f18cd1640adb1
mvg2/astr-119-hw-2
/variables_and_loops.py
771
4.15625
4
import numpy as np # imports the numpy module def main(): i = 0 # assign integer value 0 to variable i n = 10 # assign integer value 10 to variable n x = 119.0 # assign float value 119.0 to variable x # we can use numpy to declare arrays...
true
157c530a6a6f8d7bc729cbf6c1b945b3bdd83507
Moosedemeanor/learn-python-3-the-hard-way
/ex03.py
1,195
4.625
5
# + plus # - minus # / slash # * asterisk # % percent # < less-than # > greater-than # <= less-than-equal # >= greater-than-equal # print string text question print("I will now count my chickens:") # print Hens string then perform calculation print("Hens", 25 + 30 / 6) # print Roosters string then perform calculation p...
true
75888241e7d1af247414e9cdb72a2a2e9ebf70f3
theodorp/CodeEval_Easy
/ageDistribution.py
1,798
4.40625
4
# AGE DISTRIBUTION # CHALLENGE DESCRIPTION: # You're responsible for providing a demographic report for your local school district based on age. To do this, you're going determine which 'category' each person fits into based on their age. # The person's age will determine which category they should be in: # If they'r...
true
bb889189b4f6ed0e6e0119fa5f2612904fa95921
theodorp/CodeEval_Easy
/swapCase.py
645
4.25
4
# SWAP CASE # CHALLENGE DESCRIPTION: # Write a program which swaps letters' case in a sentence. All non-letter characters should remain the same. # INPUT SAMPLE: # Your program should accept as its first argument a path to a filename. Input example is the following # Hello world! # JavaScript language 1.8 # A lett...
true
e32d4c0ff6b060534d93f0d05d181de0bb6785d4
theodorp/CodeEval_Easy
/happyNumbers.py
1,204
4.25
4
# HAPPY NUMBERS # CHALLENGE DESCRIPTION: # A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include ...
true
fe8869fcc3952b4c795d5f4723d578c234e93b8d
theodorp/CodeEval_Easy
/majorElement.py
1,138
4.15625
4
# THE MAJOR ELEMENT # CHALLENGE DESCRIPTION: # The major element in a sequence with the length of L is the element which appears in a sequence more than L/2 times. The challenge is to find that element in a sequence. # INPUT SAMPLE: # Your program should accept as its first argument a path to a filename. Each line of...
true
2c991f2a5e7da455ff2fcecc75ec4d7368e2af72
theodorp/CodeEval_Easy
/lowerCase.py
588
4.3125
4
# LOWERCASE # CHALLENGE DESCRIPTION: # Given a string write a program to convert it into lowercase. # INPUT SAMPLE: # The first argument will be a path to a filename containing sentences, one per line. You can assume all characters are from the english language. E.g. # HELLO CODEEVAL # This is some text # OUTPUT S...
true
bc608d508ceb1236e5f6d020d216af56e751434c
theodorp/CodeEval_Easy
/mixedContent.py
1,038
4.15625
4
# MIXED CONTENT # CHALLENGE DESCRIPTION: # You have a string of words and digits divided by comma. Write a program # which separates words with digits. You shouldn't change the order elements. # INPUT SAMPLE: # Your program should accept as its first argument a path to a filename. Input # example is the following # 8...
true
05b9dbed2d6c37958599957c9a05b177f3b08b73
jbhennes/CSCI-220-Programming-1
/Chapter 7 Decisions/LetterGrade.py
507
4.15625
4
## LetterGrade.py def main(): print ("Given a numerical grade, returns the letter grade.") # Get the numerical grade grade = input("Enter your numerical grade: ") if grade >= 90: print ("Letter grade = A") elif grade < 90 and grade >= 80: print ("Letter grade = B") elif g...
true
28e47d7fd4572ff14512a9e86541cfeb8ee0e848
jbhennes/CSCI-220-Programming-1
/rectArea.py
1,039
4.25
4
#This function calculates the area of a rectangle. def rectArea(): #Purpose of the program. print("This program calculates the area of a rectangle.") units = input("First, tell me the units that will be used: ") #Define variables length = eval(input("Please input the length of the rectangle: ")) ...
true
4c114ee054f6bca751ac665fb7fce7a63dcf6f1c
jbhennes/CSCI-220-Programming-1
/Chapter 11 - lists/partialListFunctions.py
1,967
4.375
4
# listFunctions.py # Author: Pharr # Program to implement the list operations count and reverse. from math import sqrt def getElements(): list = [] # start with an empty list # sentinel loop to get elements item = raw_input("Enter an element (<Enter> to quit) >> ") while item != "": l...
true
913c3d0fafc5017bc72172796e8b2c793d190c61
jbhennes/CSCI-220-Programming-1
/Chapter 7 Decisions/MaxOfThree3.py
729
4.46875
4
## MaxOfThree3.py ## Finds largest of three user-specified numbers def main(): x1 = eval(input("Enter a number: ")) x2 = eval(input("Enter a number: ")) if x1 > x2: temp = x1 x1 = x2 x2 = temp print ("here") print ("The numbers in sorted order are: ") ...
true
e97f890f65d8e44456af6118610c52f96d0e82ab
jbhennes/CSCI-220-Programming-1
/Chapter 7 Decisions/MaxOfThree1.py
508
4.53125
5
## MaxOfThree1.py ## Finds largest of three user-specified numbers def main(): x1 = input("Enter a number: ") x2 = input("Enter a number: ") x3 = input("Enter a number: ") # Determine which number is the largest if x1 >= x2 and x1 >= x3: # x1 is largest max = x1 elif x2 >=...
true
2f6867f9b3569cfddafea7b46bf11ad254713d75
jbhennes/CSCI-220-Programming-1
/Chapter 8 While/GoodInput5.py
493
4.28125
4
## GoodInput5.py # This program asks the user to enter exactly 12 or 57. # This version is WRONG!!!!!! def main(): number = input("Enter the number 12 or 57: ") # This version tries to move the negation in, but incorrectly, # thus creating an infinite loop: while number != 12 or number...
true
1ef289b88e2cf959f9e0f533df0ccfa180605154
Matt-McConway/Python-Crash-Course-Working
/Chapter 7 - User Input and While Loops/ex7-2_pp121_restaurantSeating.py
216
4.15625
4
""" """ toBeSeated = input("How many people are dining tonight? ") if int(toBeSeated) > 8: print("I'm sorry, you are going to have to wait for a table.") else: print("Right this way, your table is ready.")
true
45142c33c0203fe1bc2386bb7b53e0fb919f5b27
Gutencode/python-programs
/conditionals/gradePercent.py
829
4.3125
4
## Program to compute the grade from given percentage. def grade(percent): """ This function takes the percentage as input and returns the relevant grade. """ if (percent > 100): print("Please enter the correct obtained percentage") elif (percent >= 90): return("A") elif (perc...
true
c6acf0c506bae2c792f8e9f647036776c335b506
innovation-platform/Mad-Lib-generator
/mad.py
1,203
4.125
4
import tkinter from tkinter import * main=Tk() main.geometry("500x500") main.title("Mad Libs Generator") Label(main,text="Mad Libs Generator",font="arial",bg="black",fg="white").pack() Label(main,text="Click one:",font="italic",bg="white",fg="black").place(x=40,y=80) def madlib1(): name=input("Enter a name ...
true
a907255a5ecbd9c126c08cad5693e319344d6027
Alekssin1/first_lab_OOP
/first_task.py
649
4.15625
4
import sys # cut first element(name of the file) expression = "".join(sys.argv[1:]) # We use join to make our expression a string with # spaces and then using the function eval # check whether the user input is empty if expression: try: print(eval(expression)) except ZeroDivisionError: print(...
true
be9109066f9f34b4fa21aa46312871fb244c35ec
griadooss/HowTos
/Tkinter/05_buttons.py
2,223
4.34375
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode Tkinter tutorial In this script, we use pack manager to position two buttons in the bottom right corner of the window. author: Jan Bodnar last modified: December 2010 website: www.zetcode.com """ #We will have two frames. #There is the base frame and an additio...
true
f82da39fce4bb6efbffd817b4651cb1027e15410
griadooss/HowTos
/Tkinter/01_basic_window.py
2,700
4.34375
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode Tkinter tutorial This script shows a simple window on the screen. author: Jan Bodnar last modified: January 2011 website: www.zetcode.com """ #While this code is very small, the application window can do quite a lot. #It can be resized, maximized, minimized. #A...
true
2a535a9f8cf2b45ffc9469195319a9a0df2df168
griadooss/HowTos
/Tkinter/14_popup_menu.py
1,706
4.40625
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode Tkinter tutorial In this program, we create a popup menu. author: Jan Bodnar last modified: December 2010 website: www.zetcode.com """ '''Popup menu''' # In the next example, we create a popup menu. # Popup menu is also called a context menu. # It can be sho...
true
cf108c19ac33a9286c8daba5bff0c3f9b7098711
djcolantonio/PythonProjects
/homework_function_scor.py
407
4.15625
4
# This program evaluates the score and LOOPS while True: score = input('What is your score: ') try: if int(score) >= 90: print('This is an excellent score') elif int(score) >=80: print('This is a good score') else: print('You need a better s...
true
534456b717efe50a9709c45edeedf8579a945769
CGayatri/Python-Practice1
/control_3.py
298
4.3125
4
## program 3 - to display a group of messages when the condition is true - to display suite str = 'Yes' if str == 'Yes': print("Yes") print("This is what you said") print("Your response is good") ''' F:\PY>py control_3.py Yes This is what you said Your response is good '''
true
a3df363bd6c12796722d7c243b009bd04a213538
CGayatri/Python-Practice1
/control_13.py
252
4.28125
4
## program 13 - to display each character from a string using sequence index str = 'Hello' n = len(str) # find no. of chars in str print("Lenght :", n) for i in range(n): print(str[i]) ''' F:\PY>py control_13.py Lenght : 5 H e l l o '''
true
75dc369c4b309a387583cc7dc8d05d91c29cf318
CGayatri/Python-Practice1
/Module1/CaseStudy_1/demo5.py
501
4.34375
4
# 5.Please write a program which accepts a string from console and print the characters that have even indexes. # Example: If the following string is given as input to the program: # H1e2l3l4o5w6o7r8l9d # Then, the output of the program should be: # Helloworld str = input("Enter input s...
true
286c01b126996d05ee34b93bca9b3616a3199d69
CGayatri/Python-Practice1
/string_13_noOfWords.py
668
4.125
4
## Program 13 - to find the number of words in a string # as many number of spaces; +1 wuld be no of words # to find no. of words in a string str = input('Enter a string : ') i=0 count=0 flag = True # this becomes False when no space is found for s in str: # Count only when there is no space pre...
true
456bc270c408a04758347728e9bd02c1b3a96e52
CGayatri/Python-Practice1
/string_9_chars.py
1,010
4.4375
4
## Working with Characters -- get a string --> get chars using indexing or slicing ## program 9 - to know the type of character entered by the user str = input('Enter a character : ') ch = str[0] # take only 0th character niito ch # test ch if (ch.isalnum()): print("It is an alphabet or numeric charac...
true
ea4b5b1bdd6bb54b8c439ee2ecfa37a0d0149748
CGayatri/Python-Practice1
/control_11.py
707
4.15625
4
## program 11 - to display even numbers between m and n (minimum and maximum range) m , n = [int(i) for i in input("Enter comma separated minimum and maximum range: ").split(',')] # 1 to 10 ===> x = m # start from m onwards #x = 1 # start from ths number # make start as even so that adding 2 to it would give nex...
true
9d029614f80818e96a163348028788b3b4639937
CGayatri/Python-Practice1
/string_8.py
416
4.28125
4
## Splitting and Joining Strings ## Program 8 - to accept and display a group of numbers # string.split(seperator) # separator.join(string) str = input('Enter numbers separated by space : ') # cut the string where a space is found lst = str.split(' ') # display the numbers from teh list for i in lst : print...
true
bdde2a9d113f48aac14994980bad4e84caedd315
CGayatri/Python-Practice1
/prime.py
558
4.15625
4
# program to display prime numbers between range #Take the input from the user: lower = int(input("Enter lower range: ")) upper = int(input("Enter upper range: ")) for num in range(lower,upper + 1): if num > 1: for i in range(2,num): if (num % i) == 0: break ...
true
457950d15654565ce70aa6b6c664eeb431ea25a2
CGayatri/Python-Practice1
/function_12_functionReturnsAnotherFun.py
452
4.25
4
## Program 12 - to know how a function can return another function # functions can return other functions def display(): def message(): return 'How are you?' return message # call display() function and it returns message() function # in following code, 'fun' refers to the name ...
true
8e9e41a1adabea2eef1da2b4f66e6f1794105b1a
CGayatri/Python-Practice1
/input22_argparse.py
660
4.59375
5
## program - 22 : to find the power value of a number when it is rised to a particular power import argparse # call the ArgumentParser() parser = argparse.ArgumentParser() # add the arguments to teh parser parser.add_argument('nums', nargs=2) # retrieve arguments from parser args = parser.parse_args() #find the...
true
69d2b90af1c5dfa0145321e0d808576599d31ec7
raiyanshadow/BasicPart1-py
/ex21.py
272
4.40625
4
# Write a Python program to find whether a given number (accept from the user) is even or odd, print out an appropriate message to the user. n = int(input("ENTER NUMBER: ")) if n % 2 == 0: print("That is an even number.") else: print("That is an odd number.")
true
89d58cabd879fb0e9a0f3b01bf665c754f367653
SharonOBoyle/python-lp3thw
/ex7.py
1,028
4.25
4
# print the sentence to the screen print("Mary had a little lamb.") # print the sentence to the screen, substituting 'snow' inside the {} print("Its fleece was white as {}.".format('snow')) # print the sentence to the screen print("And everywhere that Mary went.") # this printed 10 . characters in succession on the sam...
true
e127418b2765a0cb6c76915003aafd5535aea7c1
SharonOBoyle/python-lp3thw
/ex30.py
1,007
4.25
4
# create a variable named people with value 40 people = 40 cars = 4 trucks = 15 # if the boolean expression is true, execute the code in the block, otherwise skip it if cars > people or trucks > people: print(">>> if cars > people or trucks > people:", cars, people, trucks) print("We should go somewhere") # e...
true
270bd98e879bcc4a2af763a7b6a399b812bce881
SharonOBoyle/python-lp3thw
/ex15.py
1,229
4.59375
5
# import the argv module (argument variable/vector) from the sys package # argv holds the arguments specified when running this script # from the command line from sys import argv # unpack argv and assign it to the variables on the left, in that order script, filename = argv # open the file with the open() function wh...
true
d0be707b6b95674e7a55339a7774568045b2a525
stacykutyepov/python-cp-cheatsheet
/educative/slidingWindow/non_repeat_substring.py
537
4.21875
4
""" time: 13 min errors: none! """ def non_repeat_substring(str): maxLen, i = 0, 0 ht = {} for i, c in enumerate(str): if c in ht: maxLen = max(maxLen, len(ht)) ht.clear() ht[c] = True maxLen = max(len(ht), maxLen) return maxLen def main(): print("Length of the longest substring...
true
4b598ac15547bccf6febd027fc489c6d28657761
rashi174/GeeksForGeeks
/reverse_array.py
666
4.15625
4
""" Given a string S as input. You have to reverse the given string. Input: First line of input contains a single integer T which denotes the number of test cases. T test cases follows, first line of each test case contains a string S. Output: Corresponding to each test case, print the string S in reverse order....
true
c28f332fc9cbc62aa584fb9cca14452e89904da7
jieunjeon/daily-coding
/Leetcode/716-Max_Stack.py
2,235
4.125
4
""" https://leetcode.com/problems/max-stack/ 716. Max Stack Design a max stack that supports push, pop, top, peekMax and popMax. push(x) -- Push element x onto stack. pop() -- Remove the element on top of the stack and return it. top() -- Get the element on the top. peekMax() -- Retrieve the maximum element in the s...
true
6a5f82b4645e349246761c8b39829823fa7407a4
Christopher14/Selection
/revision exercise 2.py
240
4.15625
4
#Christopher Pullen #30-09-2014 #Revision exercise 2 age = int(input("please enter your age:")) if age >= 17: print ("you are legally able to drive a car with learner plates") else: print ("you are not legally able to drive a car")
true
7ed3bf159a9e29e856944f8fca2ad7c81bbb58cc
infx598g-s16/04-18-python3
/interest.py
1,118
4.40625
4
# Prompt the user for an Initial Balance (and save to a variable) # use the float() function to convert the input into a number. balance = float(input("Initial balance: ")) # Prompt the user for an Annual Interest % (and save to a variable) # use the float() function to convert the input into a number interest = float...
true
a9bed29fb65836ee58d9de662e6ea4d1612ffdea
Mokarram-Mujtaba/Mini-Projects
/faulty calculator.py
688
4.15625
4
#Faulty calculator #Design a calculator which gives wrong input whebn user enters the following calculation # 45 * 3 = 555, 56+9 = 77, 56/6 = 4 x1=input("Enter the opertions you want.+,-,/,%,* \n") x2=int(input("Enter the 1st number")) x3=int(input("Enter the 2nd number")) if x2==45 and x3==3 and x1=='*': print(...
true
b5778f7a056996cd63f63aa462d925ecfb0edd86
khan-c/learning_python
/py3tutorial.py
397
4.34375
4
print("hello world") # this is a tuple as opposed to a list # syntax would be either written like this or with parantheses programming_languages = "Python", "Java", "C++", "C#" # an array would use brackets like this: languages_list = ["Python", "Java", "C++", "C#"] # for - in loop for language in programming_langua...
true
5b5c378c445b9de900f3a5a1a82970f784a4d2ca
spencercorwin/automate-the-boring-stuff-answers
/Chapter12MultiplicationTable.py
952
4.15625
4
#! usr/bin/env python3 #Chapter 12 Challenge - Multiplication Table Marker #Takes the second argument of input, an integer, and makes a multiplication #table of that size in Excel. import os, sys, openpyxl from openpyxl.styles import Font wb = openpyxl.Workbook() sheet = wb.active #tableSize = sys.argv[1] tableSize...
true
43e0551fe36887ca2b140c7ab04352332c3b499f
DhruvGala/LearningPython_sample_codes
/TowerOfHanoi.py
1,014
4.1875
4
''' Created on Oct 10, 2015 @author: DhruvGala The following code is a general implementation of Tower of hanoi problem using python 3. ''' from pip._vendor.distlib.compat import raw_input ''' The following method carries out the recursive method calls to solve the tower of hanoi problem. ''' def towerOfHanoi(numbe...
true
f916bcbca35a5b84111b9894f85bcc637628d1ff
arimont123/python-challenge
/PyBank/main.py
2,137
4.125
4
import os import csv #python file in same folder as budget_data.csv csvpath = "budget_data.csv" with open(csvpath) as csvfile: csvreader = csv.reader(csvfile, delimiter = ",") #start reading in data after first row of text csvheader = next(csvreader) #create empty lists to store data from each column ...
true
29c45bbdc3bf5ff5b822dbffc16ce7e1a91e7037
kml1972/python-tutorials
/code/tutorial_27.py
1,125
4.1875
4
shopping_list = [ 'milk','eggs','bacon','beef', 'soup','bread','mustard','toothpaste' ] # looping by index vs using an iterator i = 0 while i < len(shopping_list): curr_item = shopping_list[i] print( curr_item ) i += 1 for curr_item in shopping_list: print( curr_item ) #shopping_list.__i...
true
3c99da6c123b0f76b02f11746f584acd92c00c48
LKHUUU/SZU_Learning_Resource
/计算机与软件学院/Python程序设计/实验/实验1/problem1.py
228
4.3125
4
import math radius = float(input("Enter the radius of a cylinder:")) length = float(input("Enter the length of a cylinder:")) area = radius*radius*math.pi print("The area is", area) print("The volume is", area*length)
true
502edac5b8c26c2ef81609d497f8084db91f0401
zhaphod/ProjectEuler
/Python/proj_euler_problem_0001.py
651
4.15625
4
''' Problem 1 Multiples of 3 and 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ''' sum = 0 def EulerProblem0001(): global sum for i in range(1, 1000): if i % 5 == 0 or i ...
true
c65e8e6d41ac120b28cf31d9f9dcf4f74d78c45e
leonguevara/DaysInAMonth_Python
/main.py
930
4.625
5
# main.py # DaysInAMonth_Python # # This program will give you the number of days of any given month of any given year # # Python interpreter: 3.6 # # Author: León Felipe Guevara Chávez # email: leon.guevara@itesm.mx # date: May 31, 2017 # # We ask for and read the month's number month = int(input("...
true
75972d8413cedaba4efe98bc5c28bbfed5c093ca
jungjung917/Coderbyte_challenges
/easy/solutions/ThirdGreatest.py
1,142
4.5
4
""" Using the Python language, have the function ThirdGreatest(strArr) take the array of strings stored in strArr and return the third largest word within in. So for example: if strArr is ["hello", "world", "before", "all"] your output should be world because "before" is 6 letters long, and "hello" and "world" are both...
true
bd5801f9768c16fdf16d9992dd47f5506cbdedcc
jungjung917/Coderbyte_challenges
/medium/solutions/StringScramble.py
572
4.375
4
""" the function StringScramble(str1,str2) take both parameters being passed and return the string true if a portion of str1 characters can be rearranged to match str2, otherwise return the string false. For example: if str1 is "rkqodlw" and str2 is "world" the output should return true. Punctuation and symbols will no...
true
26e0e5220c163bfc0631b25aabfb7395f986c941
Endlex-net/practic_on_lintcode
/reverse-linked-list/code.py
600
4.21875
4
#-*-coding: utf-8 -*- """ Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param head: The first node of the linked list. @return: You should return the head of the reversed linked list. ...
true