blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4329aba5655951eb7fb55d40cbfdd6e9db886e9e
christine-w/sandbox-algorithms
/mergeSort.py
2,431
4.1875
4
# mergeSort.py # input: an array of integers # output: array of integers sorted in ascending order # # merge sort has a running time of O(nlogn) def mergeSort(arr): """Sort arr using merge sort""" if len(arr) == 1: #print('BASE CASE REACHED') return arr midpoint = len(arr)//2 left =...
true
64664183cc005fff060f6a575f198e01770fe04e
Pmcg1/PandS_2019_Problems
/Problem2.py
536
4.25
4
# Problem Set 2019 - Problem 2 # Peter McGowan # Started 2019-02-01 # Write a program that outputs whether or not today is a day that begins with the letter T. # Import datetime module import datetime as dt # Generate current date and time now = dt.datetime.now() # Extract Day from datetime as a string Day = now.st...
true
2c108674f174575265d41cd94ecbed65a68f5469
alfaceor/programming-examples
/python/lambda_example.py
453
4.15625
4
#!/usr/bin/python def f (x) : return x**2 print f(8) # ONE LINE ANONYMOUS FUNCTION g = lambda x: x**2 print g(8) f2 = lambda x, y : x+y print f2(1,2) print f2(7,-3) # FILTER EXAMPLE XX = range(9) print XX def isEven(x): if x %2 == 0: return True else: return False XFIL = filter(isEven, XX) print XFIL ...
true
da8f70434c97d8691e5370670351e03a2250844a
marisbotero/Python_I
/baby_game.py
1,846
4.125
4
# -*- coding: utf-8 -*- """ Created on Sun May 15 17:37:46 2022 @author: marisb """ import turtle import random import time # Setting up a nice screen for our game! screen = turtle.Screen() screen.bgcolor('lightblue') # Background a lightblue colour # We want two players in this game and the idea is t...
true
ae1ac97276794106cd22df948f060f3a6f126546
anryangelov/hackbg_programming101
/week02/food_diary.py
1,270
4.3125
4
import datetime filename = 'food_diary.txt' message = '''\ Choose an option. 1. meal - to write what are you eating now. 2. list <dd.mm.yyyy> - lists all the meals that you ate that day, ''' def add_food(food): today = datetime.date.today() today_str = "{}.{}.{}".format(today.day, today.month, today.year) ...
true
8897158f2049d5a218545b2269feb3add40dc79b
elrossco2/LearnPython
/CH5/HW/spencerj/Ex3.py
532
4.1875
4
def main(): grade = input("Enter the score of the test: ") if (eval(grade) >= 90): print("The grade for this test is an A") elif (eval(grade) >= 80 and eval(grade) <= 89): print("The grade for this test is a B") elif (eval(grade) >= 70 and eval(grade) <= 79): print("The grade fo...
true
151b2d4d235e4b897fe8e2c4157c860c292906a2
elrossco2/LearnPython
/CH7/HW/spencerj/Ex3.py
459
4.125
4
def main(): grade = eval(input("Please input the number grade: ")) #print(grade) if grade >= 90: print("The letter grade is an 'A'") elif grade >= 80 and grade < 90: print("The letter grade is a 'B'") elif grade >= 70 and grade < 80: print("The letter grade is a 'C'") eli...
true
9c3942cb6258ad506eab040ba554b142302352ae
elrossco2/LearnPython
/CH4/HW/spencerj/Exercise6.py
1,760
4.25
4
# futval_graph.py from graphics import * def main(): # Introduction print("This program plots the growth of a 10-year investment.") # Create a graphics window with labels on left edge win = GraphWin("Investment Growth Chart", 400, 300) win.setBackground("white") Text(Point(20, 230), ' 0.0...
true
f976ac0897ffa0ae06aeec6cebd9160b0f87599b
janae01/independent-class-work
/mean.py
1,899
4.5
4
# Name: Janae Dorsey # File: mean.py # # Problem/Purpose: This program will calculate the RMS Average, the Harmonic Mean, and the Geometric Mean of a specified group of numbers. # # Certification of Authenticity: # I certify that this lab is entirely my own work. # # Inputs: The number of values and the values themselv...
true
caafbc531ac49044cdcbf090fe015a31c4a99d55
zhanghang1995/DeepLearningStudy
/venv/chapter01BasicFunctionWithNumpy/normalizngRows.py
1,166
4.75
5
# -*-coding: utf-8-*- """ It often leads to a better performance because gradient descent converges faster after normalization. Here, by normalization we mean changing x to x∥x∥ (dividing each row vector of x by its norm). Exercise: Implement normalizeRows() to normalize the rows of a matrix. After applying this ...
true
d0e9ad4cc1010432a520964ea372d03639d2a1a1
jessicapolansky/piethon
/ex6.py
702
4.15625
4
# Variables containing strings that comprise a bad joke x = "There are %d types of people." % 10 binary = "binary" do_not = "don't" y = "Those who know %s and those who %s." % (binary, do_not) # print bad joke print x + y print y #print joke again, with additional text in the string print "I said: %r" % x print "I also...
true
7b3f8166ed4c87d8be2486f6494bca9126f86f16
Yashreddy1/coderspackpython
/codefilext.py
538
4.3125
4
mydict={ "c":"C", "class":"Java", "cpp" : "C++" , ".cs" :"Visual C" , "h" : "C, C++, and Objective-C header file" , "jav": "Java Source code file" , "pl" : "Perl script file" , "sh": "Bash shell script" , "swift": "Swift" , "vb": "Visual Basic file" , "py":"python" } file=input("enter the file name with ex...
true
dedaa3500031dcc2abd9b15c0b15d4864bc61b06
ScriptGeek/DailyCodeProblems
/DailyCodeProblemsApplication/CodeProblems/is_palindrome_integer.py
1,022
4.53125
5
''' Good morning! Here's your coding interview problem for today. This problem was asked by Palantir. Write a program that checks whether an integer is a palindrome. For example, 121 is a palindrome, as well as 888. 678 is not a palindrome. Do not convert the integer into a string. Upgrade to premium and get in-dept...
true
2253876c13b45b5eb5b1f652d1d0e16253019031
Supriyapandhre/Test-Repository
/OOPS_concepts/class_and_object.py
676
4.1875
4
class A: def method1(self): print("We are in class A and Method1") def method2(self): print("We are in class A and Method2") # create a object obj1 = A() obj1.method1() obj1.method2() ############################################ class B: # constructor of the class def __init__(sqa, ...
true
1e3c52e0fedf58294a0e06d3ae96ef52146bb1f8
dragosnechita/python_learning
/head_first.py
730
4.125
4
import nested_list movies = ["The Holy Grail", 1975, "Terry Jones & Terry Gilliam", 91, ["Graham Chapman", ["Michael Palin", "John Cleese", "Terry Gilliam", "Eric Idle", "Terry Jones"]]] nested_list.print_lol(movies, True, 0) # indented for loops # for each_item in movies: # if isinstance(each_item, list): # ...
true
1eba802d77c96ecbc0c325ef5fb1469955129dd2
marka2/Python_Exercises
/user_input.py
795
4.40625
4
""" ************************************************ Author: Mark Arakaki October 15, 2017 Personal Practice Use ************************************************ This program asks the user to enter their name and their age. Then the program will print out a message addressed to them that tell them the year they w...
true
a398b13e6f88a70bec40b007228369cfe0556a88
superpigBB/Happy-Coding
/Algorithm/Sum of Two Integers.py
963
4.15625
4
# Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. # # Example: # Given a = 1 and b = 2, return 3. # # Credits: # Special thanks to @fujiaozhu for adding this problem and creating all test cases. ### Original Method: ### This should be basic knowledge of how to transform ...
true
8747ecbeadc448d13315289b707f46d388ce4cb3
superpigBB/Happy-Coding
/Algorithm/Reverse Integer.py
2,602
4.15625
4
# Given a 32-bit signed integer, reverse digits of an integer. # # Example 1: # # Input: 123 # Output: 321 # Example 2: # # Input: -123 # Output: -321 # Example 3: # # Input: 120 # Output: 21 # Note: # Assume we are dealing with an environment which could only hold integers within the 32-bit signed integer range. # Fo...
true
b0842a2968d3ac54ab980238d4fc44863c43fb34
hnadimint/PythonAdvanced_Programing
/Restaurants.py
1,218
4.375
4
#Make a class called Restaurant. The __init__() method for Restaurant should store two attributes: a restaurant_name and a cuisine_type. Make a method called describe_restaurant() that prints these two pieces of information, and a method called open_restaurant() that prints a message indicating that the restaurant is o...
true
147ba6bb0fd1ec4c02f3ea00181eded02943370d
MeetLuck/works
/thinkpython/chapter16/ex6.py
1,945
4.125
4
from classfunc import int_to_time, time_to_int from classfunc import Time #--------- exercise 6 ---------------- def mul_time(time, factor): seconds = time_to_int(time) seconds *= factor return int_to_time(seconds) #--------- exercise 7 ---------------- # 1. prints the day of the week # 2. input: a birth...
true
bf7f3209cb76857144b24db17836b46c62d286e9
ErickRosete/algorithms-python
/sliding_window/p2_subarray_max.py
891
4.28125
4
""" Given an array of positive numbers and a positive number ‘k,’ find the maximum sum of any contiguous subarray of size ‘k’. Example 1 Input: [2, 1, 5, 1, 3, 2], k=3 Output: 9 Explanation: Subarray with maximum sum is [5, 1, 3]. Example 2 Input: [2, 3, 4, 1, 5], k=2 Output: 7 Explanation: Subarray with maximum su...
true
9065899e8cdf6d5c27697abf74e56a026f4b7bde
ErickRosete/algorithms-python
/sliding_window/p3_smallest_subarray_greater_sum.py
2,051
4.1875
4
""" Smallest Subarray with a Greater Sum (easy) Problem Statement Given an array of positive numbers and a positive number ‘S,’ find the length of the smallest contiguous subarray whose sum is greater than or equal to ‘S’. Return 0 if no such subarray exists. Example 1: Input: [2, 1, 5, 2, 3, 2], S=7 Output: 2 Ex...
true
2260cee80a3a2ef9e06b9dc9da71ade495c769ec
iamlmn/PyDS
/algos/patterns/twoPointers/backSpacesString.py
2,106
4.40625
4
# Given two strings containing backspaces (identified by the character ‘#’), check if the two strings are equal. # Example 1: # Input: str1="xy#z", str2="xzz#" # Output: true # Explanation: After applying backspaces the strings become "xz" and "xz" respectively. # Example 2: # Input: str1="xy#z", str2="xyz#" # Outpu...
true
98967dbaaf06068820026441f77758427f3f30c1
iamlmn/PyDS
/algos/patterns/slidingWindows/noRepeatSubstring.py
1,143
4.28125
4
# Given a string, find the length of the longest substring which has no repeating characters. # Example 1: # Input: String="aabccbb" # Output: 3 # Explanation: The longest substring without any repeating characters is "abc". # Example 2: # Input: String="abbbb" # Output: 2 # Explanation: The longest substring withou...
true
1df6f0207ed634200d98435f2e48a2c3e9d19410
iamlmn/PyDS
/algos/patterns/slowFastPointers/isPalindrome.py
1,791
4.1875
4
# Given the head of a Singly LinkedList, write a method to check if the LinkedList is a palindrome or not. # Your algorithm should use constant space and the input LinkedList should be in the original form once the algorithm is finished. The algorithm should have O(N)O(N) time complexity where ‘N’ is the number of nod...
true
c35ff6919e84c364617032a4ecafb569ef66a026
iamlmn/PyDS
/algos/patterns/slidingWindows/wordsConcatenation.py
2,720
4.125
4
# Words Concatenation (hard) # # Given a string and a list of words, find all the starting indices of substrings in the # given string that are a concatenation of all the given words exactly once without any # overlapping of words. It is given that all words are of the same length. # Example 1: # Input: String="cat...
true
cb8f1bfe3f0d3150ade5d50a077ace1f79355615
iamlmn/PyDS
/algos/patterns/BFS/connect_level_order_siblings.py
1,580
4.15625
4
# Given a binary tree, connect each node with its level order successor. # The last node of each level should point to a null node. from collections import deque class TreeNode: def __init__(self, val): self.val = val self.left, self.right, self.next = None, None, None def print_level_order...
true
f1cb6b62b5bbd20f30ca5353f4bc9f9482cafdd5
jackgonzalesdev/beginner_programs
/test1.py
250
4.15625
4
''' Created on Sep 28, 2018 @author: jgonzales ''' word = str(input('escribe una letra: ')) letters = [] for letter in word: letters.insert(0, letter) print(letters) print(letters) reversed_letter = ''.join(letters) print(reversed_letter)
true
653ce6708efac87ce25f2b7cbe72f75779a317ae
Yousufakhan95/learning-python
/lessons/getting_user_input.py
729
4.40625
4
# this is the input function so the user can in put something # btw this will not do any thing because your not storing the the input input() #this is going print out the prompt then the user '''input("enter your name: ")''' #this is going to ask fotr your name then store it in name name = input("please enter your ...
true
789bf5e6d90950c4725ad662657d0d261016bb78
Hamiltonxx/pyalgorithms
/algorithmic_thinking_puzzles/练习/first_repeat.py
427
4.1875
4
def find_first_repeated_element(arr): seen = set() for element in arr: if element in seen: return element seen.add(element) return None # No repeated element found # Example usage arr = [3, 2, 1, 2, 2, 3] first_repeated = find_first_repeated_element(arr) if first_repeated is ...
true
60fb0a721167743fe11ffb3fa49ce180a4045a20
balakrishnan-vasudevan/PythonCode
/quicksort.py
395
4.1875
4
def quicksort(arr): if len(arr) <= 1: return arr else: return quicksort([x for x in arr[1:] if x<arr[0]]) + [arr[0]] + quicksort([x for x in arr[1:] if x>=arr[0]]) num_array = list() num = input("Enter the number of elements in the array \n") print ('Enter the elements of the array \n') for i in range(int(num))...
true
39fd463e90342c1ef8ab41e9c42c452575e55ce1
RussellRC/MachineLearningPlayground
/sleep_grades_regression.py
1,988
4.25
4
# # # Regression and Classification programming exercises # # # # In this exercise we will be taking a small data set and computing a linear function # that fits it, by hand. # # the data set import numpy as np sleep = [5,6,7,8,10] scores = [65,51,75,75,86] def compute_regression(sleep,scores): ...
true
8fcd2bea533f3de6f0a1c95c79f09b33b4c06b52
yamarane/pystuff
/reverse_word_order.py
350
4.4375
4
# python3 # this program takes a line from user and gives back in reverse order. user_input = input("please enter a line: ") def reverse_word_order(user_input_line): split_line = user_input_line.split() result = [] for word in split_line: result.insert(0, word) return " ".join(result) print(re...
true
5e66a7d558767ef3a04b95ad687334bb00764dab
Shubham-tiwari123/Data-structures-using-Python
/queue.py
659
4.125
4
MyQueue = [] class Queue: def DisplayQueue(self): print("queue currently contains:") for Item in MyQueue: print(Item) def Push(self,Value): if len(MyQueue) < num: MyQueue.append(Value) else: print("queue is full!") def Pop(self): i...
true
2f4a16ac41de7e8d516fe9817a3dde9aa84aa663
mfislam007/python
/python2/3.7-Dictionaries.py
555
4.15625
4
# Dictionaries # Initializing the dictionary details = {'Title':'Dr','Given name':'Steven','Middle name':'Lawrence','Surname':'Fernandes','Age': 30} # Printing the content of the dictionary print details['Title'] print details['Given name'] print details['Middle name'] print details['Surname'] print details['Age'] ...
true
5c1108ebc5a4cb0bc4c3ea380b9cf4c1ed9e02a0
D-S-Grafius/Python-Repository
/lab1C.py
322
4.28125
4
#Dylan Grafius 1/12/2018 #CSC131-005 #Purpose: The goal of thie program is to ask the user to provide a integer base and an integer exponent. Then it will display the the base raised to that exponent. number= int(input("What base?")) a= int(input("What power?")) b= (number**a) print(number,"raised to the power of",a...
true
194edb690175c2e1b538a4f8c942f252e52abfee
sahilchaudhary911/Daily1
/6.py
806
4.40625
4
""" Write a program that asks the user for a number n and gives them the possibility to choose between computing the sum and computing the product of 1,…,n. """ def computing_sum_or_product_of_n_nums(): n_number = int(input("Enter a number n of natural number: ")) yes_or_no = input(f"Press '0' to add natural ...
true
a560bc80514c82e82ae662ad45f94a69f2492376
dillonkooncey/Projects
/Python Tutorial/Variables.py
503
4.375
4
character_name = "john" character_age = "35" print("There was once a man named " + character_name + ", ") print("He was " + character_age + " years old.") print("He really liked the name " + character_name + " , ") print("But he didn't like being " + character_age + ".") # Can use same name for variable. Will go line...
true
5f8b097a7cf1ea1f75194399aff529a7dd2ab519
sudarshanchimariya/python
/Data Types/Q16.py
347
4.15625
4
#l = [2, 3, 4, 5, -6] # l is list. #total = sum(l) #print("Sum of items in the list:", total) list1 = [] num = int(input("Enter number of items in the list: ")) for i in range(0, num + 1): x = int(input("Enter items(number): ")) # x refers items or elements in the list. list1.append(x) print("Sum of items ...
true
31264a8318fa92d19fcb8a78ef67ddc014a187b2
clevercoderjoy/python_practice_questions
/sort_0_1.py
1,525
4.1875
4
# Sort 0 1 # You have been given an integer array/list(ARR) of size N that contains only integers, 0 and 1. # Write a function to sort this array/list. # Think of a solution which scans the array/list only once and don't require use of an extra array/list. # Note: # You need to change in the given array/list itself. H...
true
75c7899745dbff2f210baecaab882b160aa4fab3
clevercoderjoy/python_practice_questions
/sort012.py
1,827
4.25
4
# Sort 0 1 2 # You are given an integer array/list(ARR) of size N. It contains only 0s, 1s and 2s. # Write a solution to sort this array/list in a 'single scan'. # 'Single Scan' refers to iterating over the array/list just once or to put it. # In other words, you will be visiting each element in the array/list just on...
true
f28e359847615330d606afa19a21483e75413db7
clevercoderjoy/python_practice_questions
/hourglass_pattern.py
1,113
4.5
4
# * * * * * * # * * * * * # * * * * # * * * # * * # * # * * # * * * # * * * * # * * * * * # * * * * * * #to take the number of columns as an input from the user n=int(input()) #upper half of the hourglass pattern #loop for rows in the upper half of the hourglass pattern for i in range(1,n+1):...
true
af3ee4b858ce473f97bbaddc356baa4040aae32d
KareliaConsolidated/Data-Structures-and-Algorithms
/45_Practice/37_Sorting_Merge_Sort.py
1,514
4.34375
4
# Merging Arrays Pseudocode # Create an Empty Array, Take a Look at the Smallest Values in Each Input Array. # While there are still values we haven't looked at.. # If the value in the first array is smaller than the value in the second array, push the value in the first array into our results and move on the next val...
true
160536da9d49b6c58407c76b96cbaddddabbe2f0
KareliaConsolidated/Data-Structures-and-Algorithms
/45_Practice/27_Challenge_Recursion_Fib_04.py
1,053
4.125
4
# Write a recursive function called flatten which accepts an array of arrays and returns a new array with all values flattened. ################## METHOD # 01 ################## def flatten(arr): if len(arr) == 0: return arr if isinstance(arr[0], list): return flatten(arr[0]) + flatten(arr[1:]) return arr[:1] +...
true
4bb3743fb03a92a62476ba5199e070e651bd775b
KareliaConsolidated/Data-Structures-and-Algorithms
/47_Practice/20_Recursion_isPalindrome/isPalindrome.py
410
4.1875
4
# Write a recursive function called isPalindrome which returns true if the string passed to it is a palindrome (reads the same forward and backward). Otherwise it returns False def isPalindrome(string): if len(string) == 0: return False if len(string) == 1: return True if len(string) == 2: return string[0] == string...
true
033890dcdfe1167b8c79741ee2e68a06d7a502e3
SXL5519/Python-Study
/PythonBasic/Basic/exception.py
1,322
4.1875
4
# 捕获指定异常 def catch_specific_exception(): try: f = open("blala", 'r') except FileNotFoundError as e: print(e) print("could not open the file") try: 1 / 0 except ZeroDivisionError as e: print("There is something wrong with Division,reason:{0}".format(e)) # 捕获多个异常...
true
2dfbc0fe3f74a83f641be24401c7e432647764f3
huynguyen120390/DataStructureProjects
/HashTable/FirstRecurrentPython.py
1,356
4.1875
4
""" Return a number which has 1st recurrent in an array Eg: [2,5,1,2,3,5,1,2,4] => return 2 @args: arr[list] the array under search @return: num[int] the number with first recurrent """ arr = [2,5,1,2,3,5,1,2,4] arr2 = [2,1,1,2,3,5,1,2,4] arr3 = [2,3,4,5] arr4 = [] arr5 = None def find_num_with_firstRe...
true
5df12b55f8c1a4e7f1cb358c45a68e5dff0a3b9d
thecozysweaters/interview-prep
/basics/mergeSort.py
644
4.125
4
def merge(A, B): ''' Given two sorted arrays, A and B, return a single sorted array of all the elements in both A and B ''' C = [] while len(A) > 0 and len(B) > 0: if A[0] <= B[0]: C.append(A.pop(0)) else: C.append(B.pop(0)) if len(A) > 0: C = C + A ...
true
f5b9e72a4bc7a952f4768e264d21d1bbd079e111
johnjdailey/wf-2020-11-15
/week3/day1/intro.py
823
4.125
4
# Python Intro # How to run code # python shell # run the file print('Hello Python!') # Differences from JS # Code blocks # if () {} something = 'some value' if something == something: print('something') # Strings and formatting (fstring) name = 'Python' print('hello, ' + name) print('hello, {name}'.format(name=n...
true
94afd9711fe567c80fa7cf1f7aa0462e1883a729
data-pirate/Data-structures-in-python
/P0/Task3.py
2,555
4.1875
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 3: (080) is the area code for fixe...
true
a0a3e8061befc5b25058b11e8ae7ece8b13fd3ec
BrokenChef/Python-help
/printRandomNumbers.py
553
4.1875
4
# printRandomNumbers.py # This program collects info from the user than prints out a designated amount of random numbers from the designated range # Darren Gilbert import random print('Enter the number of random numbers to be printed: ') n = input() print('Enter the number you want to use for the lower limit of the r...
true
cb6edc69e832a97cea266450521b48bde87c252a
jamescarson3/tmp
/python_intro/python_examples/8_loop.py
518
4.1875
4
# range( ) creates a list of integers starting at 0 print range( 10 ) print "" # 'for' sets a variable to each value in a list for x in range( 5 ): print "x = " + str(x) print "" # 'while' will repeat as long as its condition is True x = 5 while x > 0: print "x = " + str(x) x = x - 1 print "" # Putting...
true
b06cc6fbf616772b88d0f1e40a1d94bba45f41c3
Paigal/python-intro
/dicts_and_arrays.py
317
4.15625
4
# Arrays # definition: array is an ordered list y = ["First thing", "Second thing"] for x in y: print(x) # Dictionaries # definition: array is an ordered list dictionary = {"Bonjour": "French", "Adios": "Spanish"} print(dictionary["Bonjour"]) for key, value in dictionary.items(): print(f"{key} : {value}")
true
6ea07eef2d50191f962a80067bc1b0043b626bff
NaiveMonkey/Problem_Solving
/py/sort/heap_sort.py
901
4.21875
4
def heap_sort(list): def swap(list, index, largest): list[index], list[largest] = list[largest], list[index] def sift_down(list, index, size): left = 2 * index + 1 right = 2 * index + 2 largest = index if left <= size - 1 and list[left] > list[index]: large...
true
b7fdcb92dd8d29b71af17a852a6f7716d793f951
Bray821/PythonProgram1
/program5.py
370
4.15625
4
age = int(input("What age are you?")) if age<2: print("The peron is a baby") if age>=2 and age<4: print("This person is a toddler") if age>=4 and age<13: print("This person is a child") if age>=13 and age<20: print("This person is a teenager") if age>=20 and age<65: print("This person is an adult")...
true
c2d06b36a20ad7d571cf55a2f695864270b940ce
lifanchu/python-workout
/49.py
942
4.125
4
# 49 - Elapsed since # Write a function whose argument must be iterable # For each iteration, return a (x, y) tuple # x should be seconds since last iteration # first timing should be 0 # y is the next item from time import perf_counter, sleep def iter_timer(iterable): for item in iterable: ...
true
ef7b2c4d90ecb31fc1c3117be66312dd69bdf182
dzt109/Deep_Learning_Notebooks
/_db4a8ae04c7c505f9666b7b8c4d9c101_DiffDriveController.py
1,722
4.125
4
class DiffDriveController(): """ Class used for controlling the robot linear and angular velocity """ def __init__(self, max_speed, max_omega): # TODO for Student: Specify these parameters self.kp=1.0 self.ka=2.0 self.kb=-1.0 self.MAX_SPEED = np.float(max_speed) ...
true
e4a6025cfbea354bd8c79c1f8ff8a935641817d6
knagesh9841/PythonMarch2020
/practice1/InnerClassExample.py
1,056
4.71875
5
""" You can create object of Inner Class inside the outer class or You can create object of inner class outside the outer class provided you use outer class name to call it """ class Student: def __init__(self): self.name = "Nagesh" self.address = "Latur" self.lap = self.Laptop() #...
true
60e2674b7e68c166f03fd66c5127299b4725ab3f
knagesh9841/PythonMarch2020
/practice1/UserDefinedFunctionExample.py
2,514
4.71875
5
# Function return more than 1 value def add_sub(x, y): c = x + y d = x - y return c, d result1, result2 = add_sub(10, 5) print("Addition", result1) print("Subtraction", result2) # Arbitrary Arguments, *args args is of Type Tuple """ If you do not know how many arguments that will be passed into your...
true
58a5346b0c017e207fb6615aa51a2e211a32d8fb
knagesh9841/PythonMarch2020
/practice1/TupleExample.py
2,016
4.75
5
ThisTuple = () # Empty Tuple print(ThisTuple) print(type(ThisTuple)) ThisTuple = ("apple", "banana", "cherry") print(ThisTuple) print(ThisTuple[0]) # This will print First item in Tuple print(ThisTuple[0:2]) # This will print First and second item in Tuple print(ThisTuple[-1]) # This will print Last item in T...
true
0d4f04d63347ca0d34647354dbb2dc6fe2875620
knagesh9841/PythonMarch2020
/practice2/GeneratorExample.py
722
4.21875
4
""" Generator-Function : If the body of a def contains yield, the function automatically becomes a generator function. Generator-Object : Generator functions return a generator object. Generator objects are used either by calling the next method on the generator object or using the generator object in a “for in” loo...
true
835650dcb10c301588c704caca3184aaae3cd8e2
hietanep/BookLibrary
/main.py
1,230
4.34375
4
""" main program: uses BookLibrary to store book information usage: python main.py <file> """ import sys from lib.book_library import BookLibrary # get arguments from commandline arguments = sys.argv # check argument count if(len(arguments) == 2): filename = sys.argv[1] library = BookLibrary(filename...
true
b21ce6c2c60090d739961f618e2b0d09467ae579
swapnil085/CP-Codeforces
/spread.py
807
4.28125
4
import math def checkSemiprime(num): cnt = 0 for i in range(2, int(math.sqrt(num)) + 1): while num % i == 0: num /= i cnt += 1 # Increment count # of prime number # If count is greater than 2, # break loop if cnt >= 2: bre...
true
13d22133e35fcce7975dae8fd08483870286983c
dennisnderitu254/hacker-rank
/algorithms/recursive/k_factorization.py
1,898
4.125
4
#!/usr/bin/env python3 """Solution for: https://www.hackerrank.com/challenges/k-factorization""" import sys from typing import List, Optional, Set def isqrt(n: int) -> int: """Returns the square root of an integer.""" x = n y = (x + 1) // 2 while y < x: x = y y = (x + n // x) // 2 ...
true
ff1a4a5a063ff42bda17b3b49feaedbd6b7ba573
toxtlej1/Python
/If-Else.py
888
4.15625
4
#!/bin/python import math import os import random import re import sys if __name__ == '__main__': n = int(raw_input().strip()) check = {True: "Not Weird", False: "Weird"} # True is given the string Not weird # False is given the string Weird print(check[ n%2==0 and # Will...
true
0f780860920741dde5449994319161a62f858a8a
kwahome/data-structures-and-algos
/algos/sorting/bubble_sort/sort.py
1,435
4.125
4
from algos import STRATEGIES from algos.sorting import ASCENDING, GREATER_THAN, SORTING_OPERATORS #: iterative implementation def ibubble_sort(arr, order=ASCENDING): """Iterative implementation of bubble sort. :param arr: input list :param order: sorting order i.e "asc" or "desc" :return: list sorted...
true
d41af0c8791dee6e58b8c3ac4368a882ad317cbb
chrishuan9/oreilly
/python/python1homework/secret_code.py
903
4.5
4
__author__ = 'chris' """ Lab 10, Objective 1: This project requires you to use built-in functions to perform character manipulations. 1. Create a new Python source file named secret_code.py. 2. Write a program to read a line of input from the user, and encode it using the following cipher: 3. Take each character of th...
true
99e57be6b65554ada9a32773d812f4de0a48b869
chrishuan9/oreilly
/python/python1homework/input_counter.py
1,610
4.1875
4
__author__ = 'chris' #Lab6, Objective 1 """ Objective 1: This project tests your ability to use sets and dicts, and your ability to follow an algorithm (recipe) exactly. 1.Create a new Python source file named input_counter.py. 2.Write a program that creates an empty set and dict. 3.Write a while loop that repeatedly ...
true
8b8b8e80d1d381865712d22f8ca127f9b0cd2cf4
chrishuan9/oreilly
/python/python1homework/final.py
2,837
4.78125
5
__author__ = 'chris' """ Objective 2: This project tests your basic ability to build a complex program from the relatively limited amounts of Python you already know. 1. Create a new Python source file named final.py. 2. Write a program that meets the following specifications: - Call the program with an argument, i...
true
f8f04d0feb5c6676af2204704de7eae2d0f90ab6
chrishuan9/oreilly
/python/python1/check_string.py
1,213
4.65625
5
__author__ = 'chris' """ Lab 3, Objective 1 This project tests your ability to use conditional tests and write code that responds differently to different inputs. Create a new Python source file named check_string.py. Write a program that asks the user to input a string. Verify with tests that the string is all in upp...
true
56cd7428083bd06728c3850dc336b704a8e9b4cf
chrishuan9/oreilly
/python/python1homework/caser.py
2,843
4.59375
5
__author__ = 'chris' """ Lab 13, Objective 1: This project further tests your ability to write and use custom functions. 1. Create a new Python source file named caser.py. 2. Create these functions: - capitalize accepts a string parameter and applies the capitalize() method. - title accepts a string parameter ...
true
0cb6b45c35c368beceecd3d7e9105c4678881932
shanyi/Python-exercises
/Python_udacity_exercises_1.py
2,007
4.59375
5
# ''' # Programming background in Python. # # The first exercise allows you to assess your ability to program in Python. # As a data analyst, you will spend much of your time writing code and # programs to work with data or to build mathematical, statistical, or # machine learning models to find insights from data. # #...
true
5c71eebc9fb7be1fa1f3cf9f4aa705dcbb31dd99
advaitsp/PS-1-Summer-2020
/String1.py
666
4.40625
4
# Python Program for # Creation of String # Creating a String # with single Quotes String1 = 'Welcome to Python' print("String with the use of Single Quotes: ") print(String1) # Creating a String # with double Quotes String1 = "Python is the most trending language" print("\nString with the use of Double Quote...
true
ad9eac3e60c3abd92f66eb0b52598a5459c216e9
advaitsp/PS-1-Summer-2020
/String2.py
311
4.34375
4
# Python Program to Access # characters of String String1 = "Programming in Python" print("Initial String: ") print(String1) # Printing First character print("\nFirst character of String is: ") print(String1[0]) # Printing Last character print("\nLast character of String is: ") print(String1[-1])
true
283ce456edc9b7f5eae143bf35ff1081f0be817c
advaitsp/PS-1-Summer-2020
/Numpy/advanced_array_indexing.py
614
4.3125
4
import numpy as np x = np.array([[ 0, 1, 2],[ 3, 4, 5],[ 6, 7, 8],[ 9, 10, 11]]) print 'Our array is:' print x print '\n' rows = np.array([[0,0],[3,3]]) cols = np.array([[0,2],[0,2]]) y = x[rows,cols] print 'The corner elements of this array are:' print y import numpy as np x = np.array([[ 0,...
true
190b9baad322e628a9ad28ddcd5539089ed9764d
beatdapredator/210ct
/week 3/Prime numbers.py
512
4.34375
4
def is_prime(number,t=3): if number == 0: result = False elif number == 2: result = True elif number <= 1 or number % 2 == 0: result = False elif t*t > number: result = True elif number % t == 0: result = False else: return is_prime(n...
true
d8feb76f4e5ef40c2693d9caa1753465576b3429
sudjoe/mydemo
/e5.py
1,277
4.21875
4
# 1st : printing printing formatter = "{} {} {} {}" print(formatter.format(1, 2, 3, 4)) print(formatter.format("one", "two", "three", "four")) print(formatter.format(True, False, False, True)) print(formatter.format(formatter, formatter, formatter, formatter)) print(formatter.format( "Try your", "Own text here", "Maybe...
true
d174257ce4a13527f4a94316fe3bafde4e97844d
Shraddha007Gabani/HW05_567
/triangle_classify.py
1,808
4.25
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 14 13:44:00 2016 Updated Jan 21, 2018 The primary goal of this file is to demonstrate a simple python program to classify triangles @author: jrr @author: rk """ def classify_triangle(a_first, b_second, c_third): """Your correct code goes here... Fix the faulty logi...
true
86728f125669b59c2c9c64169fa1d2f6c4de3811
hadkarAnish/pythonLearning
/hr_nested_lists.py
916
4.15625
4
# Given the names and grades for each student in a Physics class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. #Note: If there are multiple students with the same grade, order their names alphabetically and print each name on a new line. #Input Forma...
true
4eaae2d5408802cc280d0f17e9f0c93665a477d7
AdGw/PracticalTasks
/Python/Reverse words.py
361
4.28125
4
'''Complete the function that accepts a string parameter, and reverses each word in the string. All spaces in the string should be retained.''' def reverse_words(text): splited_txt = text.split(' ') arr =[] for i in splited_txt: reversed = i[::-1] arr.append(reversed) return " ".join(ar...
true
2769d1107cf8a836c2eb0aa072fda07e9e755868
nikitakhandare6/assignment_1
/50_assign1_binarystring.py
628
4.5
4
#python program to find the given string is binary or not # s=input("Enter the binary string") # set1=set(s) # p={'1','0'} #if (set1==p or set1=={'1'} or set1=={'0'}): # print("string is binary") # #else: # print("string is not binary") # stri = input('Enter string ') # stri = set(stri) # bin=['0','1'] # flag ...
true
7863fa5a3380af36c8635cc504c86591588978a3
athenalpn/FinalPython
/5.RectangleSquare.py
2,996
4.4375
4
"""Using OOP principles: Rectangle class calculates the perimeter and area measurements when length and width are input. Input values are automatically turned into a floating point value. Accepts the length and width as direct input to calc the area and perimeter of the rectangle. or accept the coordinates of the top...
true
d69fab99c3ebbbe9bcbc81e67209316d2ad82a9a
nage2285/day-5-1-exercise-1
/main.py
860
4.125
4
# 🚨 Don't change the code below 👇 student_heights = input("Input a list of student heights ").split() for n in range(0, len(student_heights)): student_heights[n] = int(student_heights[n]) # 🚨 Don't change the code above 👆 #Write your code below this row 👇 #Alternate way #total_height = sum(student_heights) #...
true
e72912d34476c4fc53d0ced13f6bdfd3ec322f4b
anukrit01/Iterview-trivia
/interview_google2.py
1,297
4.21875
4
# Google ''' Given an array A of integers, return True if and only if it is a valid mountain array. Mountain Array : is an array, which after plotting on graph shows a mountain like structure. Starting from a less value and increasing till a point and then again decreasing. But it did not contain same value anywh...
true
e1756382224e0ea9d4890134b73012028adb94a4
rushilg13/CP-Questions
/Duck_Number.py
299
4.125
4
# https://www.geeksforgeeks.org/check-whether-number-duck-number-not/ # Duck Number st=str(input()) for i in range(1,len(st)): if(st[i]=='0'): flag=1 break else: flag=0 if(flag==1): print("Duck number") else: print("Not a duck number")
true
07a2e780c83e1d2f52a3c2a449f39b849e8c8825
vzhz/primes
/even_or_odd.py
2,664
4.3125
4
import pprint import math numbers = range(2,51) def count_divisors(numbers): numbers_divisors = [] for i in numbers: divisors = 0 for less in range(1, int(math.ceil(math.sqrt(i)))): #more eff. to count both sides of the pair, so use sqrt if i % less == 0: divisors += 2 #only even bc counting pairs, so ...
true
5c8c9e23fa348429d9a58608e544670e7a60c62f
Ranjeet900/PycharmProjects
/pythonProject/Python_Exercise.py
833
4.1875
4
# print('Hello') # Simple python program # def main(): # print("Hello world!") # name = input("What is your name?:") # print("Nice to meet you!", name) # if __name__ == "__main__": # main() # # Example file for variables # # # Declare a variable and initialize it # f=0 # print(f) # # # re-decelaring th...
true
7fb518e37727861e260714b276779a15ab3028ac
Ranjeet900/PycharmProjects
/pythonProject/String_program_All_in_one.py
2,379
4.34375
4
# Q.1 How would you confirm that 2strings have the same identity? ''' animals = ['python', 'gopher'] more_animals = animals print(animals == more_animals) print(animals is more_animals) even_more_animals = ['python','gopher'] print(animals == even_more_animals) print(animals is even_more_animals) ''' # Q.2 How woul...
true
3d12621b8052c25195324bfb8ba0f966a6323766
criscom/coursera-2014-python
/my-miniprojects/MiniProjectWeek02.py
2,962
4.375
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console # http://www.codeskulptor.org/#user38_R7oK9fsrKH_0.py # importing modules import simplegui import random import math # initialize global variables # secret numbe...
true
9254020724d169742b956deb536464b5680279ab
aaaaaaaaaaaaaaaaace/H2-Computing-stuff
/Fundamental Algorithms/Sorting Algorithms/Bubble Sort.py
1,153
4.46875
4
''' It iterates by comparing elements pairwise and swapping adjacent elements if they are not in order. The iteration loops itself by how many elements there are in the array, but one less for every consecutive iteration because one more element will be in its correct position for every loop. For an optimised bubb...
true
d11997114c0a5c58a5f9eda879cd8a419d418654
surendravj/Python
/Dlinkedlist/insertion.py
1,916
4.15625
4
# Program implementaion of double linked list operations for insertion # Create node class node: def __init__(self, data): self.data = data self.next = None self.prev = None class Dlink: def __init__(self): self.head = None def is_newNode(self, newnode):...
true
221c265253f1dc3183eb768432f8c969aab7333e
surendravj/Python
/Strings/program1.py
1,041
4.1875
4
# Program to count the total number of punctuation characters exists in a string. def count_punc(str): count = 0 for i in str: if i in ".,/!?;:-": count += 1 return count print(count_punc("hi! r u surendra ? yes i am .")) # // program to count number of ovwels and con...
true
a085c64d24f102756a11067fd9d1ac572bc18f91
surendravj/Python
/Stacks/stackSLL.py
1,212
4.125
4
# Implementing the stack data structure using linked list class node: def __init__(self, data): self.data = data self.next = None class stack: def __init__(self): self.first = None # METHOD TO PUSH THE VALUES IN TO THE SATCK def push(self, newnode): ...
true
b9e22657c59e435108314b2ce1fbafc0d3de8790
opethe1st/CompetitiveProgramming
/CodeChef/2020/07/ada_king.py
2,080
4.15625
4
""" Chef Ada is training her calculation skills. She wants to place a king and some obstacles on a chessboard in such a way that the number of distinct cells the king can reach is exactly K. Recall that a chessboard has 8 rows (numbered 1 through 8) and 8 columns (numbered 1 through 8); let's denote a cell in row r an...
true
36ee865d1abfe522bb7357b4fb33aacd08e3fc66
dogac00/Dynamic-Programming
/memoization.py
1,082
4.1875
4
import time look_up = {0: 1} def memoize(x): if x in look_up: return look_up[x] else: look_up[x] = x * memoize(x-1) return look_up[x] def recursion(x): if x == 0: return 1 else: return x * recursion(x-1) def iteration(x): result = 1 for i in range(2,x+1): result *= i return res...
true
84d40049545e7748abb08e1d57ded806d2954104
brokenarrows/python-examples
/src/Map/Tools/calculateDistance.py
1,394
4.5
4
# !/usr/bin/env import sys import math def calculate_distance(longitude1, latitude1, longitude2, latitude2, unit): """ A line through three-dimensional space between points of interest on a spherical Earth is the chord of the great circle between the points. The central angle between the two points can b...
true
fd0a178a9b1dc69c4b8690f68c82513c386289fb
mshellik/automate_the_boring_stuff
/Continue_statements.py
387
4.28125
4
#This will be for a continue statement in a loop(Not Sure.. if we can use the continue statement out side of any conditional loop statements, this is used , when we want to have the loop to skip consecutive indented statements and to get back to the beggining of the loop spam=0 while spam < 5: spam=spam+1 if s...
true
50677509148e72bc02cca0d3c72800de01cc8abd
kimjudyh/python_class
/lesson03/exercise03_challenge3.py
569
4.125
4
# lesson 03, chapt 2, challenge 3 ''' Write a Tipper program where the user enters a restaurant bill total. The program should then display two amounts: a 15 percent tip and a 20 percent tip. ''' # initialize variables bill = 0.0; # float tip15 = 0.0; tip20 = 0.0; # user input bill = float(input("Ent...
true
c240060e5b54e786e6e5f4dc6aa332a5e97ea05a
bishalraktim/LPTHW-Python
/ex32.py
1,199
4.5
4
#!/usr/bin/python3.6 # Exercise 32: Loops and Lists 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 list for number in the_count: print(f"This is count {number}") # the same as above for ...
true
dfafc080ca169772c1b0d8febf7f5f3685bf3b0d
shaiwilson/algorithm_practice
/sorting/binarysearch.py
1,061
4.21875
4
# binary search import test # complexity # the number of overal iterations # will increase everytime the exponent # on the power of 2 increases # 0(log (n) def binarySearch(mylist, item): first = 0 last = len(mylist) - 1 found = False while first <= last and not found: midpoint = (first + ...
true