blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a84eb297b6a54c8c3b69f375bc9622700111a2b0
dp1608/python
/LeetCode/17/reshape_the_matrix.py
2,287
4.6875
5
# -*- coding: utf-8 -*- # @StartTime : 9/28/2017 10:14 # @EndTime : 9/28/2017 10:36 # @Author : Andy # @Site : # @File : reshape_the_matrix.py # @Software : PyCharm """ In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but k...
true
f81faa097ead6fc3d0812e0a288c5a4cb893e2a4
dp1608/python
/LeetCode/1807/134_gas_station_180721.py
2,544
4.1875
4
# -*- coding: utf-8 -*- # @StartTime : 2018/7/21 21:26 # @EndTime : 2018/7/21 21:40 # @Author : Andy # @Site : # @File : 134_gas_station_180721.py # @Software: PyCharm """ There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tan...
true
57d42228e26afb65aef09f2edb2b5104103663cf
CP1404/Practicals
/prac_03/capitalist_conrad.py
1,156
4.1875
4
""" CP1404/CP5632 - Practical Capitalist Conrad wants a stock price simulator for a volatile stock. The price starts off at $10.00, and, at the end of every day there is a 50% chance it increases by 0 to 10%, and a 50% chance that it decreases by 0 to 5%. If the price rises above $1000, or falls below $0.01, the progra...
true
fb364986fb5737f6f517f6d62928cdad5a5f8b06
CP1404/Practicals
/prac_10/recursion.py
700
4.28125
4
""" CP1404/CP5632 Practical Recursion """ def do_it(n): """Do... it.""" if n <= 0: return 0 return n % 2 + do_it(n - 1) # TODO: 1. write down what you think the output of this will be, # TODO: 2. use the debugger to step through and see what's actually happening print(do_it(5)) def do_somethin...
true
c9d2cee52a708856839e5c8659a63b58b67fa6c5
gauravjoshi1998/joshi_gaurav1-hackerrank
/percentage.py
627
4.125
4
#You have a record of students. Each record contains the student's name, and their percent marks in Maths, Physics and Chemistry. #The marks can be floating values. The user enters some integer followed by the names and marks for students. #The user then enters a student's name. Output the average percentage marks ...
true
b7db1b591dc1c70e5664f3b6d96167c9f8af3cd0
snallanc/Python-Projects
/quick-examples/lambdaFunc.py
361
4.34375
4
""" lambda keyword is used to define/return small anonymous functions. lambda expressions are meant to have just one expression per definition. """ def power(x): return lambda y: x ** y p=power(10) print("Powers of 10:\n") for i in range(1,10): print(p(i)) """ Output: Powers of 10: 10 100 1000 10000 100000 ...
true
39d8eb384876ef640b633c9c95097675d8ea670a
SACHSTech/livehack-1-python-basics-JackyW19
/problem1.py
556
4.1875
4
""" Name: problem1.py Purpose: compute the temperature in celsius to fahrenheit and output it to the user. Author: Wang.J Created: date in 07/12/2020 """ print ("**** Welcome to the celsius to fahrenheit ****") # get the temperature in celsius from the UserWarning celsius_temperature = float(input("Enter the temp...
true
c22afee28f141c89f3021c6bf8c6c6caed098afc
bobbytoo2/SJ-Sharks
/TuitionIncrease.py
1,102
4.1875
4
# TuitionIncrease.py ''' This program calculates tuition (per semester) on a yearly basis with the percent increase and amount of years. ''' def main(): # Enter tuition fee t = float(input("Enter the current tuition fee: ")) while t < 0: print("ERROR: The tuition fee cannot be negative.") t = float(input(...
true
cd98b77f7b44f64495f7221e320b8f7967830e9b
kanatnadyrbekov/Ch1Part2-Task-17
/task17.py
1,457
4.125
4
# Write the code which will write excepted data to files below # For example given offices of Google: # 1) google_kazakstan.txt # 2) google_paris.txt # 3)google_uar.txt # 4)google_kyrgystan.txt # 5)google_san_francisco.txt # 6)google_germany.txt # 7)google_moscow.txt # 8)google_sweden.txt # When the user will say “Hell...
true
850f118e89a82c763881e122bcb146796ce8c12a
mdfarazzakir/Pes_Python_Assignment-3
/Program55.py
1,776
4.21875
4
""" Exception Handling Write a program for converting weight from Pound to Kilo grams. a) Use assertion for the negative weight. b) Use assertion to weight more than 100 KG """ """Function to convert pounds to kg and to check that the weight should not be negative""" def poundsTokgs(pound): print("\na)Converting n...
true
d94858c4bddeb340f0a45af9a59aa707384ef2fa
mdfarazzakir/Pes_Python_Assignment-3
/Program60/listPackage/list3.py
2,146
4.28125
4
""" Python List functions and Methods Create a list of 5 names and check given name exist in the List.         a) Use membership operator (IN) to check the presence of an element.         b) Perform above task without using membership operator.         c) Print the elements of the list in reverse direction. """ l = ...
true
deab2c1a0cbc174c7feaa1c00c7dbb837ff09ed9
mdfarazzakir/Pes_Python_Assignment-3
/Program58/calc.py
1,144
4.3125
4
"""Function to add two numbers""" def add(num1,num2): return(num1 + num2) """Function to subtract two numbers""" def subtract(num1,num2): return(num1 - num2) """Function to multiply two numbers""" def multiply(num1,num2): return(num1 * num2) """Function to find the suare root of a number""" def squareRoo...
true
a87c5c45b59b01bf7934f3ef409e77ce066c6950
mdfarazzakir/Pes_Python_Assignment-3
/Program60/stringPackage/string12.py
2,127
4.46875
4
def strgOp(): strg = input("Enter the string: ") print("\nYour enetered string is: ",strg) print("\nString operation using startswith return True if S starts with the specified prefix, False otherwise: ") stg1 = input("Enter the string for check: ") print("\nAfter performing startswith:",strg.start...
true
f47d8e9d4fed9676d7e6b134f18818d93db21d44
mdfarazzakir/Pes_Python_Assignment-3
/Program41b.py
846
4.15625
4
""" Dictionary  and Date & Time: Using calendar module perform following operations. a) Print the 2016 calendar with space between months as 10 characters. b) How many leap days between the years 1980 to 2025. c) Check given year is leap year or not. d) print calendar of any specified month of the year 2016. """ """I...
true
ac44a72d80053e2484a03a77451db74accf387ae
mdfarazzakir/Pes_Python_Assignment-3
/Program60/stringPackage/string5.py
2,072
4.59375
5
""" Strings: Write a program to check given string is Palindrome or not.That is reverse the given string and check whether it is same as original string, if so then it is palindrome.Example: String = "malayalam"  reverse string = "malayalam" hence given string is palindrome. Use built functions to check given string is...
true
a9d6b7af8185c2cca2dd3df0c0a9aace8b3e4942
Amarthya03/Scripting-Languages-Lab
/Week_2/lab2.py
635
4.25
4
# Python has 5 data types: Number, String, List , Tuple, Dictionary # Strings are immutable # All the elements belonging to a list or tuple can be of different data type # List elements and size can be changed # Tuples are "read-only" lists. They are immutable. Once created, their size and elements cannot be changed # ...
true
f500e62929cdeee175464927e2564d59eda1d8ac
vonbalzer/module
/db/people.py
288
4.25
4
def what(): answer = input("Do you know how much will be, 2 + 2 ? !!!yes or no!!!") if answer == 'yes': print('You are smart') elif answer == 'no': print('You need to learn the multiplication table, xD') else: print('Read the terms carefully)))')
true
61bd084536f349759ea4ce6e26a81a507f30b56e
aliceshan/Practice-Questions
/recursion_dynamic_programming/robot_in_a_grid.py
2,743
4.25
4
""" Type: Dynamic programming, graphs Source: Cracking the Coding Interview (8.2) Prompt: Imagine a rovot sitting on the upper left corner of grid with r rows and c columns. The robot can only move in two directions, right and down, but certain cells are "off limits" such that the robot cannot step on them. Design an a...
true
560df3a1ab20c6a2e6f2966e6070e93a2682d537
parisa7103/Python
/hw3q3.py
400
4.125
4
#Define a procedure, product_list, #takes as input a list of numbers, #and returns a number that is #the result of multiplying all #those numbers together. #product_list([9]) => 9 #product_list([1,2,3,4]) => 24 def product_list(inputList): result = 1 for a in inputList: result *= a print result inputList1 = [9]...
true
ab1c2281fd3c21a6768c9c4343c11146b95b29a6
TanyaPaquet/sortrec
/sortrec/sorting.py
2,490
4.46875
4
def bubble_sort(items): '''Return array of items, sorted in ascending order. Args: items (array): list or array-like object to sort. Returns: array: list or array-like object to sorted in acsending order. Examples: >>> bubble_sort([3, 6, 3, 5, 8, 1]) [1, 3, 3, 5, 6, 8] ...
true
6fa9fd0df0aa8c79b20d6844d9df464589a145a2
PrithviRajMamidala/Leetcode_Solutions
/Problems/Arrays&Strings/climbingStairs.py
424
4.125
4
"""bottom-top approach Can use dictionary for storing other elements and easy lookup more optimized solution""" def climbStairs(n): stairs = [] stairs.extend([0, 1, 2]) # print(stairs) if n <= 2: return stairs[n] i = 3 while i <= n: stairs.append(stairs[i-1] + stairs[...
true
abf3c8d71bd970d0b6f48040b70f1e9df32fba0f
rohan2jos/SideProjects
/BinaryTree/HeapNode.py
2,092
4.21875
4
''' Class for the node that will be used in the heap will be imported into the implementing program ''' class HeapNode: data = 0 left = '' right = '' ''' __init__() --> constructor args: data, left node, right node returns: the initialized node with the passed arguments ''' def __...
true
7fc0f940d23c137748ab18f91b1625b25d2c38f3
sampita/Python-Showroom-Junkyard
/cars.py
1,655
4.1875
4
# Create an empty set named showroom. showroom = set() # Add four of your favorite car model names to the set. showroom = {'Jeep Renegade', 'Kia Soul', 'Ford Thunderbird', 'Toyota Prius'} # Print the length of your set. print(len(showroom)) # Pick one of the items in your show room and add it to the set again. showr...
true
02640b8941b4e0ea239b980c9ea90123cd6c538b
jared-chapman/Projects
/Python/Python_Examples/Chapter 9 (Files)/Writing to files.py
1,167
4.3125
4
#open a file with the open function #Takes two parameters, a string representing the path, and a string representing the mode to open the file in #File paths shouldn't be typed manually as different OS's label them differently #Instead, use the built-in os module. Takes each location in a file as a parameters #Fi...
true
9c8d0bf8df50fb169aec3657cdb7cb0c2ebd0faf
jared-chapman/Projects
/Python/Python_Examples/Chapter 4 (Functions)/Functions.py
924
4.59375
5
#Define a function with [def functionName(paramaters):] def double(x): return x*2 #Call a function with [functionName(paramaters)] result = double(3) print(result) #A function doesn't have to have parameters def sayMyName(): return "Jared" name = sayMyName() print(name) #A function ca...
true
a4c841c701a38f50417a4b3f1c91f630f17cd5f8
Lackman-coder/python-tutorail
/while_loop/introduction.py
690
4.53125
5
i = 1 while i < 6: print(i) i += 1 # With the while loop we can execute a set of statements as long as a condition is true. # Note: remember to increment i, or else the loop will continue forever. i = 1 while i < 6: print(i) if i == 3: break i += 1 # With the break statement we can stop the loop even i...
true
ad064a81e1db44094af4f23eca4857085402a233
Lackman-coder/python-tutorail
/list/add list items.py
722
4.5625
5
thislist = ["apple", "banana", "cherry"] thislist.append("orange") print(thislist) # To add an item to the end of the list, use the append() method. thislist = ["apple", "banana", "cherry"] thislist.insert(1, "orange") print(thislist) # Insert an item as the second position. thislist = ["apple", "banana", "cherry"] t...
true
09fdff6a6ae012ea69be341a50b80954b2d7ab41
Lackman-coder/python-tutorail
/list/remove list itmes.py
699
4.4375
4
thislist = ["apple", "banana", "cherry"] thislist.remove("banana") print(thislist) # The remove() method removes the specified item. thislist = ["apple", "banana", "cherry"] thislist.pop(1) print(thislist) # The pop() method removes the specified index. thislist = ["apple", "banana", "cherry"] thislist.pop() print(th...
true
ae5e01be8e3605a1c14866421730be6f299b1bc8
greysou1/pycourse
/mod2/practice/challenge.py
602
4.15625
4
the_list = ['cat', 'dog', 'machine'] def list_o_matic(the_list, entry): if entry == '': popped = the_list.pop() return popped + ' popped from list' elif entry in the_list: the_list.remove(entry) return '1 instance of "' + entry + '" removed from the list' else: ...
true
d9f1229f680f3f33e15eb90522e36aca499f5c7f
hafij15/python-basic
/6/short_circuit_evalution.py
261
4.28125
4
# name = '' # if name == "": # default_name = "Guest" # else: # default_name = name # print(default_name) # name = 'Hafij' # default_name = name or 'Guest' # print(default_name) name = "Hafij" upper_name = name and name.upper() print(upper_name)
true
82570514a9830884ba59d6acd247f0d9000d5a78
tberhanu/elts-of-coding
/Arrays/primes.py
1,202
4.40625
4
import math def is_prime(n): if n == 2: return True if n < 2: return False i = 2 while i <= math.sqrt(n): if n % i == 0: return False i += 1 return True def list_all_primes_upto(n): """ Getting all the prime numbers upto number N. Note: Rather...
true
fc1a7e72faaff24a58411840f763eb732bbe91cf
tberhanu/elts-of-coding
/HashTables/test_collatz_conjecture.py
1,878
4.46875
4
def test_collatz_conjecture_driver(num): s = {1: 1} i = 2 return test_collatz_conjecture(i, num, s) def test_collatz_conjecture(i, num, s): """ Coolatz conjecture is: Taking any natural number, and halve it if it's even, or multiply it by 3 and add 1 if it's odd number. If...
true
1a4dcdb5122d2540963d77450759faa7c10bd71a
tberhanu/elts-of-coding
/DynamicProgramming/min_triangle_path_weight.py
1,576
4.15625
4
def min_path_weight(triangle): """ Write a program that takes as input a triangle of numbers and returns the weight of a minimum weight path. Tess Strategy: Once we know the min at row 1, then we will know at row 2, and once we know the min at row 2, we will know the min at row 3 without the...
true
6f73e8b67c000778c1007c8a558fdfb591641a47
tberhanu/elts-of-coding
/Searching/binary_search.py
2,520
4.1875
4
""" In built Binary Search Libraries: 1. bisect.bisect_left(arr, e): return the first index whose value is >= e, else return len(arr) arr = [0, 1, 2, 4] bisect.bisect_left(arr, 2): return 2 bisect.bisect_left(arr, 3): return 3 num = [0, 1, 2, 2, 2, 2, 4, 5] bisect.bisect_left(nu...
true
72412b507958b248e4c579e8b8ab337d3e3c4a22
tberhanu/elts-of-coding
/Arrays/46. permutations.py
796
4.125
4
""" Given a collection of distinct integers, return all possible permutations. Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] """ def permute(nums): nums2 = nums[:] # copying the nums to reserve start = 0 result = [] return permutation(nums, nums2, start, re...
true
f353962660242276ab460e96fd3b3ffdac2ba141
tberhanu/elts-of-coding
/Graphs/search_maze.py
2,761
4.25
4
from collections import namedtuple WHITE, BLACK = range(2) Coordinate = namedtuple('Coordinate', ('x', 'y')) def search_maze_driver(maze, start, end): path = [] return search_maze(maze, start, end, path) def search_maze(maze, start, end, path): """ Consider a black and white digitized image of a maze-w...
true
ee4770920fb96f25fea3462b58418c4919891758
tberhanu/elts-of-coding
/Sorting/sort_linked_list.py
844
4.1875
4
def sort_linked_list(ll): """ Strategy: 1. Loop through the linked list and append each Node to the ARRAY, O(N), since looping through N number of Nodes, and APPENDING to Array takes only O(1), unlike INSERTING w/c takes O(N). 2. Sort the array in REVERSE OREDER i.e. a...
true
f46cec3b67374f498a85f493aa0e90b10a4094fe
tberhanu/elts-of-coding
/GreedyAlgorithms/two_sum.py
1,386
4.125
4
def two_sum(arr, target): """ Given a sorted array of integers, and a target value, get two numbers that adds up to the TARGET. Strategy 1: Brute-force: Double for loop checking each and every pair: O(N * N) Strategy 2: HashTable: Putting the arr in HashTable or SET, and check if (Target - e) found in H...
true
b49ddda99c07271539c9bfd92ea9b63d8d1dfc34
tberhanu/elts-of-coding
/Searching/search_sorted_matrix.py
1,862
4.21875
4
def search_sorted_matrix(matrix, num): """ Question: Given a sorted 2D array, matrix, search for NUM SORTED MATRIX: means each ROW is increasing, and each COL is increasing Solution: Brute-force approach of looping thru the double array takes O(N * N) Smart approach is: 1. Gr...
true
f6ca9a0bd17be2e8f4547a2f65b94b546e33a3e9
tberhanu/elts-of-coding
/GreedyAlgorithms/optimum_task_assignment.py
1,076
4.3125
4
def optimum_task_assignment(task_durations): """ Consider assigning tasks to workers where each worker must be assigned exactly TWO TASKS, and each task has a fixed amount of time it takes. Design an algorithm that takes as input a set of tasks and returns an optimum assignment. Note: Simply enumer...
true
caccbb5a383caf682478494c3288e2f45424e298
jimmy1087/codeKatas
/sorting/bubbleSort.py
836
4.21875
4
''' o(n^2) 5 * 5 = 25 steps to sort an array of 5 elements that were in desc order. ''' def bubbleSort(array): steps = 0 outerLoop = 1 sorted = False sortedElements = 0 while not sorted: steps += 1 print('[[loop]]', outerLoop) outerLoop += 1 sorted = True for...
true
9e5e40c15f41762cf4fcc76c484260d6bcebb9f1
bradg4508/self_taught_challenges
/chp_4.py
1,479
4.4375
4
#1 def square(x): """ Returns x^2. :param x: int. :return: int x raised to the second power. """ return x**2 print(square(2)) #2 def print_string(word): """ Prints a string passed in by user. :param word: str. """ print(word) print_string("This is a sent...
true
924f623d0dae965902aba3b2c4d2abc9e14d3e4e
marcovnyc/penguin-code
/1000_exercises/1000_exercises_02.py
563
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Aug 3 22:59:33 2021 @author: Marco M """ print("Let's calculate the area of a rectangle") print("Formula: A = w * l") print("Enter width and height") width_value = int(input("enter width -> ")) height_value = int(input("enter height -> ")) area = wi...
true
cc2b260b8fe52136b91c440c2b264dd1ef93e126
marcovnyc/penguin-code
/Impractical-Python-Projects/chapter_8_9/syllable_counter.py
2,095
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 17 16:29:46 2019 @author: toddbilsborough Project 15 - Counting Syllables from Impractical Python Projects Objective - Write a Python program that counts the number of syllables in an English word or phrase Notes - First experience with natural l...
true
91e78752c499744a110c0dc947a52cfbf60a0594
utep-cs-systems-courses/python-intro-ecrubio
/wordCount.py
2,127
4.125
4
import sys # command line arguments import re # regular expression tools import os # checking if file exists #Checking that the correct format is used when running the program. #When running the file it should also have the input and output files in the argument def argumentCheck(): if len(...
true
d4cded95c436c9973d914324a537690e1e2b0060
MohamedGassem/ai_for_tetris
/src/AI/metrics.py
2,554
4.125
4
import numpy as np def compute_holes(board): """ Compute the number of holes in the board Note: a hole is defined as an empty cell with a block one or more blocks above Parameters ---------- board: 2d array_like The tetris board ...
true
c10bacef9eab1132af932f4aeae83d954093cc7f
burnacct36/lpthw
/ex29.py
756
4.3125
4
# An if-statement creates what is called # a "branch" in the code. The if-statement # tells your script, "If this boolean expression # is True, then run the code under it, otherwise skip it." people = 20 cats = 30 dogs = 15 if people < cats: print "Too many cats! The world is doomed!" if people > cats: print "No...
true
0540e9ef0c4fd0a078d4c36d7e52f87996b171e6
Davie704/My-Beginner-Python-Journey
/IfStatementsBasic.py
1,048
4.21875
4
# If statement basics # Ex 1 salary = 8000 if salary > 5000: print("My salary is too low!") else: print("My salary is above average, its okay right now.") # Ex 2 age = 55 if age > 50: print("You're a senior Developer, for sure!") elif age > 40: print("You're more than 40 years old.") el...
true
71a34df3b3807a67a682d0ff908b5d4c3cdf07c8
Davie704/My-Beginner-Python-Journey
/Variables.py
1,241
4.5
4
# My Learning Python Journey # A simple string example short_string_example = "Have a great week, Ninjas!" print(short_string_example) # Print the first letter of a string variable, index 9 first_letter_variable = "New York City"[9] print(first_letter_variable) # Mixed upper and lowercase variable mixed_l...
true
7b2270e4177a957ff674f6a17a22041910889efa
FarazMannan/Magic-8-Ball
/Magic8Ball.py
2,755
4.1875
4
import random count = 0 # count = count + 1 print("Welcome to Faraz's Magic 8 Ball") # Faraz, wrap the code below in a loop so the user can # keep asking the magic 8 ball questions... Go! # Challenge number 2 before we call it a day... # create a variable to keep track of whether we should keep running # the magi...
true
562aab1605b9c5e77f75b11d9a3b74552ca2c5da
ProdigyX6217/interview_prep
/char_count.py
251
4.4375
4
user_str = input("Please enter a string: ") # This variable will be used to hold the number of characters in the string. count = 0 # This for loop adds 1 to count for each character in user_str. for char in user_str: count += 1 print(count)
true
8851c47cc61d585a02bbe8ab035c3248afd5e3a6
ProdigyX6217/interview_prep
/convert_degrees.py
720
4.5
4
celsius = int(input("Please enter an integer value for degrees celsius: ")) def fahrenheit(cel): # To avoid the approximation error that would occur if the float 1.8 was used in the calculation, 1.8 * 10 is used # instead, resulting in the integer 18. To balance this out, 32 is also multiplied by 10 to get...
true
b679551cca213b2b705d70eff7e45b61c2b3f010
karaspd/leetcode-problem
/python/6/ZigzagConversion.py
1,477
4.15625
4
""" 6. ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a st...
true
ada4a46a88954707cb958f23a0b13332d4ed37eb
shavvo/Projects
/Projects/PtHW_Ex/ex15_open_files.py
668
4.25
4
from sys import argv script, filename = argv txt = open(filename) # 'open' is a command that reads the files # ( as long as you put the name of the file in # the command line when you run the script) print "Here is your file %r:" % filename print txt.read() # txt is the variable of object and the . (dot) # is to add...
true
b0ff17bb9b8e449491605256305d1873e21c322d
RedPython20/New-Project
/weight_conv.py
460
4.3125
4
#Weight Converter app #Convert your weight to either pounds or kilos. #This section gets the user's data weight = input("How much do you weigh? ") unit = input("(L)bs or (K)gs? ") #Pounds to kilos if unit == "L": new_weight = int(weight) // 2.205 print("Your weight in kilos is : ", str(new_wei...
true
54de09d1bfb95805012c167e2dfbe9dbe9fc3751
MarkBenjaminKatamba/python_sandbox
/python_sandbox_starter/conditionals.py
1,704
4.46875
4
# If/ Else conditions are used to decide to do something based on something being true or false c = 16 d = 16.4 # Comparison Operators (==, !=, >, <, >=, <=) - Used to compare values # Simple if # if c > d: # print(f'{c} is greater than {d}') # If/else # if c > d: # print(f'{c} is greater than {d}') # else: ...
true
a0261cafabef291f465553216412ee185a0a84ca
flash-drive/Python-First-Go
/Homework 2 Fall Time.py
759
4.15625
4
# Homework 2 Fall time # Mark Tenorio 5/10/2018 # Write a program that determines the time it takes for an object # to hit the ground from a given height # Recall the kinematics equation: # distance = velocity(initial) * t + (1/2)*acceleration*time^2 # Assume that velocity(initial) is zero m/s. # Assume that...
true
d9e16a8ffdcbac930cb679cce804e6d2478ddedc
flash-drive/Python-First-Go
/Homework 3 Weather Stats.py
976
4.28125
4
# Homework 3 Weather Stats # Mark Tenorio 5/13/2018 # Write a program that takes in a list # comprised of a vector and a string. Output the maximum and average # of the vector and output the string. # Import modules from statistics import mean import ast # Function to output max, average, and string from ...
true
c68142b091a3f615de97fc4aeb5a46cfac02f508
flash-drive/Python-First-Go
/Classes.py
1,440
4.46875
4
#### Class #### # Classes are blueprints where you can make objects # Objects contain different variables and methods (function) # Differences between a class and an object is that the values that belong # to the variables are not defined. It will not refer to a specific object. # class Robot: # def intro...
true
c974d7b78b2410ef05689f39ebe0ff1e277f44fc
RashiKndy2896/Guvi
/Dec19_hw31strong.py
561
4.28125
4
maximum = int(input(" Please Enter the Maximum Value: ")) def factorial(number): fact = 1 if number == 0 or number == 1 : return fact for i in range(2, number + 1) : fact *= i return fact for Number in range(1, maximum): Temp = Number ...
true
75d9e3de14c2f7e2fda2de6f6be687625176f389
euphoria-paradox/py_practice
/p_d_3/3_fruit_display.py
346
4.34375
4
# P1 3 # Program to display respective fruit name for # the user input of Alphabets(A,B or C) alphabet = input('Enter the character(A or B or C): ') # checking for condition if alphabet == 'A': print('Apple') elif alphabet == 'B': print('Banana') elif alphabet == 'C': print('Coconut') else: ...
true
266cc73a414731724b29a33a8bf3aaba718ca3a4
euphoria-paradox/py_practice
/p_d_3/monthly_mortgage.py
1,647
4.46875
4
# Home Loan Amortization # This program calculates the monthly mortgage payments for a given loan amount # term and range of interests from 3 to 18% # the formula for determinig the mortgage is A/D # A - original loan amount # D - discount factor given by D = ((1+r)^n -1)/r(1+r)^n # n- number of payments, r-inter...
true
3341c9c72a7ed6f6233ca4eca015aa38020106ed
euphoria-paradox/py_practice
/p_d_3/3.3.1_sum_even.py
274
4.1875
4
# Addition of even numbers between 100 and 200 # Init num = 100 sum_of_even = 0 # summing of even numbers using a while loop while num <= 200: sum_of_even += num num += 2 # Display of result of addition print('Sum of even numbers between 100 & 200:', sum_of_even)
true
6b4ea4370106b2820c50f7d8f62f10498a1fbef7
euphoria-paradox/py_practice
/p_d_3/lif_signs.py
1,440
4.375
4
# Life Signs # This is a test program to that determines number of breaths # and the number of heartbeats the person had in their life # based on their age. # The average respiration rate of people changes during different # stages of development. # the breath rates used are : # Infant - 30-60 breaths per min ...
true
a65ddcbd2e1e57a05a1e7573e821a4bec1418062
CampbellD84/Sprint-Challenge--Data-Structures-Python
/reverse/reverse.py
1,885
4.125
4
class Node: def __init__(self, value=None, next_node=None): # the value at this linked list node self.value = value # reference to the next node in the list self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.nex...
true
33ef25bcd74c64f23733386d5c48ebea36968d89
rjdoubleu/GSU
/Design and Analysis of Algortithms/Python/Depth_First_Search.py
1,943
4.15625
4
# Python program to print DFS traversal from a given given graph # Visits all verticies and computes their mean and variance from collections import defaultdict #from random import randint # This class represents a directed graph using adjacency list representation class Graph: # Constructor def __init...
true
5a5a1b03c9b6fb68c07014256b34cf9e7af6d7e0
vijaybnath/python
/vijay16.py
464
4.21875
4
energy = int(input('enter the number you want to convert ')) units = input('which type of convertion you want to do only (kw)kilowatts to watts , (kv) kilovolt to volt or (v)olt to watt ') if (units == "kw"): converted = energy * 1000 print(f"the converted energy = {converted} watt") elif(units == "kv"): co...
true
1aa3363b36796f3672ff6db15c6771b93839c360
RNTejas/programming
/Python_Flow_Control/Python Flow Control/8.For loop.py
304
4.375
4
print("Welcome to the For Loop") """ The computer can perform the repeated tasks very quickly or earlier like, For Loop While Loop List Comprehension and Generators it executes the block of code for each iterable """ parrot = "Norwegian Blue" for character in parrot: print(character)
true
e5d92fbeff64e9a91d4a94b2329a840970f77372
RNTejas/programming
/Python_Flow_Control/Python Flow Control/1.if Statements.py
742
4.25
4
# the input function will returns the value as a string # name = input("Please enter your name: ") # age =int(input(f"How old are you, {name}?")) # print(age) # this will print out the age but we can't add the string to this number # print(f"{name}, is {age} Years old") # age = int(age) # print(2 + age * 10) # ...
true
a4a88d8eb3ab92368571017794feb22f99a1893d
byui-cse/cse210-student-solo-checkpoints-complete
/06-nim/nim/game/board.py
2,039
4.3125
4
import random class Board: """A designated playing surface. The responsibility of Board is to keep track of the pieces in play. Stereotype: Information Holder Attributes: _piles (list): The number of piles of stones. """ def __init__(self): """The class constructor. ...
true
7493c538d11bf91f27a028d505b5f3e98cf7f61e
UtsavRaychaudhuri/Learn-Python3-the-Hard-Way
/ex9.py
446
4.125
4
# assigning the variable days="Mon Tue Wed Thu Fri Sat Sun" # assigning to a variable but with new line inbuilt into the string months="Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" # printing print("Here are the days:",days) # printing print("Here are the months:",months) # Multiline string print(""" There's something ...
true
79d97d8382aaf7b9993e108b7a2fa0580b6cf53b
Aaryan1734/RPS
/RPS.py
1,758
4.21875
4
# ROCK PAPER SCISSORS GAME # Remember the rules: # rock beats scissors # scissors beats paper # paper beats rock import getpass print("""Let's play a game of rock paper scissors!! You'll need a partner to play this game. To End the Game input any response other than rock, paper or scissors.""") print(...
true
bbced53efb44e572f6c919da5a7bd7b2dc510c8e
porregu/unit5
/claswork8.py
306
4.15625
4
user_number = int(input("what number do you want to put?")) while user_number!=1: print(user_number) if user_number%2==0: user_number/=2 print("new number = ",user_number)# print the new number else: user_number=user_number*3+1 print("new number = ",user_number)
true
1320d84cad763e584256cd1f8be502618534221b
Zchap1/Old_Python
/guess my number game.py
645
4.125
4
print ("\tWelcome to 'guess my numer'!") print ("\n I'm thinking of a number between 1 and 1000.") print ("Try to guess it in as few attempts as possible.\n") # set the initial values import random the_number = random.randint(1, 1000) #guess = int(input("take a guess: ")) guess = 0 tries = 0 #guessing loops5 while gue...
true
b21dc12fd76fb85352c1ea0a9ebbed5ec9e730f1
Jean13/convenience
/unscramble.py
1,470
4.15625
4
# Template for unscrambling words # Compares a scrambled wordlist with original wordlist and unscrambles unscrambled = [] def main(): readFiles() # Read the original wordlist and the txt file with the scrambled words def readFiles(): # Makes the words from the files available to the whole program glob...
true
4fcad62bea4bb3df5080548ab6e1ed117d7c747b
VolanNnanpalle/Python-Projects
/rock_paper_scissors.py
1,650
4.46875
4
# -*- coding: UTF-8 -*- """ Rock, Paper, Scissors Game Make a rock-paper-scissors game where it is the player vs the computer. The computer’s answer will be randomly generated, while the program will ask the user for their input. """ from random import randint #rock beats scissors #paper beats rock #scissors beats...
true
dc7fd3fa3c12fc96a59261296a9d8b0bd097153b
yuvaraj950/pythonprogram
/averageof list.py
247
4.15625
4
#Take a list list1 = [5,6,8,9,7,5] #Average of number = sum of numbers in list /total members in list length = len(list1) print(length) sum_list1 = sum(list1) print(sum_list1) #output average_list1 = (sum_list1 / length) print(average_list1)
true
365898eb7874e64e2dcd5a04e21eb28b667ad119
miguelhasbun/Proyecto-1_SI
/main.py
871
4.15625
4
from trie import * from levenshtein import * WORD_TARGET = sys.argv[1] for word in WORDS: trie.insert(word) l = levenshtein() if WORD_TARGET=="grep" or WORD_TARGET=="ping" or WORD_TARGET=="ls": result = WORD_TARGET else: print ("Did you meant to say:",l.search(WORD_TARGET)) result = l.search(WORD_TA...
true
7037a8f4a82695fdbc29207f80336fed27d15ec1
alexander-mcdowell/Algorithms
/python/InsertionSort.py
1,131
4.4375
4
# Insertion Sort: Simple sorting algorithm that works relatively well for small lists. # Worst-case performance: O(n^2) where n is the length of the array. # Average-case performance: O(n^2) # Best-case performance: O(n) # Worst-case space complexity: O(1) # Method: # 1. Loop through the array. If array[i + 1] < ar...
true
1781d10e402e177dec64720c36b491c8167acbdd
alexander-mcdowell/Algorithms
/python/ShellSort.py
1,847
4.3125
4
import math # Shell sort: a variant of isertion sort that sorts via the use of "gaps." # Worst-case complexity: O(n log n) where n is the length of the array. # Average-case complexity: O(n^4/3) # Best-case complexity: O(n^3/2) # Worst-case space complexity: O(1) # Method: # 1. Initialize the gap values. # 2. ...
true
29a4361f03d95b3e5ace4e4b90c3d870a88e4794
alexander-mcdowell/Algorithms
/python/ExponentiationSqr.py
1,445
4.28125
4
import math # There are two algorithms here: Exponentiation by Squaring and Modulo of Exponentiation by Squaring. # Both algorithms use O(log n) squarings and O(log n) multiplications. # Exponentiation by Squaring: Quickly computes the value n^k by using properties of squaring. # This method works because of the prop...
true
677b93fab786b8e3997ab0b8c42db26093ff6b20
gaomigithub/Leetcode
/GraphValidTree.py
1,696
4.25
4
# Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. # For example: # Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return true. # Given n = 5 and edges = [[0, 1], [1, 2], [2, 3], [1, 3],...
true
b13d1b40e5fe1b97f94bc9a2380542cba9640364
viniciuszambotti/statistics
/Binomial_Distribution/code.py
584
4.1875
4
''' Task The ratio of boys to girls for babies born in Russia is 1.09: 1 . If there is 1 child born per birth, what proportion of Russian families with exactly 6 children will have at least 3 boys? Write a program to compute the answer using the above parameters. Then print your result, rounded to a scale of 3 decimal ...
true
8b012009d004b277dcd911213be55ad4e62b12f1
qbarefoot/python_basics_refreshers
/pbrf1.8_sorting_lists.py
1,076
4.59375
5
#we can use the ".sort()" statement to put a list in alphabetical order. horses = [ "appalose", "fresian", "mustang", "clydesdale", "arabian" ] horses.sort() print(horses) #we can also arrange our list in alphabetical order backwards with the ".sort(reverse=True)". horses = [ "appalose", "fresian", "mustang", "clydesd...
true
090041cd7dc95f2a3176b13985a691c289379037
smh82/Python_Assignments
/Vowels.py
335
4.34375
4
# Write a Python program to test whether a passed letter is a vowel or not letter = input ("enter the letter to be checked : ") v = "AEIOU" for i in v: if i.upper() == letter.upper(): print("the letter {t} is a vowel".format(t=letter)) break else : print( "the letter {t} is not a vowel ".for...
true
06881534aeb302011ff5229bbb4feae0047d4e3f
smh82/Python_Assignments
/Area_of_Circle.py
214
4.4375
4
# Python program which accepts the radius of a circle from the user and compute the area import math radius = float(input ("Enter Area of Cirle ")) print("Area of Circle is : " + str( math.pi*radius**2 ))
true
9d7e5b798dac265dbd23c4c5f8bca62db8cad843
projectinnovatenewark/student_repository
/todos/3_classes_and_beyond/17_classestodo.py
1,656
4.53125
5
""" Creating classes for your classmates """ # TODO: Create a class for an Employee, and include basic data # TODO: like hours worked, salary, first name, last name, age, and title # TODO: Create a function inside the class and print out a formatted # TODO: set of strings explaining the details from the employee. Us...
true
7d66b8782ac7e066a550125483791c7ec6c8beaf
alive-web/paterns
/src/strategy/second.py
1,920
4.125
4
__author__ = 'plevytskyi' class PrimeFinder(object): def __init__(self, algorithm): """ Constructor, takes a callable object called algorithm. algorithm should take a limit argument and return an iterable of prime numbers below that limit. """ self.algorithm = algo...
true
098f4f60e0a9eafe5e039ff135354b073b1b1016
andizzle/flipping-game
/board.py
1,188
4.125
4
from Move import move class Board: size = 0 moves = 0 def __init__(self, board_size): """ Construct a board grid like """ x = 0 self.grid = [] self.size = board_size while(x < board_size): row = [1 for size in range(board_size)] ...
true
429c33062fd855385134e8294ad03cb3fd7d1a43
Thatguy027/Learning
/Learning_python/ex3.py
923
4.34375
4
# print text in quotes print "I will now count my chickens:" # calculates 25 + (30/6) print "Hens", 25 + 30 / 6 # % or modulus gives you the remainder of 75/4 = 3 print 75 % 4 # 100 - (25*3)%4 print "Roosters", 100 - 25 * 3 % 4 print "Now I will count the eggs:" print 5 % 2 print 1 - 1/4 + 6 # calculates everyth...
true
c9f9b5ddce63734ae225e8f899707b6db253945e
melardev/PythonAlgorithmSnippets
/sort_nested_iterable_by_index.py
420
4.375
4
""" We will sort a list of tuples based on the index of a tuple that is contained in the list This would also work for list of lists (shown in other demo) """ def sort_callback(value): return value[1] my_list_of_tuples = [(1, 2), (2, 3), (3, 4), (2, 2), (2, 1)] my_list_of_tuples.sort(key=sort_callback) print(m...
true
d192f485a91461f5cffadb07c247d22f9335578c
sharepusher/leetcode-lintcode
/data_structures/tree/trie/implement_trie.py
2,514
4.125
4
## Reference # http://www.lintcode.com/en/problem/implement-trie/ # 208 https://leetcode.com/problems/implement-trie-prefix-tree/#/description ## Tags - Medium; Blue # Trie; Facebook; Uber; Google ## Description # Implement a trie with insert, search, and startsWith methods. # NOTE: # You may assume that all inputs a...
true
cab50d418dfc432d379e5754a0367d499ae620e2
sharepusher/leetcode-lintcode
/data_structures/hashtable/hash_function.py
1,688
4.25
4
## Reference # http://www.lintcode.com/en/problem/hash-function/ ## Tags - Easy # Hash Table ## Description # In data structure hash, hash function is used to convert a string (or any other type) # into an integer smaller than hash size and bigger or equal to zero. # The objective of designing a hash function is to "...
true
0eb832f03503b99fbca623515c4230512846cb9b
superstones/LearnPython
/Part1/week1/Chapter6/directory_exercise/directory_table_6.3&6.4.py
758
4.28125
4
# 6.3词汇表 directory = { 'print': 'Output statement', 'min': 'Find the smallest number in the list', 'max': 'Find the largest number in the list', 'sum': 'Sum the list', 'pop': 'Delete the list of element', 'for': 'Repeat statement', '+': 'Add two objects', '-': 'Get a negative number or s...
true
d1373ab395a8a6200cf0193c02d52e74ef112a17
superstones/LearnPython
/Part1/week1/Chapter4/Exercise/cut_4.10.py
301
4.5
4
#4.10切片 items = ['beautiful', 'handsome', 'brilliant', 'nice', 'prefect', 'regret', 'forgive'] print("The first three items in the list are:") print(items[:3]) print("Three items from the middle of the list are:") print(items[2:5]) print("The last three items in the list are:") print(items[-3:])
true
7394d5ab482418b278d95c53be799cbe3c47bf8a
nchen0/Data-Structures-Algorithms
/Data Structures/Queues & Stacks/Intro - Queue.py
1,085
4.15625
4
# Queues follow a FIFO (First in first out) approach. # It's tempting to use a similar approach as stack for implementing the queue, with an array, but it becomes tragically inefficient. When pop is called on a list with a non-default index, a loop is executed to shift all elements beyond the specified index to the lef...
true
85d196557625563dfc6d3cee88445d373d18529c
nchen0/Data-Structures-Algorithms
/Data Structures/Queues & Stacks/Circular LinkedList as Queue.py
1,204
4.28125
4
class CircularQueue: """Queue implementation using circular linked list for storage""" def __init__(self): self.tail = None self.size = 0 def isEmpty(self): return self.size == 0 def first(self): if self.isEmpty(): return "List is empty" head = self...
true
00d1bbd2552698704a794b6881a07bd33f750db8
jnajman/hackaton
/03_recursion/03_draw_01_nautilus.py
1,350
4.3125
4
''' In this exercise, you'll understand the concepts of recursion using selected programs - Fibonacci sequence, Factorial and others. We will also use Turtle graphics to simulate recursion in graphics. Factorial Fibonacci Greatest common divisor Once we understand the principles of recursion, we can do fun stuff with...
true
b08d237c10a08e9e5de0e43cc1cd2905b693e209
CharlotteKings/Data14Python
/introduction/Advanced_FizzBuzz.py
962
4.40625
4
# Function to check if inputted values are integers def check(val): while not val.isnumeric(): val = input("Please type a valid number? \n") if val.isnumeric: return int(val) # Assign counter = check(input("What number do you want to start from? \n")) limit = check(input("What number do you wan...
true
3a3845be749058ed1c1c4141bcd36584ca49da17
any027/PyTest_Examples
/pytest_venv/calculator/calculator.py
856
4.21875
4
class CalculatorError(Exception): """ An exception class for Calculator """ class Calculator(): """ Example Calculator """ def add(self, a, b): self.check_operands(a) self.check_operands(b) return a + b def subtract(self, a, b): self.check_operands(a) self.che...
true