blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
dc32aca649e15f1c376cdab3b7a4863bee192039
FrankieZhen/Lookoop
/LeetCode/python/172_easy_Factorial Trailing Zeroes.py
704
4.21875
4
''' Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: 5 Output: 1 Explanation: 5! = 120, one trailing zero. Note: Your solution should be in logarithmic time complexity. ''' # 2018-9-8 # 172. Factorial Trailing Zero...
true
ce1fc687bcda7d954466f08b088607d876ca15d6
FrankieZhen/Lookoop
/LeetCode/python/81_medium_Search in Rotated Sorted Array II.py
1,821
4.4375
4
""" Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). You are given a target value to search. If found in the array return true, otherwise return false. Example 1: Input: nums = [2,5,6,0,0,1,2], target = 0 Output: true...
true
78f10e0ada769334998f0136c58fc1d63b2590d4
FrankieZhen/Lookoop
/LeetCode/python/72_hard_Edit Distance.py
1,833
4.125
4
""" Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitted on a word: Insert a character Delete a character Replace a character Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: horse -> rorse (re...
true
81d8203e7b5bcbfc3ec76d2f5a0c7ae240d0e490
FrankieZhen/Lookoop
/LeetCode/python/03_medium_Longest Substring Without Repeating Characters.py
1,529
4.21875
4
''' Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of 1. Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substri...
true
ea5a74c1d2fbddded07ec4c8e9b14b36a3793d02
jacko8638/algorithms
/Binary search algorithm.py
1,020
4.28125
4
#this sub finds the index for the given num by finding the midpoint, seeing if it's higher or lower and reapeats until it find the mun. def binarySearch(aList, itemSought): found = False index = -1 first = 0 last = len(aList)-1 #while loop to check if the num is found or not while first <= last ...
true
5b4ebeb5243a0350bf7386d546ac3c6c23f6ab26
blackkspydo/100_small_projects_in_python
/project_14.py
621
4.15625
4
# How to make question of random number? import random result = random.randint(1,20) guess = None while result != guess: guess = int(input('\nGuess any number between 1 and 20: ')) if guess <=20: if result > guess: print('Your guess is smaller than result. guess little higher.') ...
true
a4c0e17197af7f9271a678bde17b36883be5213e
Adamcglee/Intro-Python
/src/day-1-toy/fileio.py
462
4.28125
4
# Use open to open file "foo.txt" for reading f = open("foo.txt", "r") # Print all the lines in the file lines = f.read() print(lines) # Close the file f.close() # Use open to open file "bar.txt" for writing file = open("bar.txt", "w") # Use the write() method to write three lines to the file with open("bar.txt", "w"...
true
a35be4876cea1cea2966c015da032d2755732186
clzendejas/HackerRank_Algos
/Strings/AlternatingCharacters.py
1,066
4.40625
4
#!/bin/python3 """ Alternating Characters: Shashank likes strings in which consecutive characters are different. For example, he likes ABABA, while he doesn't like ABAA. Given a string containing characters A and B only, he wants to change it into a string he likes. To do this, he is allowed to delete...
true
ba0b2ea43401e35b5d712da24e382932fd9af4f8
clzendejas/HackerRank_Algos
/Implementation/UtopianTree.py
1,412
4.5
4
#!/bin/python3 """ Utopian Tree: The Utopian Tree goes through 2 cycles of growth every year. Each spring, it doubles in height. Each summer, its height increases by 1 meter. Laura plants a Utopian Tree sapling with a height of 1 meter at the onset of spring. How tall will her tree be after N growth c...
true
d25d7e1cc0d37b91ff02070d2d3a73b6f1a2a799
clzendejas/HackerRank_Algos
/Implementation/CaesarCipher.py
1,782
4.53125
5
#!/bin/python3 """ Caesar Cipher Julius Caesar protected his confidential information by encrypting it in a cipher. Caesar's cipher rotated every letter in a string by a fixed number, K, making it unreadable by his enemies. Given a string, S, and a number, K, encrypt S and print the resulting string. ...
true
e5610a264eb1f82302111f6ad50ea20d925ad00e
jxavie/python-challenge
/Part-1/HW_Task1_HouseOfPies/house_of_pies.py
1,818
4.46875
4
print("\nWelcome to the House of Pies! Here are our pies: ") # Create list of pies pie_types = ["Pecan", "Apple Crisp", "Bean", "Banoffee", "Black Bun", "Blueberry", "Buko", "Burek", "Tamale", "Steak"] # Print pie options available for user selection for pie in pie_types: pie_location = pie_types.index(pie) + 1 ...
true
e3cccf31569aa1b3ae6de0e3acacc9caa25d2e48
sophiasagan/coding-challenges
/codesignal/restoreBinaryTree.py
1,485
4.3125
4
''' Let's define inorder and preorder traversals of a binary tree as follows: Inorder traversal first visits the left subtree, then the root, then its right subtree; Preorder traversal first visits the root, then its left subtree, then its right subtree. For example, if tree looks like this: 1 / \ 2 3 / ...
true
42580ca2ac7f96de82e274edab9cfa693d23b24d
CooperPair/the-basic-projects
/clock.py
1,222
4.1875
4
class clock(object): def __init__(self, hours, minutes, seconds): self.set_clock(hours, minutes, seconds) def set_clock(self,hours, minutes, seconds): if type(hours) == int and 0 <= hours and hours < 24: self._hours = hours else: raise TypeError("Hours have to be an integer between 0 and 23") if typ...
true
bab8a37704b6f937f56cfba920b9094d1b00624f
ZixinYang/leetcode
/872.py
1,236
4.1875
4
''' Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. Two binary trees are considered leaf-similar if their leaf value sequence is the same. Return true if and only if the two given trees with head nodes root1 and root2 are leaf-similar. Note: ...
true
7bd9e188587ff68aa5605be7968bfa6351e055a8
florian-hartl/python-testing-framework
/python_testing_framework/increment.py
1,617
4.1875
4
"""Functions to increment values or to set them to zero.""" import json def zero(): return 0 def inc(num): return num + 1 def zero_dict_values(data): """Sets values of input data to zero. Parameters ---------- data : dict Any dictionary. """ for k, v in data.items(): data[k] = zero() de...
true
4a46c2c04db187a52cbcd548a487bfd946208785
YelikeWL/functions-collection
/initial-deposit-value.py
612
4.1875
4
'''Suppose you want to deposit a certain amount of money into a savings account with a fixed annual interest rate. What amount do you need to deposit in order to have $XXXX in the account after XX years?''' # Data needed finalAccountValue = float(input("Enter final account value: ")) annualInterestRate = float(input(...
true
f428a5c7bfef8371e05e48937501996f8b50dd57
MarkAYoder/BeagleBoard-exercises
/python/GPIOtest.py
2,668
4.125
4
#!/usr/bin/env python3 # From: https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/gpio # From: https://adafruit-beaglebone-io-python.readthedocs.io/en/latest/GPIO.html # To setup a digital pin as an output, set the output value HIGH, and then cleanup after you're done: # import Adafruit_BBIO.G...
true
7695b2f31cd369451735e6999ebdfa66a666f4e5
kalynbeach/Python-Projects
/Projects/WeatherAdvisor.py
763
4.1875
4
# Weather Advisor by Kalyn Beach # Given the current temperature in Fahrenheit, determine the advisable activity # for the given weather: def weather(): temperature = input("Enter the current temperature (in Fahrenheit, between 0 and 100): "); if (temperature < 0 or temperature > 100): print "Invalid...
true
f8a7cb5679f15ab2d792ef2bc5d96837f6e591be
akonon/pbhw
/04/hw04.py
1,771
4.25
4
# -*- coding: utf-8 -*- # Task 1: Relative frequencies of letters # Count relative weights of letters in a string (in percent). Case-insensitive. # Print out a dictionary: # {letter: its_percentage_of_occurence_in_the_string} # Round values to the first decimal place. # Example: # 'ABCda' >> {'a': 40.0, 'b': 20.0, 'c'...
true
d5feec5259d3e0f46f55be766d4c6491d661d77f
akonon/pbhw
/01/03.py
290
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Task 3: Count occurences of a substring. # Count overlapping occurenses as well. # s = "wowhatamanwowowpalehche" # ... # print count # 3 s = 'wowhatamanwowowpalehche' count = 0 for i in range(len(s)): if s[i:i+3] == 'wow': count += 1 print count
true
336c456f11883c65cc49ef0570d5e241de1f36f5
louieg888/CS61A
/misc/quiz1.py
1,171
4.34375
4
""" Last Name: McConnell First Name: Louie Student ID number: 3032735110 CalCentral email: louie.mc@berkeley.edu Discussion Section: Online 11-12:30pm All the work on this exam is my own (please initial): LM For each of the expressions in the table below, write the output displayed by the interactive Python interprete...
true
3777e43bb22bba869643d79d3dd722eb01572a8b
elchananvol/IntrotoCS
/ex9/game.py
2,529
4.125
4
from car import Car from board import Board import json import sys class Game: """ Add class description here """ def __init__(self, board): """ Initialize a new Game object. :param board: An object of type board """ self.board = board def __single_turn(self...
true
413949d4d84e9bb915abea37f423de392d87a1ab
KSrinuvas/ALL
/aa/PYT/PRAC/NET/OOPS/nn6.py
226
4.15625
4
#!/usr/bin/python3 import re ''' Write a program which accepts a sequence of words separated by whitespace as input to print the words composed of digits only. ''' s = input() bb = re.findall("\d+",s) print (bb)
true
5d9e77582407791414db48689ca94ae9354acc5d
KSrinuvas/ALL
/srinivas/PY_FILES/meterial/data_types_0.py
797
4.5
4
#!/usr/bin/python3 ##-------------------------------------------------------- ## python data types ##-------------------------------------------------------- ''' 1] Number 2] String 3] List 4] Tuple 5] Dictionary 6] Set ''' ##-------------------------------------------------------- ## number no1 = 10; ## inte...
true
3f606bce55a524c9ee267c855692bed0fab4c8a0
KSrinuvas/ALL
/srinivas/PY_FILES/TASKS/DAY3/min_max.py
509
4.15625
4
#!/usr/bin/python3 ## to find the min and max elem in the list without using min() and max() functions #list1 = [1,5,6,7,8,9,10,11,12,20,100,2,15,17,19] ''' list1.sort() print(list1) print("maximum no in a list: " , list1[-1]) print("minimum no in a list: " , list1[0]) ''' str = str(input("Enter the values with ...
true
c7b8852da7b1aa3ac4e4cfd95ac45829b5748187
KSrinuvas/ALL
/aa/PYT/Reg/rr3.py
506
4.28125
4
#!/usr/bin/python3 test_list = [[4, 5, 1], [9, 3, 2], [8, 6]] # printing original list print("The original list : " + str(test_list)) # using List comprehension + enumerate() + sort() # Indices of sorted list of list elements res = [(i, j) for i, x in enumerate(test_list) ...
true
700e24eb977923f2bafb2a8442818ecd09610977
KSrinuvas/ALL
/aa/PRAC/PERL/switch1.py
337
4.1875
4
#!/usr/bin/python3 def Switch_case (argument): switches = { 0 : "this is case 0\n", 1 : "this is case 1\n", 2 : "this is case 2\n", 3 : "this is case 3\n" } return switch.get(argument,"nothing") if __name__ == "__main__": argument = int(input("Enter the value check the case : ")) aa = Switch_case(argume...
true
22a50ddbbe1e8aaa9bfb6b4a653eb7a519531aa6
WiooPikings/Lab_experiment
/Experiment2/Arithematic_Fucnctions.py
1,259
4.25
4
# Import math Library import math # Return the sine of different values print (math.sin(0.00)) # 0.0 print (math.sin(-1.23)) # -0.9424888019316975 print (math.sin(10)) # -0.5440211108893698 print (math.sin(math.pi)) # 1.2246467991473532e-16 print (math.sin(math.pi/2)) # 1.0 # Return the cos of different numbers pri...
true
fcb4ff9abe41c7d17ab60a044c15ba155b28f1a2
dylburger/python-data-structures
/queue.py
672
4.4375
4
""" We do not want to implement queues using list in Python, since popping elements from the left of the list (necessary for the queue to work) requires moving all other elements over to the left, which is an O(n) operation """ from collections import deque q = deque(["a", "b", "c"]) q.append("d") q.poplef...
true
067a87f22379e9d5c980860c77fea4933510a871
tdesfont/CtCI-6th-Edition-Python
/Chapter10/sorting/radixSort.py
1,220
4.125
4
""" Radix Sort: O(k.n) where n is the number of elements and k is the number of passes of the sorting algorithm """ from math import log, floor from queue import deque def getBit(n, i): """ Must return 0 or 1 :param n: :param i: :return: """ return (n &(1<<i))>>i def radixSort(arr...
true
5cb669c2eadad25a6567727b06553221aa6f9b24
tdesfont/CtCI-6th-Edition-Python
/Chapter01/6_String Compression/string_compression.py
1,349
4.125
4
""" 1.6 String Compression """ def compress_recursive(string): """ Recursive approach for the string compression :param string: :return: """ if not string: return "" i = 0 count = 1 while i < len(string)-1 and string[i] == string[i+1]: count += 1 i += 1 ...
true
ae0dd189914bdffbd50abfb0c71e2bd3a0006ef0
CMNWestbrook/calculator-2
/calculator_file.py
1,827
4.28125
4
"""calculator.py Using our arithmetic.py file from Exercise02, create the calculator program yourself in this file. """ from arithmetic import * def calculator(): file_name = "numbers.txt" try: with open(file_name) as f: tokens = f.readlines() f.close() except (OSError, IOErro...
true
b95a51373a12a6797665a25ad3e1064f40a88be6
rodrigo-r-martins/programming-problems
/leetcode/array/findNumbersWithEvenDigits.py
1,017
4.375
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). ...
true
c6c7cffe95f3ef7cabf1bdf522fb21afe39139ec
DHIVYASHREE5/list_methods
/list methods.py
923
4.46875
4
fruits = ['apple', 'banana', 'cherry'] fruits.append("orange") print(fruits) # get the index of 'banana' index = fruits.index('banana') print(index) # 'grapes' is inserted at index 3 (4th position) fruits.insert(3, 'grapes') print('List:', fruits) # remove the element at index 2 removed_element = fruits...
true
be8ab9954f6f47f78fe21a918f8f07c446f69263
alessiaamele/qa-python-exercises
/easy-level-exercises/times_tables.py
393
4.34375
4
max_range = int(input("Input a number")) listOfValues = [] # create a list for i in range(1, max_range + 1): listOfValues.append(i) # function to multiply all values in a list def multiplyList(myList, multiplier): for x in myList: x = x * multiplier return myList print(multiplyList(listOfValues, ...
true
67ebf6d1fabdce5b7287018a88a997180cb40284
remace/OC-P3-MacGyver
/sources/characters.py
1,298
4.21875
4
"""module definition for the characters classes""" class Character: """abstract class about characters like Mac Gyver and the Villain""" def __init__(self, x, y, name): """constructor""" self.x = x self.y = y self.name = name class Hero(Character): """class defining a he...
true
7bac91bc0ec7b820a6a20e8d8ce34a0db8c96803
HarleyB123/python
/session_2/answers/A4.py
278
4.40625
4
# A4 - Ask the user to enter a number, if the number is even, print "Even", otherwise print "Odd" number = int(input("Please enter a number to find out if it is even or odd:\n")) if number % 2 == 0: print(str(number) + " is Even") else: print(str(number) + " is Odd")
true
82a85e81571c62c1d284e919fcf4657b8cc82b6f
gabrielwry/InterviewPractice
/Algorithm/LeetCode/UnionFind.py
1,435
4.1875
4
# Python Program for union-find algorithm to detect cycle in a undirected graph # we have one egde for any two vertex i.e 1-2 is either 1-2 or 2-1 but not both from collections import defaultdict # This class represents a undirected graph using adjacency list representation class Graph: def __init__(self, vertic...
true
ae07aa3c82e96ce57dedabcc5998892985653a62
SuXuewei/learn_python
/simpleProgram/simpleProgram.py
1,425
4.25
4
#python3 simple #1 Output print ('Hello, world!') #2 Input, assignment name = input('What is your name?\n') print ('Hi, %s.' % name) #3 For loop, built-in enumerate function, new style formatting friends = ['Tina', 'Able', 'Penda', 'Rose'] for i, name in enumerate(friends): print ("iteration {iteration} is {name...
true
f70a44b847a0f0941e5d9a4af7b8c07cb07f1e50
candytale55/Learn_Python_2__Classes
/12_Shapes_Class__Inheritance_Syntaxis.py
1,026
4.53125
5
""" In Python, inheritance works like this: class DerivedClass(BaseClass): # code goes here where DerivedClass is the new class you’re making and BaseClass is the class from which that new class inherits. """ class Shape(object): """Makes shapes!""" def __init__(self, number_of_sides): self.number_of_side...
true
df5b64f2a45db85ee097db52c2bf3e1a886ea007
sam456852/EECS349_ML
/PS1/PS1.py
1,789
4.21875
4
# DOCUMENTATION # ===================================== # Class node attributes: # ---------------------------- # children - dictionary containing the children where the key is child number (1,...,k) and the value is the actual node object # if node has no children, self.children = None # value - value at the nod...
true
975c97f264e28d0b989c16198c76f2c9cb4b39a4
Miguel-Tirado/Python
/python_work/Chapter_10/common_words.py
837
4.46875
4
def count_words(file_name): """Count the approximate number of words in a file""" # in order to fail silently we can replace the print statement inside the except block # with a pass statement which tells python to do nothing for that block of code try: with open(file_name, encoding='utf-8') as ...
true
517c543e4d845ec2f0caaafe2dc0f574108b4f05
Miguel-Tirado/Python
/python_work/Chapter_3/cars.py
353
4.375
4
cars = ['bmw', 'audi','toyota','subaru'] print("Here is the original list:") print(cars) print("\nHere is the sorted list:") print(sorted(cars)) print("\nHere is the original list again") print(cars) print("\nHere is the reverse order") # the resverse method modifies the list permantly to start from the last itme on th...
true
d08efc280e3e82fa8dd488bc0a903370e8ccc02f
Miguel-Tirado/Python
/python_work/Chapter_7/parrot.py
421
4.3125
4
# message = input("Tell me something, and I will repeat it back to you: ") # print(message) prompt = "\nTell me something, and I will repeat it back to you:" prompt += "\nEnter 'quit' to end the program. " # adding a while loop to iterate as many times until the user wants to quit new_message = '' while new_message !...
true
06539c13636ab7c0d28d8a2420cb71f0f212c0b9
Miguel-Tirado/Python
/Python_Projects/Data_Visualization/Chap15_generating_data/random_walk.py
1,277
4.375
4
from random import choice class RandomWalk: """A class to generate random walks.""" def __init__(self, num_points=5000): """Initialize attributes of a walk""" self.num_points = num_points # all walks start at (0, 0). self.x_values = [0] self.y_values = [0] def...
true
691280d4f525e4a08cbc6130191a03c5ee392c6a
rohitrnath/DataStructures-Algorithms
/6. Sorting Algorithms/1. InsertionSort.py
646
4.15625
4
# Insertion sort is proces of sorting an array. # In insertian sort, we divide the array into two, sorted part and unsorted part. # Every time we select the first element from the unsorted part and find its position in sorted part and insert there. # At the beginning, we onsider the first element is sorted part and rem...
true
eda8e76c906c018b98f272cf15b83d0e6691a4aa
MimiDumpling/Mentors
/jos_string_compression.py
1,221
4.25
4
from collections import defaultdict """ String compression. collapse down repeated sequence of letters. only compress more than 2 repeats Take a string. break into list. #1 implement compression into new copy. #2 implement in place Ex) "aaaa" => a4 # doesn't compress only 2 repeats "aabbb" => aab3 """ def str_comp...
true
e058854ca0b4ac36a3b96282489fbaa3598f3272
MimiDumpling/Mentors
/jos_enumerate.py
787
4.15625
4
""" Write a function that takes two lists of numbers, of equal length, containing the same numbers, but in scrambled order. so for example, [41, 27, 12, 8] and [8, 27, 12, 41]. return a list of tuples that maps from one list to another - each tuple contains the index of a number in the first list, and then the in...
true
9c446497b615b3f73ab48cef18dae24d393d76a5
MimiDumpling/Mentors
/rot4.py
2,237
4.15625
4
# def rot4_encrypt(): # """Encrypts a string of letters by rotating each letter four indexes in alphabet.""" # alphabet=["a","b","c","d","e","f","g","h","i","j","k","l", # "m","n","o","p","q","r","s","t","u","v","w","x","y","z"] # dictionary = {} # # range(0, 26) # for char in range(0, len(al...
true
bbbb97cbc3a56debba71fec82cfe88b7a1c98031
Redwoods87/CS167
/dictionaries.py
2,539
4.25
4
# wget http://cs.whitman.edu/~davisj/cs/167/2016F/exmpls/dictionaries.py def add_fruit(inventory, fruit, quantity): """ Add the specified quantity of fruit to the inventory. Parameters: inventory, a dictionary mapping names to quantities fruit, a string naming a type of fruit quantity,...
true
f6ba7845a52de7dd632559e63c5dd27722e6e5c4
CodingDojoDallas/python_feb_2017
/john_lee/Python OOP/chaining.py
804
4.25
4
class Bike(object): def __init__(self,name,price,max_speed,miles): print 'Bike!' self.name = name self.price = price self.max_speed = max_speed self.miles = miles def displayInfo(self): print self.price print self.max_speed print self.miles ...
true
3d07348bcd96c1a95ed8e493ef3c0debe344ac14
CodingDojoDallas/python_feb_2017
/James_Kelley/pythonFundamentals/python_assignments/stringsAndLists.py
1,311
4.21875
4
'''print the position for all instances of the word "monkey". Then create a new string where the word "monkey" is replaced with the word "alligator".''' str = "If monkeys like bananas, then I must be a monkey!" print str.find('monkey') print str.replace('monkey', 'alligator') #Print the min and max values in a lis...
true
4b75488598f0e94415109b6e48a5dc6f4e8bfea6
miguelpduarte/Advent-Of-Code-2017-Py
/Day5/Day5-Part2.py
1,425
4.1875
4
#!/usr/bin/python3 #Ended up not using this function but keeping it because it looks cool def isAnagram(w1, w2): """True if one word is an anagram of another""" #Don't believe it's necessary to create a list from the strings beforehand #If checking for strictly anagrams should also check if w1 is differen...
true
a0b0f0cd034a2d751f31ad4bf9f997a994c774f5
MHI2000/HW-2
/HW2 #2.py
379
4.40625
4
# Get the Volume & Length of the Cylinder from the user: Radius = float(input('Please Enter the Radius of a Cylinder: ')) Length = float(input('Please Enter the Length of a Cylinder: ')) PI = 3.14 Area = PI * Radius * Radius Volume = PI * Radius * Radius * Length print(" The Volume of a Cylinder = %.2f" ...
true
103f031412d14149eea7c350856388bfc383934d
normangalt/Algorithms-Lab-1
/generate_experiments.py
2,277
4.1875
4
"Generators of the experiments for sorting algorithms tests" import random from math import ceil def generate_array(number: int): """ Generates an array of size n consisting of random elements . Args: number (int): size of the list. Returns: [list]: a list of size n consisting of ran...
true
2cf9231370343e6db65876ba95cf2b84c3e9334c
sheilagmit/Practice-Work
/grade.py
695
4.25
4
# Program to read a students percentage mark and print out the corresponding grade. # Taken from Andrew Beatty's week 4 lab on "if elif and else" percentage = float(input("enter the percentage:")) # print (percentage) # be careful with 'ands' and 'ors' if percentage < 0 or percentage > 100: print ("Please enter ...
true
d9d6227c2d6cf4b6bc581dcf2294d35bfee96367
bhavitavayashrivastava/Python-Code
/7) Capped_output.py
721
4.375
4
''' Three equation are capped for a given output but rest function should be executed normally Given these three calculations are capped for output : # 45 * 3 = 555 # 56 + 9 = 76 # 56/6 = 5 ''' num1 = int(input("Enter your first number : ")) operator = input("enter your operator : ") num2 = int(input("Enter...
true
0274aba0ed1d6f922a3ccf326fddb02b26740937
ViviRsk/hackerrank
/algorithms/implementation/counting_valleys.py
1,190
4.78125
5
#!/bin/python3 """ Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike, he took exactly n steps. For every step he took, he noted if it was an uphill or a downhill step. Gary's hikes start and end at sea level. We define the following te...
true
df444d9d2200eb1348805955a0e04d64210729a5
ViviRsk/hackerrank
/cracking-the-coding-interview/arrays_left_rotation.py
505
4.3125
4
#!/bin/python3 ''' Output Format Print a single line of space-separated integers denoting the final state of the array after performing left rotations. Sample Input 5 4 1 2 3 4 5 Sample Output 5 1 2 3 4 Explanation When we perform left rotations, the array undergoes the following sequence of changes: Thus, we ...
true
a45cee9121af5c928702510419f80fab788bfcee
ali9155/Even_odd
/even_odd.py
455
4.15625
4
class EvenOdd(): def even_odd(): while True: data = input('please insert real number.its chek even or odd numbers:') try: int(data) if int(data) % 2 == 0: print("%s is even number" % data) else: ...
true
bfb4abea1a78246a98881379568a6d1b00cf675e
BoomerPython/Week_2
/week2Functions.py
697
4.15625
4
# Week 2 - Functions # This script provides two simple functions # The first function accepts a number and prints # out the OU cheer that number of times def functionBoomer(n): for i in range(n): print("Boomer") print("Sooner") # Notice there is not a return on this function #...
true
8202b22b3e90f3c1fc272ac277ad811ffe7672e1
Eclipsess/LintCode
/BinaryTree/469. Same Tree.py
1,513
4.28125
4
# Check if two binary trees are identical. Identical means the two binary trees have the same structure and every identical position has the same value. # # Example # Example 1: # # Input:{1,2,2,4},{1,2,2,4} # Output:true # Explanation: # 1 1 # / \ / \ # 2 2 an...
true
878e2fa2c5b551dd5f7c1aa4315844eb22f3ed26
NikithaJohnsiraniVenkatesan/BinarySearchTree
/Binary Search Tree/Perform_BST_serach.py
604
4.1875
4
#How do you perform a binary search in a given array? #In recursive way def binary_search(arr, low, high, x): if high >= low: mid = (high+low) //2 if arr[mid] == x: return mid elif arr[mid] > x: return binary_search(arr, low, mid-1, x) else: ...
true
ddb4b795aab60a2987cdad4e5b243a71f8bb17ec
raaes0123/Using-Python-to-Access-Web-Data
/4. Programs that Surf the Web/Following_Links_in_HTML.py
2,053
4.125
4
# To run this, you can install BeautifulSoup # https://pypi.python.org/pypi/beautifulsoup4 # Or download the file # http://www.py4e.com/code3/bs4.zip # and unzip it in the same directory as this file ''' Following Links in Python In this assignment you will write a Python program that expands on https://www.py4e.com...
true
ec9bb0510e804bb1e1912ce2004991b320a3b15f
Icyscools/the-internship-2020
/floating_prime.py
1,011
4.125
4
""" Floating Prime Author: Woramat Ngamkham """ prime_number = [] # Memo for collect prime number to decrease compute time def floating_prime(num): ''' Seperate 1-5 first digit and check is prime ''' if (num >= 1 and num <= 10): num = int(num * 1000) checking_num = [num // 1000, num // 100, ...
true
04c8d21c9f05b921809cd23a7d62938680f7294a
dheerajgopi/think-python
/Chapter8/rotencryption.py
604
4.1875
4
# code for encrypting a word by rotating each letter by n times def rotn(word,n): rotword = '' # initialising empty string for result for letter in word: rotletter = ord(letter)+n # converting each letter into numeric code and adding it with n if rotletter > 122: # for cyc...
true
29df56b32db2b932d21e2728a60de10184b48764
dheerajgopi/think-python
/Chapter9/abecedarian.py
398
4.21875
4
# checks if each letter in a word is in alphabetical order def is_abecedarian(word): prvalpbt = 'a' # initialising a variable for checking with previous alphabet for letter in word: # for loop for comparing each letter with the previous alphabet if letter < prvalpbt: return False ...
true
bd8580bd6ec4f9183e43421b77e02e4308c9a7bf
dheerajgopi/think-python
/Chapter12/sortby_length.py
588
4.1875
4
# for sorting a list according to the length of its elements. elements of same length are sorted randomly import random def sort_by_length(words): t=[] # creating a list 't' with tuples elements.tuple consist of length, random number and word for word in words: t.append((len(word),random.random(),word)) # s...
true
3d6dc5e4fd1eb537c06429fae63455dd35e872fa
SubhradeepSS/dsa
/String/myatoi(special cases).py
2,079
4.15625
4
""" Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and inte...
true
d78118a45059ab294d0350871d5ed245d772ed04
SubhradeepSS/dsa
/Math/Fraction to Recurring Decimal.py
1,478
4.125
4
""" Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses. Example 1: Input: numerator = 1, denominator = 2 Output: "0.5" Example 2: Input: numerator = 2, denominator = 1 Output...
true
64e6a48f58e86e6b853210a9435bcd5137a4aa0e
nithinkoneri/hello-world
/helloWorld.py
366
4.15625
4
# This program says hello and asks for name. print('Hello World!') print('Whats your name?') myName = input() print('It is good to meet you '+myName+'.' ) print('Length of your name is : '+ str((len(myName)))) # print(len(myName)) print('Whats your age?') myAge = input() # print(myAge) print('You will...
true
aa1d2693a817ec03826f9ea4a7e325c7999b7fb9
odavila/git-dir_repo
/Assign1.py
701
4.53125
5
# Create a small python3 program that convert temperature def main(): '''Ask the user to input a number in Fahrenheit and convert it to Celsius and print both on the screen ''' # Set Celsius count to zero cel = 0 # Welcome user to temperature convert program print("\nWelcome to the temperature convert progra...
true
4e55ec0783e13628e0eff47ac3e2bc7158fe7030
aziaziazi/Udacity-ITPN
/Stage2_madlibs_game Python/2.7.2 How to Solve Problems - Days Between.py
2,759
4.375
4
# Define a daysBetweenDates procedure that would produce the # correct output if there was a correct nextDay procedure. # # Note that this will NOT produce correct outputs yet, since # our nextDay procedure assumes all months have 30 days # (hence a year is 360 days, instead of 365). # def nextDay(year, month, day): ...
true
e9b5bab091456b09e03cf42d3b3a7ff97e7e603b
aziaziazi/Udacity-ITPN
/Stage3_Use_other_people_code/3.4b_Make_inherited_Classes/# Lesson 3.4: Make Classes.py
1,200
4.90625
5
# Lesson 3.4: Make Classes # Mini-Project: Draw Turtles # Sometimes we want to define classes that may have similarities. # For example, a TVShow class and a Movie class would both have a title attribute. # To cut down on repitition we can have classes inherit from each other. # So in our example we could have both TV...
true
12808a10d6f4b0684ceb6801735acdb4212eb20f
aziaziazi/Udacity-ITPN
/Stage4/4.6.1_Validation/what_is_your_birthday/valid_day.py
1,358
4.46875
4
# ----------- # User Instructions # # Modify the valid_day() function to verify # whether the string a user enters is a valid # day. The valid_day() function takes as # input a String, and returns either a valid # Int or None. If the passed in String is # not a valid day, return None. # If it is a valid day, then retur...
true
417894a0abc6c6150514f12f1c39fc1fbe0f2319
StephenArg/Algorithm_Practice_Python
/buildPalindrome.py
813
4.25
4
from custom_functions.is_palindrome import palindrome def buildPalindrome(st): index = 1 final = st while not palindrome(final): suffix = st[0:index] final = st + suffix[::-1] index += 1 return final print(buildPalindrome("abc")) # https://app.codesignal.com/arcade/intro/lev...
true
e1772c8bb902e869285889e16bdc0a329e8d1d76
Rocker775/Osnove
/main.py
373
4.21875
4
mood = input("What's your mood? ") if mood == "sad" or mood == "angry": reason = input("Why are you {0}".format(mood)) if reason == "corona": print("It will pass some day, don't worry") else: print("Please don't be " + mood) elif mood == "happy": print("I'm happy that you are {0}".format...
true
b6b19f65f8d5f7b4e399dda2ad390b9f4cca79d9
eduardo-bau/practice_python
/P6_string_lists.py
335
4.28125
4
def run(): print("""This program will tell you if the string you enter is either a palindrome or not""") word = input("Please enter a string: ").replace(" ", "") reverse = word[::-1] if word == reverse: print("is palindrome") else: print("is not a palindrome") if __name__ == "__mai...
true
5ed75374af932fa99723deb56e10a00997f2a07a
jorge-gx/teaching-python
/shortrecap/listsanddicts.py
2,767
4.625
5
# quick python overview # ############################## # string # ############################## my_name = "Python" # s = f"I'm learning {my_name}" # print(s) # ############################## # list # ############################## # defining a list named: departments # and initializing it with three elements # a ...
true
50da38a6bbb8049dd8311bf88c60fb1bca59fc08
IvanStankov/python-first
/com/ivan/firstpython/classes/basics.py
1,027
4.28125
4
class Student: age = 18 # class variable shared by all instances # constructor def __init__(self, name): self.__name = name self.age = 12 # class attributes can be referenced via self def get_name(self): return self.__name def get_upper_name(self): return self.get...
true
cf59df5ec12e9df05a68f9fb40d55b9f3cc23d52
kristyd43/She_Codes_Python
/conditional_playground.py
1,281
4.21875
4
#is_raining = False #is_cold = True #print(is_raining) #print(type(is_raining)) #print(is_cold) #print(type(is_cold)) #print(is_raining) #print(not is_raining) #print(is_raining and is_cold) #print(is_raining and not is_cold) #print(is_raining) #F #print(not is_raining) #T #print(is_raining or is_cold) #T #print(is_...
true
c9821ca7d8d9ff6e6bdff84a6161d2d96e3b769c
kristyd43/She_Codes_Python
/loops/for_loops_playground.py
1,451
4.34375
4
#Loops - repetitive tasks #Loop - for loops, while loops #For loops - know how many times to repeat a task #While llops - don't know how many times to repeat #For Loops - sequence, strings, lists, dictionaries #a = [1, 2, 3, 4] #print(a[1:4]) #for num in range(1, 11): #iterate through sequence of numbers # print(...
true
76f589bddfb970f4672d16c5f716a37870b5b33d
Nekose/Codewars
/src/rot13.py
996
4.625
5
""" ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher. Create a function that takes a string and returns the string ciphered with Rot13. If there are numbers or special characters included in the string, the...
true
bb2b039b9751d7c8bba8924d6b0ebd4c28b17cd1
ediprekpalaj/rockpaperscissorspy
/game.py
1,584
4.53125
5
#import the package for simulating comp choices import random while True: #take input from the user and assign it to a var based on the respective choice user_choice = input("Enter a choice from either: rock, paper and scissors. ") #make the computer select a random choice between the actions ...
true
9e31f4b902889ff4ee9825fd96328340608cb8d8
NeuroDataDesign/TeamEEG
/Aamna/Dictionaries and Sets.py
1,802
4.625
5
# understanding dictionaries-unordered, access by key fruits={"Apple":"Red, round ,and crunchy", "Pear":"Juicy and odd-shaped", "Grape":"Green, round, juicy", "Banana": "Yellow and a good source of potassium"} # appending new elements to the fruit dictionary fruits["Mango"]="Yellow, juicy and yummy" print(fruits) ...
true
2a7948e55c7191f434bfa52ee0f4019d011461e7
kevinlee05/python-snippets
/concurrency/multiprocessing/multiprocessing_queue.py
878
4.28125
4
# demonstration of using a normal queue vs multiprocessing queue with Processes import multiprocessing import queue result = [] def calc_square(numbers, q): for n in numbers: q.put(n*n) #add n*n to the queue if __name__ == '__main__': numbers = [2,3,5] q1 = queue.Queue() #normal queue q2 = m...
true
cc6ee9406ab325f7941226389be2c27993e2eddd
karenwsit/ToyProblems
/trees_and_graphs/friends.py
2,535
4.25
4
"""Find whether two people in an undirected graph are friends. """ class PersonNode(object): """A node in a graph representing a person. This is created with a name and, optionally, a list of adjacent nodes. """ def __init__(self, name, adjacent=[]): self.name = name self.adjacent = s...
true
b8e24e537f5fe0266a327fb3146c9a82088b3c79
karenwsit/ToyProblems
/recursion/redbluebluered.py
1,173
4.4375
4
""" You are given a pattern, such as [a b a b]. You are also given a string, example "redblueredblue". A few examples: Pattern: [a b b a] String: catdogdogcat returns 1 Pattern: [a b a b] String: redblueredblue returns 1 Pattern: [a b b a] String: redblueredblue returns 0 http://stackoverflow.com/questions/26702757/ch...
true
fb5e8bc8d0cc689a36831e26f819f2985eba8152
karenwsit/ToyProblems
/strings_arrays/is_unique_str.py
1,710
4.25
4
#Exercise 1.1 of Cracking the Coding Interview #Implement an algorithm to determine if a string has all unique characters ################################################################################# # Time: O(n) # Space: O(n) def is_unique(string): """ >>> is_unique("tornado") Fals...
true
17094124907471511d1f68f992706020c3e16d2b
lauragodzwon/Pirple---Python
/Topic_6.py
931
4.125
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 13 15:15:42 2021 @author: User """ def Guess(): print("You can guess Genre, Artist, Title, Year_of_release,\ DurationSeconds or DurationMinutes, Album or Producer") Value = input("Which value would you like to guess? \ ...
true
0ac01d0c933d49ecfbac5b0fec21fc71c0c16806
bjartur20/5_Algorithms_and_git
/sequence.py
631
4.40625
4
''' The sequance is defined as the sum of the last three numbers 1. Input from the user which decides how many numbers in the sequance should be printed. 2. Give ourselves the first three numbers (1, 2, 3) 3. Find the next numbers the user asked for by swapping old numbers for the new numbers. 4. Print the numbers. ''...
true
61d47f6701da551dce7fec3260a37b845b341704
jose-zanetti/PythonTutorial
/LessonOne/FrontBack.py
1,053
4.28125
4
# Consider dividing a string into two halves. # If the length is even, the front and back halves are the same length. # If the length is odd, we'll say that the extra char goes in the front half. # e.g. 'abcde', the front half is 'abc', the back half 'de'. # Given 2 strings, a and b, return a string of the form # ...
true
af6ac62463c9f64875b7df150dde18bb49454823
jchenwth101/add_matrix
/a1_p3_matrix_add.py
975
4.40625
4
# Course: CS261 - Data Structures # Student Name: Joel Chenoweth # Assignment: 1 Adding Matrices # Description: A Matrix is values within ordered rows and columns. This function adds them together. def matrix_add(x,y) -> [[]]: """ This function takes in two lists as arguments. It iterates through the rows a...
true
c48d570e8b5c4d36efc7b575e4c0f03d32ee48a3
Sanjay2486/Python
/Dictionary.py
574
4.40625
4
# Dictionaries: # It is used to collect unorderd data. # unline list, dictioraries keeps the data in order by using "key:value" pairing #Example: create a dictionary to store user profile User_Profile = { "Name":"Sanju", "Age" : 25, "Address": "Bangalore", ...
true
78648d1430e759dfab13d2912a90cd4fde35a132
Sanjay2486/Python
/NestedIf_Test.py
795
4.21875
4
#********************* Nested IF Statement Test********************************** # Number guessing Game # Make a variable, like winning_number and assign any number to it. # Ask user to guess a number # if user guessed correctly then print "You Win!!!" # if user did not guessed correctly the : # if user ...
true
8907a2b8d740da7536daa2bf0b8edfbb718931d4
Sanjay2486/Python
/In_Statement.py
248
4.28125
4
#IN Statement : is used to check the character in a given string Name = "Sanju" #now suppose you want to check if character a is present in name variable value or not if "a" in Name: print("Present") else: print("Not Present")
true
c78d3aa82781ac8052f294c695ca16ba778d9505
Sanjay2486/Python
/Converting_tuple_To_List.py
467
4.25
4
#How to convert tuple to list: #create simple tuple of range from 1 to 10 number = tuple(range(1,11)) print(number) #now convert number tuple to list number1 = list(number) print(number1) #How to convert tuple to string number2 = tuple(range(1,11)) print(number2) #now convert number tuple to list num...
true
00c634740f0fa617d763fc9b7ed95345d0384d8c
Sanjay2486/Python
/For_Loop.py
379
4.1875
4
#For Loop with range functions for i in range(10): print("Hello World") # #suppose my range value starts with 5 and ends with 10 , then for i in range(5,10): print("Hello World") #Break for i in range(1,11): if i==5: break print(i) #Conitue for i in range(1,11): if i==5: ...
true
f9835b61f9f44ea809e9577fa3db8b28ba16aeb0
hvitserk/python
/numberguess.py
1,020
4.15625
4
# A Simple Number Guessing Game #!/usr/bin/python import random import time print("Welcome to the Simple Number Guess Game!") def get_user_guess(): user_guess = int(raw_input("Guess a number: ")) return user_guess def roll_dice(number_of_sides): first_roll = random.randint(1, number_of_sides) second_roll = ra...
true
6eae57f3018691fffe520dd96f7c3e0ed47f7d7f
powder-river/duke-code
/time_converters/time_convert.py
326
4.1875
4
import time # 2. Given an integer that represents a time measured in the number of seconds since Epoch, # print out a human readable timestamp (e.g. MM/DD/YYYY HH:mm:ss). epoch_time = input("enter epoch time: \n") new_time = time.strftime("Date: %b-%e-%Y \nTime: %H:%M:%S", time.localtime(epoch_time)) print(new_...
true