blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a6b7095bdf942c083324dc7d49dc2835d651bdb9
RileyMathews/nss-python-exercises-classes
/employees.py
1,597
4.1875
4
class Company(object): """This represents a company in which people work""" def __init__(self, company_name, date_founded): self.company_name = company_name self.date_founded = date_founded self.employees = set() def get_company_name(self): """Returns the name of the compan...
true
eec5d6c8cb0b850addb2f043eb56b93787cb123f
peterjoking/Nuevo
/Ejercicios_de_internet/Ejercicio_22_Readfile.py
897
4.53125
5
""" Opening a file for reading is the same as opening for writing, just using a different flag: with open('file_to_read.txt', 'r') as open_file: all_text = open_file.read() Note how the 'r' flag stands for “read”. The code sample from above reads the entire open_file all at once into the all_text variable. Bu...
true
f3b36b0d425a27a84edce61bd93de52c69ec90fe
ceejtayco/python_starter
/longest_strings.py
455
4.125
4
#Given an array of strings, return another array containing all of its longest strings. def longest_string(inputList): newList = list() longest = len(inputList[0]) for x in range(len(inputList)-1): if longest < len(inputList[x+1]): longest = len(inputList[x+1]) for x in inputLi...
true
eab7db0160e4e7dfc0da0690f114d51b49cbd69a
Haris-HH/CP3-Haris-Heamanunt
/Exercise_5_2_Haris_Heamanunt.py
262
4.28125
4
distance = int(input("Distance (km) : ")) time = int(input("Time (h) : ")) if(distance < 1): print("Distance can not be less than 1 km") elif(time < 1): print("Time can not be less than 1 hour") else: result = distance / time print(result,"km/h")
true
383cd867c393b32c6655c8c5bfbbd8baba60ad6a
LeilaRzazade/python_projects
/guess_number.py
802
4.1875
4
#This is random number generator program. #You should guess the random generated number. import random random_num = random.randint(1,100) user_input = int(input("Guess the number: ")) if (user_input == random_num): print("Congratulations! Guessed number is: ", user_input) while(user_input != random_num): ...
true
4f8686f815a0f47d40b96cd5d9f6491d490a6159
jlast35/hello
/python/data_structures/queue.py
1,905
4.34375
4
#! /usr/bin/env python # Implementation of a Queue data structure # Adds a few non-essential convenience functions # Specifically, this is a node intended for a queue class Node: def __init__(self, value): self.value = value self.nextNode = None class Queue: def __init__(self): self.head = None self.tail =...
true
2bb03b26a4554f78c897815138c6bf675ddfe96e
YuliiaAntonova/leetcode
/reverse integer.py
786
4.125
4
# Given a signed 32-bit integer x, return x with its digits reversed. # If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. class Solution(object): def reverse(self,n): y = str(abs(n)) # Create a variable and convert the integer into a string ...
true
cc54a0283f674a4091d9d3a26f3b70459245119e
JaffarA/ptut
/python-4.py
1,626
4.4375
4
# introduction to python # 4 - io, loops & functions cont.. # functions can take multiple arguments, default arguments and even optional arguments (part of *args) def introduce(name='slim shady', age, hobby='fishing'): return print(f'Hi, my name is {name}. Hi, my age is {age}. Hi, i like this "{hobby}"') # this code...
true
f9f86abfd5bab24edac6d6149fefd15b451f438e
anvarknian/preps
/Heaps/min_heap.py
2,621
4.1875
4
import sys # defining a class min_heap for the heap data structure class min_heap: def __init__(self, sizelimit): self.sizelimit = sizelimit self.cur_size = 0 self.Heap = [0] * (self.sizelimit + 1) self.Heap[0] = sys.maxsize * -1 self.root = 1 # helper function to swa...
true
643bb8a4c5100d1f22dbd60132317b66f6fb3b06
Vinaypatil-Ev/aniket
/1.BASIC PROGRAMS/4.fahrenheit_to_degree.py
286
4.40625
4
# WAP to convert Fahrenheit temp in degree Celsius def f_to_d(f): return (f - 32) * 5 / 9 f = float(input("Enter Fahrenheit temprature: ")) x = f_to_d(f) print(f"{f} fahreheit is {round(x, 3)} degree celcius") # round used above is to round the decimal values upto 3 digits
true
3211aaae0cdbca9324479483fb2206519ccf8ca2
TonyPwny/cs440Ass1
/board.py
1,614
4.1875
4
# Thomas Fiorilla # Module to generate a Board object import random #import random for random generation def valid(i, j, size): roll = random.randint(1, max({(size - 1) - i, 0 + i, (size - 1) - j, 0 + j})) return roll # function to generate the board and place the start/end points # returns the built board and...
true
30b85504154a9a22042c416955ca643818f45e63
psarangi550/PratikAllPythonRepo
/Python_OOS_Concept/Monkey_Pathching_In_Python.py
2,149
4.4375
4
#changing the Attribute of a class dynamically at the runtime is called Monkey Patching #its a common nature for dynamically typed Language #lets suppose below example class Test:#class Test def __init__(self):#constructor pass#nothing to initialize def fetch_Data(self):#instance method #remeber...
true
1bbc38978d15042164c2a458952ea34ba30853db
yuliia11882/CBC.Python-Fundamentals-Assignment-1
/Yuliia-py-assignment1.py
1,380
4.21875
4
#Canadian Business College. # Python Fundamentals Assignment 1 #PART 1:------------------------------- #enter how many courses did he/she finish # the input value (which is string) is converted into number with int() num_of_courses = int(input("How many courses have you finished? ")) print(num...
true
6e3568a6057b0d88393120ad65238b14834d53ba
samiCode-irl/programiz-python-examples
/Native_Datatypes/count_vowels.py
273
4.125
4
# Python Program to Count the Number of Each Vowel vowels = 'aeiou' ip_str = 'Hello, have you tried our tutorial section yet?' sent = ip_str.casefold() count = {}.fromkeys('vowels', 0) for letter in sent: if letter in count: count[letter] += 1 print(count)
true
f19151fce2c14be35efad14a418a87e724286aa0
bryanlie/Python
/HackerRank/lists.py
1,198
4.46875
4
''' Consider a list (list = []). You can perform the following commands: insert i e: Insert integer at position . print: Print the list. remove e: Delete the first occurrence of integer . append e: Insert integer at the end of the list. sort: Sort the list. pop: Pop the last element from the list. reverse: Reverse t...
true
c270f4865da343415ea72349627c690b2bd5ad54
dipikakhullar/Data-Structures-Algorithms
/coding_fundamentals.py
772
4.125
4
def simpleGeneratorFun(): yield 1 yield 2 yield 3 # Driver code to check above generator function for value in simpleGeneratorFun(): print(value) import queue # From class queue, Queue is # created as an object Now L # is Queue of a maximum # capacity of 20 L = queue.Queue(maxsize=20) ...
true
28a982b392e5a1c3e5ecc287f78d63b506349c2a
Aparna768213/Best-Enlist-task-day3
/day7task.py
794
4.34375
4
def math(num1,num2): print("Addition of two numbers",num1+num2) print("Subtraction of two numbers",num1-num2) print("Multiplication of two numbers",num1*num2) print("Division of two numbers",num1/num2) num1 = float(input("Enter 1st number:")) num2 = float(input("Enter 2nd num:")) math(num1,num2) ...
true
c28bc62bc1b7a68b6a73b36cceada5cf8f07cd0c
rishikumar69/all
/average.py
239
4.21875
4
num = int(input("Enter How Many Number you want:")) total_sum = 0 for i in range(num): input = (input("Enter The Number:")) total_sum += input ans = total_sum/num line = f"Total Average of {total_sum}is{ans}" print(line)
true
d6ab91f6579ec619a681ab8f0d6f31240773a194
Gaurav716Code/Python-Programs
/if else if/ph value..py
288
4.125
4
def phvalue(): num = float(input("Enter number : ")) if num > 7 : print(num," is acidic in nature.") elif num<7: print(num," is basic in nature.") else: print(num,"is neutral in nature.") print("~~~~ End of Program ~~~~~~") phvalue()
true
d22f4ce6a9cff8d04db8fca268a56a52bb2092e3
ridwan098/Python-Projects
/multiplication table.py
220
4.21875
4
# This program displays the multiplication table loop = 1 == 1 while loop == True: n= input('\nenter an integer:') for i in range(1, 13): print ("%s x %s = %s" %(n, i, i*int(n)))
true
e4d00925b6e7d22f3f36a97fe670119419ffc614
ridwan098/Python-Projects
/fibonacci sequence(trial 1).py
361
4.15625
4
# This program prints out the fibonacci sequence(up to 100) loop = 1 == 1 while loop == True: number = 1 last = 0 before_last = 0 num = int(input("\nHow many times should it list? ")) for counter in range(0, num): before_last = last last = number number = be...
true
26f0f0fdbbe45e57831f01a07ccdcf501e11515c
kelleyparker/Python
/grades.py
512
4.3125
4
print("This program calculates the averages of five students' grades.\n\n") # Define a list of tuples containing the student names and grades students = [] for i in range(5): name = input(f"Insert student {i+1}'s name: ") grade = float(input(f"Insert {name}'s grade: ")) students.append((name, grade)) # Ca...
true
19387fd2d7095b98e0492d1e93bd8f98001d8cf1
MaiShantanuHu/Coursera-Python-3-Programming
/Python-Basics/Week-2/Lists and Strings.py
1,622
4.21875
4
'''Q-1: What will the output be for the following code?''' let = "z" let_two = "p" c = let_two + let m = c*5 print(m) #Answer: # pzpzpzpzpz '''Q-2: Write a program that extracts the last three items in the list sports and assigns it to the variable last. Make sure to write your code so that it work...
true
88aa8d4f5e4c0db6bc03e01b37b1b81e5419b3fa
dtulett15/5_digit_seperator
/3digit_seperator.py
300
4.28125
4
#seperate three digits in a three digit number entered by user #get number from user num = int(input('Enter a 3 digit number: ')) #set hundreds digit num1 = num // 100 #set tens digit num2 = num % 100 // 10 #set ones digit num3 = num % 10 #seperate digits print(num1, ' ', num2, ' ', num3)
true
9c2987a4dc6565034ae0ee703a4af1175d409d22
shahzeb-jadoon/Euclids-Algorithm
/greatest_common_divisor.py
691
4.375
4
def greatest_common_divisor(larger_num, smaller_num): """This function uses Euclid's algorithm to calculate the Greatest Common Divisor of two non-negative integers pre: larger_num & smaller_num are both non-negative integers, and larger_num > smaller_num post: returns the greatest com...
true
873a3801db68683d1551df016016074821335284
Meghna-U/posList.py
/posList.py
215
4.125
4
list=[] s=int(input("Enter number of elements in list:")) print("Enter elements of list:") for x in range(0,s): element=int(input()) list.append(element) for a in list: if a>0: print(a)
true
7e97f790d96abf42d0220cb1fe537834a50d0796
shikhaghosh/python-assigenment1
/assignment2/question10.py
284
4.15625
4
print("enter the length of three side of the triangle:") a,b,c=int(input()),int(input()),int(input()) if a==b and a==b and a==c: print("triangle is equilateral") elif a==b or b==c or a==c: printf("triangle is a isoscale") else: printf("triangle is a scalene")
true
143f78b793a0772073bcc3239ce361d2735339d4
IbroCalculus/Python-Codes-Snippets-for-Reference
/Set.py
1,592
4.21875
4
#Does not allow duplicate, and unordered, but mutable. #It is faster than a list #Python supports the standard mathematical set operations of # intersection, union, set difference, and symmetric difference. #DECLARING EMPTY SET x= set() #NOTE: x = {} is not an empty set, rather an empty dictionary s ...
true
b27175e1a40f491c0ef12308615e1fc946b694e6
IbroCalculus/Python-Codes-Snippets-for-Reference
/Regex2.py
902
4.4375
4
import re #REGULAR EXPRESSIONS QUICK GUIDE ''' ^ - Matches the beginning of a line $ - Matches the end of a line . - Matches any character \s - Matches whitespace \S - Matches any non-whitespace character * - Repeats a character zero or more times *? - Repeats a character zero or more times (non-greedy) + ...
true
fd9adb7ebb5603760577526aa16ab7d83555be5d
ParulProgrammingHub/assignment-1-mistryvatsal
/Program8.py
241
4.15625
4
# WPP TO TAKE INPUT BASE AND HEIGHT OF THE TRIANGLE AND PRINT THE AREA OF THE TRIANGLE base = int(input('ENTER THE BASE OF THE TRIANGLE :')) height = int(input('ENTER THE HEIGHT OF THE TRIANGLE :')) print('AREA IS : ', 0.5 * height * base)
true
c26f6b50cf1d5469dbd3cc97838e12ec9893e8ba
johnlev/coderdojo-curriculum
/Week2/activity.py
633
4.34375
4
# We are going to be making a guessing game, where the user guesses your favorite number # Here we define a variable guess which holds the user's response to the question # The input function asks the user the question and gives back the string the user types in. # The int(...) syntax converts the string into an i...
true
f83050b30754d73714f4382103ec3499635b7eb2
GiantPanda0090/Cisco_Toolbox
/regex/remove_dup_words.py
695
4.46875
4
################################################### # Duplicate words # The students will have to find the duplicate words in the given text, # and return the string without duplicates. # ################################################### import re def demo(): print(remove_duplicates("the bus bus will never be...
true
7b23940e3907b14467adeec77e52d3713ae5ad87
jtylerroth/euler-python-solutions
/1-100/14.py
1,219
4.125
4
# The following iterative sequence is defined for the set of positive integers: # # n → n/2 (n is even) # n → 3n + 1 (n is odd) # # Using the rule above and starting with 13, we generate the following sequence: # # 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1 # It can be seen that this sequence (starting at 13 and fin...
true
086a9d173ed3e63778658acb1b08f31c5adacf90
leo-sandler/ICS4U_Unit_4_Algorithms_Leo_Sandler
/Lesson_4.1/4.1_Recursion_and_Searching.py
1,826
4.21875
4
import math # Pseudo code for summing all numbers from one to 100. # Initialize count variable, at 1 # for 101 loops # Add loop number to the count, with reiterating increase # Real code count = 0 for x in range(101): count += x # print(count) # Recursion is calling the same function within itself. # Recursi...
true
83971e63972f9a21edf9f355529cab109502a54d
sanketha1990/python-basics
/pythonHelloWorld/com/python/learner/ComparisionOperatorInPython.py
410
4.46875
4
temperature=30 if temperature > 30: # == , !=, print('its hot day !') else: print('it is not hot day !') print('=============================================') name=input('Please enter your name .. ') name_len=len(name) if name_len <= 3: print('Name should be gretter thant 3 charecter !') elif name_len >=5...
true
bc0237b5b7ad679068c608b10a522c79423ca44a
alexisfaison/Lab1
/Programming Assignment 1.py
1,021
4.1875
4
# Name: Alexis Faison # Course: CS151, Prof. Mehri # Date: 10/5/21 # Programming Assignment: 1 # Program Inputs: The length, width, and height of a room in feet. # Program Outputs: The area and the amount of paint and primer needed to cover the room. import math #initialize variables width_wall = 0.0 length_wall = 0....
true
0f662c6750f4e56b67eb4c73f495dc70b96c1bf7
pallavibhagat/Problems
/problem2.py
376
4.4375
4
""" 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. Write a program to find the sum of all the multiples of 3 or 5 below 1000. """ def multiple(): sum = 0 for i in range(1,1000): if i%3==0 or i%5==0: sum +=i ...
true
2133af4c52bba08fd49755539e15512f1ee865e5
DipakTech/Python-basic
/app.py
2,827
4.15625
4
# print('hello world') # python variables # one=1 # two=2 # some_number=1000 # print(one,two,some_number) # booleans # true_boolean=True # false_boolean=False # # string # my_name='diapk' # # float # book_price=12.3 # print(true_boolean,false_boolean,my_name,book_price) # if True: # prin...
true
104fac3bec6c7975673715d7a3d2594d6d8e9d63
AlphaCoderX/MyPythonRepo
/Assignment 1/RecipeConverter.py
1,157
4.125
4
#Programmer Raphael Heinen #Date 1/19/17 #Version 1.0 print "-- Original Recipe --" print "Enter the amount of flour (cups): ", flour = raw_input() print "Enter the amount of water (cups): ", water = raw_input() print "Enter the amount of salt (teaspoons): ", salt = raw_input() print "Enter the amount of yeast (teaspoo...
true
463fab4b59fd21609889666840b14b98e01a80bf
helloallentsai/leetcode-python
/1295. Find Numbers with Even Number of Digits.py
958
4.21875
4
# Given an array nums of integers, return how many of them contain an even number of digits. # Example 1: # Input: nums = [12,345,2,6,7896] # Output: 2 # Explanation: # 12 contains 2 digits (even number of digits). # 345 contains 3 digits (odd number of digits). # 2 contains 1 digit (odd number of digits). # 6 conta...
true
6c0da654abdc01986b10d70f380f02b0f7800d29
seekindark/helloworld
/python/py-study/testlist.py
1,968
4.375
4
# # define a function to print the items of the list # def showlist(team): i = 0 for item in team: # end= "" will not generate '\n' automatically print("list[%d]=%s" % (i, item), end=" ") i += 1 print("\n-------------------") team = ['alice', 'bob', 'tom'] print...
true
8fb063a77d24fc0a4e30759ca867b24d4c448a56
sabbirDIU-222/Learb-Python-with-Sabbu
/loopExercize.py
1,483
4.46875
4
# for loop exersize in the systamatic way # so we first work with the list party = ['drinks','chicken','apple','snow','ice','bodka','rma','chess board'] for p in party[:4]: print(p) print(len(p)) print(sorted(p)) for n in "banana": print(n) # break statement to break the loop in ...
true
7d20e78c33f560812eac4f0f420b3035bdc6b322
sabbirDIU-222/Learb-Python-with-Sabbu
/Unpacking Arguments.py
928
4.21875
4
# so what is unpacking ugument # i am surprised to know about the horriable things # and that is , what i learn about the arbetery argument \ # or can i call it paking and unpaking # so what i learn aboout variable argument \ ''' def _thisFunction(*args): sum = 0 for n in range(0,len(args)): ...
true
e76737fb088ea69b73e34bf61037610d30e869d1
ccccclw/molecool
/molecool/measure.py
1,252
4.15625
4
""" This module is for functions """ import numpy as np def calculate_distance(rA, rB): """ Calculate the distance between two points. Parameters ---------- rA, rB : np.ndarray The coordinates of each point. Return ------ distance : float The distance between the t...
true
6433e495fd2d47ee50910d166821502eab388856
mdk7554/Python-Exercises
/MaxKenworthy_A2P4.py
2,537
4.25
4
''' Exercise: Create program that emulates a game of dice that incorporates betting and multiple turns. Include a functional account balance that is updated with appropriate winnings/losses. ''' import random #function to generate a value from dice roll def roll(): return int(random.randrange(1,7)) #function to ...
true
11a0db557909161e59c03ab75726f02e4275be5a
gammaseeker/Learning-Python
/old_repo/6.0001 Joey/sanity_check2.py
848
4.15625
4
annual_salary = 120000 portion_saved = .1 total_cost = 1000000 monthly_salary = (annual_salary / 12.0) portion_down_payment = 0.25 * total_cost current_savings = 0 returns = (current_savings * 0.4) / 12 overall_savings = returns + (portion_saved * monthly_salary) months = 0 # Want to exit the loop wh...
true
c5f3dcab578ef708da59fc2be131ef86cf6660e1
gammaseeker/Learning-Python
/old_repo/6.0001 Joey/sanity_check.py
623
4.15625
4
annual_salary = 120000 portion_saved = .1 total_cost = 1000000.0 monthly_salary = (annual_salary / 12.0) portion_down_payment = 0.25 * total_cost current_savings = 0 returns = (current_savings * 0.04) / 12 overall_savings = returns + (portion_saved * monthly_salary) months = 0 # Want to exit the lo...
true
e0a5c95ec996fd314a829b8f41043a0f3aaa9d4c
JanDimarucut/cp1404practicals
/prac_06/car_simulator.py
1,397
4.125
4
from prac_06.car import Car MENU = "Menu:\nd) drive\nr) refuel\nq) quit" def main(): print("Let's drive!") name = input("Enter your car name: ") my_car = Car(name, 100) print(my_car) print(MENU) menu_choice = input(">>>").lower() while menu_choice != "q": if menu_choice == "d": ...
true
210105f313227d23381e8ce2e0511df1ffec2637
JanDimarucut/cp1404practicals
/prac_04/list_exercises.py
2,647
4.40625
4
# 1 numbers = [] for i in range(5): number = int(input("Number: ")) numbers.append(number) # print("The first number is: ", numbers[0]) # print("The last number is: ", numbers[-1]) # print("The smallest number is: ", min(numbers)) # print("The largest number is: ", max(numbers)) # print("The average of the nu...
true
a00f702483bab4e505f2c2cb7b7bc790d01beeeb
Zach-Wibbenmeyer/cs108
/lab05/spirograph.py
2,909
4.125
4
'''Using Python to draw a spirograph March 5, 2015 Lab05 Exercise 2 Zach Wibbenmeyer (zdw3)''' #Gains access to the turtle module import turtle #Gains access to the math module import math #Prompts the user to enter a choice if they would like to draw or not choice = str(input('Would you like to draw a spirograph? (...
true
703a6f099c981601b87743d254d6b6661626fa6f
mronowska/python_code_me
/zadania_domowe/zadDom3.py
945
4.28125
4
men_name = input("Male name: ") feature_positive = input("Positive feature of this man: ") feature_negative = input("Negative feature of this man: ") day_of_the_week = input("Day of the week: ") place = input("Place: ") animal = input("Animal: ") print( f"There was a man called {men_name}. In one hand he was {feat...
true
8df97a9d1609a30896b0a3342a44b11cc7fcce90
Mannuel25/py-projects
/all-python-codes/e-mail-scrapper/email.py
502
4.25
4
# file input for users fname = input('Enter file name: ') # if the enter key is pressed 'emailfile.txt' is the file automatically if (len(fname) < 1): fname = 'emailfile.txt' #file handle fh = open(fname) # a loop that prints out the email for line in fh: # parsing through if not line.startswith('From ...
true
f1e0b7caafb0e93735eeb2b8fda8ba152076607d
Mannuel25/py-projects
/all-python-codes/password-generator/password-generator-2/generate_password.py
1,523
4.34375
4
import secrets, string def password_generator(): """ A program that generates a secure random password : return: None """ try: # get the length of alphabets to be present in password length_of_alphabets = int(input('\nEnter the length of alphabets (upper and lower case inclusive): '...
true
8abed6121ee7847b3d076fa7c555db089ec3f483
wajdm/ICS3UR-5-05-Python
/addressing_mails.py
1,866
4.46875
4
# !/usr/bin/env python3 # Created by: Wajd Mariam # Created on: December 2019 # This program formats the mailing address using given input. def format_address(first_name, last_name, street_add, city, province, postal_code, apt_number=None): # returns formatted mailing address if apt_numbe...
true
ac566079a1f0b1c8b05a921253df65872f4d2201
tryingtokeepup/Sorting
/src/iterative_sorting/iterative_sorting.py
1,387
4.34375
4
# TO-DO: Complete the selection_sort() function below def swapping_helper(index_a, index_b, arr): # cool_dude = array temp = arr[index_a] arr[index_a] = arr[index_b] arr[index_b] = temp return arr def selection_sort(arr): # loop through n-1 elements for i in range(0, len(arr) - 1): ...
true
9a718e4a71ef9f2a19f9decc472d6fba57a5cb51
czwartaoslpoj/book-review-project
/templates/house_hunting.py
736
4.1875
4
//calculating how many months I need to save the money fo portion_down_payment total_cost = int(input("The cost of your dream house: ")) portion_down_payment = total_cost/4 current_savings = 0 annual_salary= int(input("Your annual salary: ")) portion_saved = float(input("Portion of your salary to save as a decim...
true
e1a42bb8d1b00666fe1a9d2022d116fc879630eb
markellisdev/bangazon-orientationExercises1-6
/bangazon.py
2,605
4.15625
4
class Department(object): """Parent class for all departments Methods: __init__, get_name, get_supervisor """ def __init__(self, name, supervisor, employee_count): self.name = name self.supervisor = supervisor self.size = employee_count def get_name(self): """Retur...
true
24f6feeda30f66fddf433d9d4c0cd388b6509763
MrDeshaies/NOT-projecteuler.net
/euler_042.py
1,597
4.125
4
# The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); # so the first ten triangle numbers are: # # 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... # # By converting each letter in a word to a number corresponding to its alphabetical position and # adding these values we form a word value. For examp...
true
542759df80baa3bdc951931364e72aea52226305
amitkumar-panchal/ChQuestiions
/python/q01/Contiguous.py
1,558
4.28125
4
""" Fiels: _items is a list of items _size is number of items that can be stored """ ## Contiguous(S) produces contiguous memory of size s ## and initializes all entries to None. ## Requires: s is positive class Contiguous: def __init__(self, s): self._items = [] self._size = s; for ...
true
164e6ece6af8f27d2f6154414be81e602fc2c53b
Anushadsilva/python_practice
/List/list.pg5.py
489
4.21875
4
'''Write a Python program to extract specified size of strings from a give list of string values. Go to the editor Original list: ['Python', 'list', 'exercises', 'practice', 'solution'] length of the string to extract: 8 ''' #Solution: if __name__ == '__main__': list1 = ['Python', 'list', 'exercises', 'practice', 's...
true
d68786a9942542808767b47b11919d0f7f7eaa6a
Anushadsilva/python_practice
/Functions/func_pg3.py
305
4.28125
4
#Write a Python function to find the Max of three numbers def mx(x,y,z): return max(x,y,z) if __name__ == '__main__': a = int(input("Enter the first number")) b = int(input("Enter the second number")) c =int(input("Enter the third number")) print("max of the given numbers is: ", mx(a,b,c))
true
579d6046604626afd901e8885bcce6de1a8fb09c
SinghReena/TeachPython3
/SayNamesMultipleTimes.py
591
4.21875
4
# SayNamesMultipleTimes.py - lets everybody print their name on the screen # Ask the user for their name name = input("Can I know your name please: ") # Keep printing names until we want to quit while name != "": # Print their name 35 times for x in range(35): # Print their name followed by a spa...
true
ac96cf0e2ab8e77a576743b00c938e0d259aa089
TanmoyX/CodeStore-Cracking_The_Coding_Interview
/Chap2/2.1 - RemoveDuplicates/n2-sol.py
936
4.125
4
class Node: def __init__(self, val): self.data = val self.next = None def printLL(node): while node != None: print(node.data) node = node.next def insertNode(node, val): if node == None: return None while node.next != None: node = node.next node.next...
true
7f8be46a01d986de37906424a7c6e7e186ca30c3
Shivani3012/PythonPrograms
/conditional ass/ques33.py
484
4.375
4
#Write a Python program to convert month name to a number of days. print("Enter the list of the month names:") lname=[] for i in range(0,12): b=input() lname.append(b) #print(lname) m=input("Enter the month name:") ind=lname.index(m) #print(ind) if ind==0 or ind==2 or ind==4 or ind==6 or ind==7 or ind==9 or ind...
true
21d89fe0a3fbf5d59124847acd307845da9205ce
Shivani3012/PythonPrograms
/guessing a number.py
876
4.15625
4
print(" Welcome to the Guessing a Number Game ") print("You have to guess a number if the number matches the random number") print("you win the game else you will only get three chances") name=input("Enter the user name") import random for i in range (1,4): print("Chance",i) r=random.randint(10,50)...
true
53ca55ed41ad6b133f43f1951a52320980eed50d
Shivani3012/PythonPrograms
/conditional ass/ques6.py
419
4.15625
4
#Write a Python program to count the number of even and odd numbers from a series of numbers. a=int(input("Enter the number of elements in the list")) print("Enter the list") l=[] countev=0 countodd=0 for i in range(a): b=int(input()) l.append(b) for i in range(a): if l[i]%2==0: countev+=1 else:...
true
52a686724c000189abcae44a27fc2e0eda9f4b70
Shivani3012/PythonPrograms
/conditional ass/ques35.py
212
4.40625
4
#Write a Python program to check a string represent an integer or not. s=input("Enter the string") a=s.isdigit() #print(a) if a==True: print("This is an integer.") else: print("This is not an integer.")
true
4112f792af4b4e1cd696891ebaa81dcd6868a4c1
KaanSerin/python_side_projects
/rock_paper_scissors_game.py
2,879
4.28125
4
import random def welcomeMessage(): print("Welcome to my very basic rock, paper, scissors game!") print('You can play as long as you want.') print('Whenever you want to quit, just enter -1 and the game will end immediately.') #Implementing the rules of rock paper scissors with if-else blocks d...
true
d43a964b2eddddbfd01ad71ee356b7711f7945fd
s-ajensen/2017-18-Semester
/knockKnock/blackbelt.py
1,857
4.21875
4
# Samuel Jensen, Knock Knock Joke Blackbelt, 9/28/2017 # Checks user input, gets frustrated when user doesn't go with the joke, unnecessary recursion # Get user's name name = input("Hi what's your name?") # Ask user if they want to hear a joke hearJoke = input("Nice to meet you " + name + ", would you like to hear a ...
true
f7b353f903f773892c834561b89e06b732cb61ca
x223/cs11-student-work-ibrahim-kamagate
/april11guidedpractice.py
861
4.25
4
# what does this function return ? This prints the x*2 which is 7*2 def print_only(x): y = x * 2 print y # how is this one different ? This does the same thing as the print function but you dont see it def return_only(x): y = x * 2 return y # let's try to use our 2 functions print "running print_only ..."...
true
90e995d7a410da9d546f1c3a2f687c9e12c74995
prasanth-vinnakota/python-gvp
/generator-fibonacci.py
358
4.125
4
def fibonacci(n): a = 0 b = 1 for i in range(n): yield a a, b = b, a + b size = None try: size = int(input("Enter size of fibonacci series: ")) if size == 0: raise ValueError except ValueError: print("input must be a number and greater than 0") exit(0) for j in f...
true
2cfe7c91405ec313dfed83e864bf6e18f5d8e276
jing1988a/python_fb
/900plus/FractionAdditionandSubtraction592.py
2,718
4.1875
4
# Given a string representing an expression of fraction addition and subtraction, you need to return the calculation result in string format. The final result should be irreducible fraction. If your final result is an integer, say 2, you need to change it to the format of fraction that has denominator 1. So in this cas...
true
1e4e214385a54a8e225977e90172fe154dd2300a
jing1988a/python_fb
/lintcode_lyft/ReverseInteger413.py
558
4.125
4
# Reverse digits of an integer. Returns 0 when the reversed integer overflows (signed 32-bit integer). # # Example # Given x = 123, return 321 # # Given x = -123, return -321 class Solution: """ @param n: the integer to be reversed @return: the reversed integer """ def reverseInteger(self, n): ...
true
f8aef6ac6c5f8838b8fed96f3f36437c6560a423
Almr1209/idk
/ex32.py
1,001
4.59375
5
the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] # this first kind of for-loop goes through a loop for number in the_count: print(f"This is count {number}") # same as above, basically it's using the same format but different var...
true
e5db03cd5cde605a6fda0837ae334bfb247d231f
sarahoeri/Giraffe
/window.py
1,229
4.15625
4
# Tuples...don't change like in lists even_numbers = (2, 4, 6, 8, 10, 12) print(even_numbers[5]) # Functions def sayhi(name, age) : print("Hello " + name + " you are " + age) sayhi("Nancy", "25") sayhi("Christine", "27") # Return Statement def square(num) : return num*num print(square(8)) def cube(num) : ...
true
9391c201f98ce42de5efc3c74cf6a32887901013
hyperskill/hs-test
/src/test/java/projects/python/coffee_machine/stage3/machine/coffee_machine.py
1,127
4.25
4
# Write your code here water_amount = int(input('Write how many ml of water the coffee machine has:')) milk_amount = int(input('Write how many ml of milk the coffee machine has:')) coffee_amount = int(input('Write how many grams of coffee beans the coffee machine has:')) N = int(water_amount / 200) if N > milk_amount /...
true
8cd722978b4902fd1f5e803d37358ac481741a54
mybatete/Python
/seqBinSearch.py
1,873
4.25
4
""" Program: seqBinSearch.py Author : Charles Addo-Quaye E-mail : caaddoquaye@lcsc.edu Date : 01/31/2018 Description: This program implements demo for both sequential and binary search algorithms. The program generates a random list of integers and provides a menu for searching for numbers in the list. Input v...
true
dff114f7caa3b803d85a634807ae4e38aa70a4e0
krissmile31/documents
/Term 1/SE/PycharmProjects/pythonProject/Tut2/Most Frequent Character.py
263
4.28125
4
from collections import Counter #ask user input a string stringCount = input("Enter a string: ") #count char appearing most in that string count = Counter(stringCount).most_common(1) print("Character that appears most frequently in the string: " ) print(count)
true
8dfcd3b7339f271409fa64ae63b4357c8692e990
adinimbarte/codewayy_python_series
/Python_Task6/Q.4/Q.4.py
283
4.15625
4
# taking string input string = input("Enter the string from which you want to count number of 'at': ") # counting occurence of "at" and printing count=string.count("at")+ string.count("At")+ string.count("At") + string.count("AT") print("'at'occured %d times in string." % count )
true
c94fe10616b30c1291d5675772810fc0374fbc69
KeithWilliamsGMIT/Emerging-Technologies-Python-Fundamentals
/03-fizzbuzz.py
506
4.34375
4
# Author: Keith Williams # Date: 21/09/2017 # This script iterates between the numbers 1 and 100. # For each iteration there is a condition for each of the following: # 1) For numbers which are multiples of both three and five print "FizzBuzz". # 2) For multiples of three print "Fizz". # 3) For multiples of five print...
true
a406961c86682d5d15c0b6eaa25a187a33a8ae59
scoffers473/python
/uneven_letters.py
564
4.28125
4
#!/usr/bin/python3 """ This takes an input word and prints out a count of uneven letters for example in aabbc we have one uneven letter (c). In hello we have 3 (hme and o) """ import sys from collections import Counter def solution (S): removal=0 counter = Counter(S) for letters in S: if count...
true
680528fefc54b25668e4e7fdb1ebc2cfc752f1ff
scoffers473/python
/days_offset.py
1,197
4.25
4
#!/usr/bin/python3 """ This take an input number and works out the offset day based on this number Days are Mon:1 Tue:2 Wed:3 Thu:4 Fri:5 Sat:6 Sun:7 So if i passwd an offset of 7 this would be a Sunday, a 5 a Friday, a 13 a Saturday, etc """ import sys def solu...
true
0e55bc414b576a4a6962eaac939dd1709fcb04de
ksu-is/Congrats
/test_examples.py
269
4.125
4
# Python code to pick a random # word from a text file import random # Open the file in read mode with open("MyFile.txt", "r") as file: allText = file.read() words = list(map(str, allText.split())) # print random string print(random.choice(words))
true
3b4d4944bfe4a170225e0d213f327c89d890905d
lttviet/py
/bitwise/count_bits.py
337
4.15625
4
def count_bits(x: int) -> int: """Returns the number of bits that are 1. """ num_bit: int = 0 while x: # if odd, right most bit is 1 num_bit += x & 1 # shift to the right 1 bit x >>= 1 return num_bit if __name__ == '__main__': for i in (1, 2, 11): print(...
true
b81c76ba7cc637017c0432b6d9b0e527cd624fd3
tvanrijsselt/file-renamer
/main.py
1,058
4.15625
4
"""This main module calls the helper functions in the main-function, such that the right files in the right folder are changed.""" import os from helperfunctions import ask_input_for_path, ask_input_base_filename, files_ending_with_chars def main(): """Main function to call the helper functions and rena...
true
caedf25abc2fcbb1677d8743b9f50e254447bdd9
ahathe/some-a-small-project
/MyPython/test/StrBecome.py
320
4.15625
4
#!/usr/bin/env python 'make string become largest to smallest orade! ' num = list(raw_input("plaese input number!thank you!:")) choice = raw_input("input you choice!,one or two:") one = 'one' two = 'two' if choice == one: num.sort() print num elif choice == two: num.sort() for x,i in enumerate(num): print x,i
true
950c8785a6fe4cec2e491a1e1ca90a1651cae86d
ahathe/some-a-small-project
/MyPython/test/NumTest.py
1,626
4.25
4
#!/usr/bin/env python 'is input number to count mean and total' empty = [] def Input(): while True: num = raw_input("input you number to count mean!,input 'q' is going to quit!:") if num == ('q' or 'Q'): print 'rechoice input type,input or to count or remove or view!' Choice() else: try: number ...
true
1298ec09dc5cf5bbbe9ad19dd9a691e60e384b2c
JaclynStanaway/PHYS19a
/tutorial/lesson00/numpy-histograms.py
2,352
4.53125
5
""" Author: Todd Zenger, Brandeis University This program gives a first look at Numpy and we plot our first plot. """ # First, we need to tell Python to bring in numpy and matplotlib import numpy as np import matplotlib.pyplot as plt from scipy.stats import norm # np and plt are the standard shortcut names we give it...
true
ba522adf755c38008a07ac70acb9effcc2dafe1e
sonushakya9717/Hyperverge__learnings
/dsa_step_10/power_of_number.py
238
4.15625
4
def power_of_number(n,x): if x==0: return 1 elif x==1: return n else: return n*power_of_number(n,x-1) n=int(input("enter the number")) x=int(input("enter the degree of no.")) print(power_of_number(n,x))
true
b732cda25aed23b3a2f629b89bccf286cf16c62c
mrvrbabu/MyPycode
/Python Developer Bootcamp/Section5-Python_Loops/1.for_loops_pt-1.py
472
4.4375
4
# ----------------------------------------------------------------------- # # --------------- ** For Loops ** -------------------------- # # Example 1 - DRY - Do not repeat yourself # n = 3 # for (i=0, i<=n,): # print(i) # i += 1 for x in range(10): print(x + 1) print("\n") for number in range(5): pri...
true
24a8c11de8abacaf180b9e99452ddf3e7adc17d6
mrvrbabu/MyPycode
/Python Developer Bootcamp/Section4-Python_Logic-Control_Flow/21.Conditional_statements.py
621
4.46875
4
# ----------------------------------------------------------------------- # # --------------- ** Control Statements ** ---------------------------- # """ if (boolean expression): execute the statements """ # ******************** Example Check for a single condition ******************* temperature = int(input(...
true
d0d29d933e69c997308480233cd114b6e10e188d
mrvrbabu/MyPycode
/Python Developer Bootcamp/Section5-Python_Loops/4.iterables.py
342
4.125
4
# ----------------------------------------------------------------------- # # --------------- ** Iterables ** -------------------------------------- # # *** Example 1 print(type(range(4))) for char in "Welcome Home": print(char) # *** Example 2 for somethin in ["Coffee", "Play with the cat", "Walk the dog"]...
true
7a3d476958d7a43f3545000557bd7c66990e2ab6
faustfu/hello_python
/def01.py
1,281
4.5
4
# 1. Use "def" statement with function name, parameters and indented statements to declare a function. # 2. Use "return" statement with data to return something from the function. # 3. If there is no "return" statement, the function will return "None". # 4. All parameters are references. # 5. Parameters could be assign...
true
e240fabceddd8c71f1a81d400582a996bbd0ac07
avbpk1/learning_python
/circle_area.py
251
4.4375
4
# Program to accept radius and calculate area and circumference radius = float(input("Please Enter Radius:")) pi = 22/7 area = pi * radius**2 circumference = pi * 2 * radius print(f"Area is : {area}") print(f"Circumference is : {circumference}")
true
2c95c3f1109bd296b05896f637a61c155f2ef6d8
avbpk1/learning_python
/assignments.py
476
4.125
4
# This is assignment 1 # Program to take input from user until 0 is entered and print average. Negative input to be ignored total = 0 cnt = 0 while True: num = int(input("Please enter a number (Entering Zero will terminate) : ")) if num == 0: break elif num < 0: continue else: ...
true
9f1190f69f2799fd18d2e86845f794643761d4c2
avbpk1/learning_python
/20May_ass4.py
568
4.1875
4
# -- ass4 -- use map to extract all alphabets from each string in a list. Use map and a function def ext_alpha(word_str): new_word = '' for c in word_str: if c.isalpha(): new_word += c return new_word words = ['Ab12c','x12y2','sdfds33&'] for word in words: alpha_extract =...
true
43aa1410040d47341dab6e09813c0820f38d3f97
LalithaNarasimha/Homework2
/Solution2.py
1,062
4.21875
4
# Code that compute the squares and cubes for numbers from 0 to 5, # each cell occupies 20 spaces and right-aligned numbers = [ 0, 1, 2, 3, 4, 5] place_width = 20 header1 = 'Number' header2 = 'Square' header3 = 'Cube' print('\nSolution 1\n') print(f' {header1: >{place_width}} {header2: >{place_width}} {header3: >{pl...
true
ef47c071219b5964290c6802f8006a639abf1955
amylearnscode/CISP300
/Lab 8-5.py
2,270
4.1875
4
#Amy Gonzales #March 21, 2019 #Lab 8-5 #This program uses while loops for input validation and calculates #cell phone minute usage def main(): endProgram = "no" minutesAllowed = 0 minutesUsed = 0 totalDue = 0 minutesOver = 0 while endProgram=="no": ...
true
82fc95d5d86f08c337f3823f0bd147c142f8c69e
floydnunez/Project_Euler
/problem_004.py
852
4.21875
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ import math def check_palindrome(number): is_palindrome = True str_num = str(number) size...
true
9b6ed13e70dcb0706ea37b9c4d36b8e838d7965a
swaroopsaikalagatla/Python
/python5.py
267
4.125
4
def maximum(a,b,c):#function list=[a,b,c]#statement 1 return max(list)#statement 2 x=int(input("Enter the first number : ")) y=int(input("Enter the second number :")) z=int(input("Enter the third number :")) print("biggest number is :",maximum(x,y,z))
true