blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
d99af8d7a19d0e1545818127008ba451c76e0669
zainab404/zsfirstrepo
/packing_with_dictionaries.py
390
4.375
4
#packing is when you can pass multiple arguments. #here, we used **kwargs to signify the use of multiple arguments. #the for loop will iterate over the arguments given and print each one def print_student(**kwargs): for key,value in kwargs.items(): print("{} {}".format(key,value)) print_student(name = "Z...
true
6aa6d30c03cb59c7a67036aeb778971356e70959
wherby/hackerrank
/Temp/Scala/add.py
406
4.1875
4
def addInt(input): if "a" in input and "b" in input: a = input["a"] b = input["b"] try: int(a) try: int(b) return a+b except: print b + " is not int" except: print a + " is not int" el...
true
2d47bef22ea73a37b69df451cd60b9df4834603a
Andrewzh112/Data-Structures-and-Algorithms-Practice
/Two Pointers II.py
1,257
4.15625
4
# Valid Palindrome class Solution: """ @param s: A string @return: Whether the string is a valid palindrome """ def isPalindrome(self, s): start, end = 0, len(s) - 1 while start < end: while start < end and not s[start].isalnum(): start += 1 wh...
true
958cb78be722ee0cf1de35a0587da701bc078646
WayneGoodwin95/Algorithms
/selection_sort.py
710
4.125
4
""" SELECTION SORT loop through list keeping track of smallest unchecked index (min_index) if another index is smaller swap the value to min_index once looped through, change the minimum index to the next array element repeat """ def selectionSort(my_arr): min_index = 0 for min_index in range(len(my_arr)): ...
true
97bc3c6267200c16610d7e6725c022b0f47730a2
andre-lobo/Complete-Python-Bootcamp
/011-if_elif_else.py
446
4.1875
4
#if, elif and else examples if True: print("It was True") print() x = False if x: print("x was True") else: print("x was False") print() loc = "Bank" if loc == "Auto Shop": print("Welcome to the Auto Shop") elif loc == "Bank": print("Welcome to the Bank") elif loc == "Mall": print("Welcome to the Mall") el...
true
7a8de130d4c4ee9fccf98ce22e0fb60dd647b0da
Sabrina-Sumona/Python-learning
/oop_1.py
1,344
4.125
4
class StoryBook: # CLASS VARIABLE no_of_books = 0 discount = 0.5 def __init__(self, name, price, author_name, author_born, no_of_pages): # setting the instance variables here self.name = name self.price = price self.author_name = author_name self.author_born = ...
true
273b56a48a8bcb4eccfd6020852347a27407649c
Napster56/Sandbox
/function_scpoe_demo.py
666
4.21875
4
def main(): """Demo function for scope of an immutable object.""" x = 3 # int is immutable print("in main, id is {}".format(id(x))) function(x) print("in func, id is {}".format(id(x))) def function(y: int): print("in func, id is {}".format(id(y))) y += 1 # assignment creates a...
true
87f0528ad87ca333109df2a21864358aff4f4a8e
Napster56/Sandbox
/reverse_text_recursively.py
284
4.28125
4
""" Function to reverse a string recursively. """ def reverse(text): if len(text) < 2: # base case return text else: # recursive step = reverse(rest of text) + first char of text return reverse(text[1:]) + text[0] print(reverse("photon"))
true
165bd77cb033c6535f0ebf67d16986a24f83dd7f
Napster56/Sandbox
/CreditCard_class.py
2,471
4.15625
4
""" Create a class for a consumer credit card """ class CreditCard: def __init__(self, customer, bank, account, limit): """Make a new credit card instance The initial balance is zero. """ self.customer = customer self.bank = bank self.account = account sel...
true
689b0af2411c98e7bd92590ceb0b24d8ac68b254
Napster56/Sandbox
/user_name.py
547
4.3125
4
""" Ask user for their name Tell them how many vowels are in their name Tell them how many capitals are in their name """ count_vowels = 0 name = "Bobby McAardvark" # name = input("Name: ") for letter in name: if letter.lower() in 'aeiou': count_vowels += 1 print("Out of {} letters, {} has {} vowels".form...
true
5f522189d56fe7cd74fcdd8153ada80032a89cee
Napster56/Sandbox
/Classes demo/circle_class.py
498
4.46875
4
""" Program to create a Circle class which inherits from the Shape class. The subclass Circle extends the superclass Shape; Circle 'is-a' Shape. """ from shape import Shape class Circle(Shape): def __init__(self, x=0, y=0, radius=1): super().__init__(x, y) # used to access the instance of the Shape cl...
true
f4ca8f55ec31d63d82b33b20a76085bcb6a258ea
Napster56/Sandbox
/file_methods.py
813
4.15625
4
""" # readline method temp = open("temp.txt", "r") # open file for reading first_line = temp.readline() # reads exactly one line print(first_line) for line in temp: # read remaining lines print(line) temp.readline() # read file, return empty string print(temp) temp.close() # read m...
true
4a50ac2346aee77dfd6080be2541d3c810b04cea
alexisdavalos/DailyBytes
/BinaryTreeVisibleValues/binaryTreeVisibleValues.py
921
4.21875
4
# Given a binary tree return all the values you’d be able to see if you were standing on the left side of it with values ordered from top to bottom. # This is the class of the input binary tree. Do not Edit! class Tree: def __init__(self, value): self.val = value self.left = None self.right...
true
6681a57d55dbe2ea18d6f6d5c65776935455dde9
alexisdavalos/DailyBytes
/MakePalindrome/makePalindrome.py
524
4.1875
4
# Write a function that takes in a string with any set of characters # Determine if that string can become a palindrome # Returns a Boolean after processing the input string def makePalindrome(string): # Your Code Here return # Test Cases Setup print(makePalindrome("aabb")) # => true (abba) print(makePalind...
true
dc4b771cc52cb1a5d19e2a5e07858472fcb9254d
razorblack/python_programming
/PythonPractice/PrimeOrComposite.py
307
4.28125
4
userInput = int(input("Enter a number to check for prime \n")) count = 0 # To count no. of factors of user input number for i in range(2, userInput): if userInput % i == 0: count += 1 if count > 0: print(f"{userInput} is composite number") else: print(f"{userInput} is a prime number")
true
e5e647601be99ae9e20aa7c3f0f37f4867a18802
razorblack/python_programming
/PythonLab/Program6.1.py
673
4.125
4
# Method to perform Linear Search def linear_search(list_of_number, no_to_search): size = len(list_of_number) for i in range(0, size): if list_of_number[i] == no_to_search: print(f"Search Successful: Element found at index {i}") return print("Search Unsuccessful: Element Not...
true
b8f6125de3b647d2b8c3c6a8fee82d258c6b8731
minaeid90/pycourse
/advanced/example0.py
2,923
4.53125
5
#-*- coding: utf-8 -*- u''' DESCRIPTORS EXAMPLE 0: How attributes look up works ''' # Let's define a class with 'class' and 'instance' attributes class MyClass(object): class_attr = "Value of class attrib" def __init__(self): self.instance_attr = "Value of instance of {0} attrib".format(self.__class__....
true
e4598a7212964d5dc6440bb57d16342e46b1fd95
usfrank02/pythonProjects
/project3.py
288
4.34375
4
#! python import sys name = input("Enter your name:") print (name) #Request user to input the year he was born year_of_born = int(input("What's the year you were born?")) #Calculate the age of the user age = 2020 - year_of_born print("You will be {} years old this year!".format(age))
true
2e046c0d4fc1e243a8ae9e85b56d10f9195e473b
Regato/exersise12
/Romanov_Yehor_Exercise14.py
582
4.15625
4
# Entering input and making from string all UPPER case: input_string = input('[!] INPUT: Please enter your value (only string type): ') upper_string = input_string.upper() # Function that count letters in string: def letter_counter(x): return upper_string.count(x) # For cycle that check every letter for duplica...
true
38582bca142960e852de0445e04d76afb018a1fb
Jattwood90/DataStructures-Algorithms
/1. Arrays/4.continuous_sum.py
435
4.25
4
# find the largest continuous sum in an array. If all numbers are positive, then simply return the sum. def largest_sum(arr): if len(arr) == 0: return 0 max_sum = current = arr[0] # sets two variables as the first element of the list for num in arr[1:]: current = max(current+num, n...
true
088a600b0d851da9345a6ef2e336bdf32c9dddb8
rhaydengh/IS211_Assignment1
/assignment1_part2.py
614
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Assignment 1, Part 2""" class Book: """Class for books""" def __init__(self, author, title): """this function returns a book by author and title based on variables""" self.author = author self.title = title def display...
true
6e29c29f32d27aa1e76cc0a3ead78b2b3cca6515
sachlinux/python
/exercise/strings/s3.py
369
4.15625
4
#embedding value in string value = "500" message = "i hav %s rupees" print(message % value) #we can do without variable also print(message % 1000) #more example var1 = "sachin" var2 = "dentist" message1 = "%s: is in love with %s" message2 = "%s is so %s" print(message1 % (var1,var2)) print(message2 % ('she',...
true
658ec398f352a09390fd9534cb448e2a91bffc9c
debakshmi-hub/Hacktoberfest2021-2
/checkPrime.py
756
4.21875
4
# //your code here # Program to check if a number is prime or not num = int(input("Enter a Number ")) flag = False if num > 1: for i in range(2, num): if (num % i) == 0: flag = True break if flag: print(num, "is not a prime number") else: print(num, "is a prime num...
true
fb54c0d63382752c3c9a3feb327321a2c77492cc
gautamk/ProjectEuler
/problem1.py
528
4.25
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. MAX = 1000 def mul_of(multiple_of, max=MAX): multiplier = 1 multiple = multiple_of * multiplier while multiple < M...
true
250aaa13de0944d78fc6f7a6083c5413ea1961e5
KhallilB/Tweet-Generator
/Code/practice_code/sampling.py
1,731
4.125
4
import random import sys import histograms def random_word(histogram): '''Generates a random word without using weights''' random_word = '' random_index = random.randrange(len(histogram)) random_word += histogram[random_index][0] return random_word def weighted_random_word(histogram): '''Gen...
true
79ec249c78604d85bf5612da0d597d41c39214e3
qcl643062/leetcode
/110-Balanced-Binary-Tree.py
1,730
4.15625
4
#coding=utf-8 """ Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. """ class TreeNode(object): def __init__(self, x, left = None, right = None): ...
true
a2f10d28828b2fe43054860554e2915bbe1a3e13
EngrDevDom/Everyday-Coding-in-Python
/Distance.py
379
4.25
4
# File : Distance.py # Desc : This program accepts two points and determines the distance between them. import math def main(): x1, y1 = eval(input("Enter first coordinate.(x1, y1): ")) x2, y2 = eval(input("Enter second coordinate.(x2, y2): ")) distance = math.sqrt((x2-x1)**2 + (y2-y1)**2) pri...
true
38af1cc91d8307cf8d0adfb77e19b558ad5b6bb5
EngrDevDom/Everyday-Coding-in-Python
/SciPy/polynomials.py
830
4.25
4
from numpy import poly1d # We'll use some functions from numpy remember!! # Creating a simple polynomial object using coefficients somePolynomial = poly1d([1,2,3]) # Printing the result # Notice how easy it is to read the polynomial this way print(somePolynomial) # Let's perform some manipulations print("\nSquaring ...
true
d43dcc1e99425696cdaeff16dc969344a3205a95
EngrDevDom/Everyday-Coding-in-Python
/Identify_triangle.py
496
4.4375
4
# This program identifies what type of triangle it is # based on the measure of it's angle angle = int(input("Give an angle in degrees: ")) type = "" if angle > 0 and angle < 90: type = "ACUTE" elif angle == 90: type = "RIGHT" elif angle > 90 and angle < 180: type = "OBTUSE" elif angle == 180: type = ...
true
96ff1baf71e2a5f8e24a0985a95a4cf52e2d14b4
EngrDevDom/Everyday-Coding-in-Python
/Ladder.py
447
4.46875
4
# File : Ladder.py # Desc : This program determine the length of the ladder required to # reach a given height leaned. import math def main(): angle = float(input("Enter the value of angle in degrees: ")) radians = math.radians(angle) # Convert degrees to radians height = float(input(...
true
0cea260a3dcf1852cbd66920e3aa23e94e7d26b7
EngrDevDom/Everyday-Coding-in-Python
/quadratic_5.py
702
4.1875
4
# File : quadratic_5.py # Desc : A program that computes the real roots of a quadratic equation. Version 5.0 # Note: This program catches the exception if the equation has no real roots. import math def main(): print("This program finds the real solutions to a quadratic\n") try: a = ...
true
de25351bfb982437ac08ebd4d1c7ba94ffd86490
EngrDevDom/Everyday-Coding-in-Python
/quizzes_2.py
549
4.1875
4
# File : quizzes_2.py # Desc : A program that accepts a quiz score as an input and uses a decision # structure to calculate the corresponding grade. def main(): grade = int(input("Enter your grade: ")) scale = '' if grade <= 100 or grade >= 90: scale = 'A' elif grade <= 89 or grade...
true
f05e35fdc63cfcb45bb19620d0478dfc7b91ab8c
EngrDevDom/Everyday-Coding-in-Python
/Eq_of_Motion.py
261
4.28125
4
# Program for computing the height of a ball in vertical motion v0 = 5 # Initial velocity (m/s) g = 9.81 # Acceleration of gravity (m/s^2) t = 0.6 # Time (s) y = v0*t - 0.5*g*t**2 # Vertical position print("Height of the ball: ", y, " m")
true
0db588fb91a034b200427bc709206e201947fc9f
EngrDevDom/Everyday-Coding-in-Python
/Algorithms/Sorting Algorithms/Tim_sort.py
2,652
4.28125
4
# Tim_sort Algorithm from random import randint from timeit import repeat def timsort(array): min_run = 32 n = len(array) # Start by slicing and sorting small portions of the # input array. The size of these slices is defined by # your `min_run` size. for i in range(0, n, min_run): in...
true
88f6afcf9589102e21cd694e2ce4f9104d61b08e
EngrDevDom/Everyday-Coding-in-Python
/Resistor_Color_Coding.py
508
4.21875
4
''' Resistor Color Coding - This program calculates the value of a resistor based on the colors entered by the user. ''' # Initialize the values black = 0 brown = 1 red = 2 orange = 3 yellow = 4 green = 5 blue = 6 violet = 7 grey = 8 white = 9 gold = 0 silver = 0 bands = input('Enter the color bands: ') c...
true
7d5ad562c1fd4fd490af54eeca2429e41b04e95c
sreedhr92/Computer-Science-Laboratory
/Design And Analysis of Algorithms/power_iterative.py
251
4.28125
4
def power_iterative(x,n): result =1 for i in range(0,n): result = x*result return result x = int(input("Enter the base:")) y = int(input("Enter the exponent:")) print("The value of",x,"to the power of",y,"=",power_iterative(x,y))
true
15544b46b10a29d6f235de86dbf6a1af00bae4bd
UzairIshfaq1234/python_programming_PF_OOP_GUI
/07_color_mixer.py
891
4.46875
4
colour1 = input("Enter the first primary colour: ") colour2 = input("Enter the second primary colour: ") mixed_colour = "" if (colour1 == "red" or colour1 == "blue" or colour1 == "yellow") and (colour2 == "red" or colour2 == "blue" or colour2 == "yellow"): if (colour1 == "red" and colour2 == "blue") or (colour2 ...
true
f8d641ea4352a27b00c1d30c84545fd5e5c7744c
nirakarmohanty/Python
/controlflow/IfExample.py
248
4.375
4
print('If Example , We will do multiple if else condition') value =int(input('Enter one integer value: ')) print('You entered the value as : ',value) if value>0: print('value is an integer') else: print('Please enter one integer number')
true
9a107acee38a1fc5a4632d6ed1c20b5b81408161
nirakarmohanty/Python
/datatype/ListExample.py
513
4.46875
4
#Define simple List and print them nameList=['Stela','Dia','Kiara','Anna'] print(nameList) #List indexing print(nameList[1],nameList[2],nameList[3]) print(nameList[-1],nameList[-2]) #length of List print(len(nameList)) #Add a new list to the original list nameList= nameList + ['Budapest','Croatia','Prague'] print(n...
true
b9ec0f8c814393ce080abe964c5c59f417dfc897
dspwithaheart/blinkDetector
/modules/read_csv.py
2,833
4.1875
4
''' csv module for reading csv file to the 2D list Default mode is 'rb' Default delimiter is ',' and the quotechar '|' # # # arguments: csv_file - read csv file name coma - if True replaces all the comas with dots (in all cells) header - specify how many lines (from the beg...
true
1c43a8a8cccb45600465dc2389894102763ad40b
a-bl/counting
/task_1.py
243
4.15625
4
# What is FOR loop? sum = 0 while True: n = int(input('Enter N:')) if n > 0: for num in range(1, n + 1): sum += num print(sum) break else: print('Enter positive integer!')
true
53490c2c6e9feba29d73cb1024895eda79298a2e
rollbackzero/projects
/ex30.py
458
4.1875
4
people = 40 cars = 30 trucks = 45 if cars > people: print("We should take cars") elif cars < people: print("We should not take cars") else: print("We can't decide") if trucks > cars: print("Thats too many trucks") elif trucks < cars: print("Maybe we could take the trucks") else: print("We sti...
true
009d63fffab9020cf7c8ebc4b9deec98b0f656a9
UVvirus/frequency-analysis
/frequency analysis.py
1,099
4.4375
4
from collections import Counter non_letters=["1","2","3","4","5","6","7","8","9","0",":",";"," ","/n",".",","] key_phrase_1=input("Enter the phrase:").lower() #Removing non letters from phrase for non_letters in non_letters: key_phrase_1=key_phrase_1.replace(non_letters,'') total_occurences=len(key_phrase_1) #Co...
true
5445d08db0f152cba9a08f2f6d176a071d61c080
habbyt/python_collections
/challenge_1.py
292
4.15625
4
#Challenge #1 #function takes a single string parameter and #return a list of all the indexes in the string that have capital letters. def capital_indexes(word): word="HeLlO" x=[] for i in range(len(word)): if word[i].isupper()==True: x.append(i) return x
true
cd2ae708b13c6359cbbcefa0b957fa58d304f722
okazkayasi/03_CodeWars
/14_write_in_expanded_form.py
682
4.375
4
# Write Number in Expanded Form # # You will be given a number and you will need to return it as a string in Expanded Form. For example: # # expanded_form(12) # Should return '10 + 2' # expanded_form(42) # Should return '40 + 2' # expanded_form(70304) # Should return '70000 + 300 + 4' # # NOTE: All numbers will be whol...
true
4f7cbb96396df971f262b7faecee06a8be3a23a9
okazkayasi/03_CodeWars
/24_car_park_escape_5kyu.py
2,297
4.15625
4
# Your task is to escape from the carpark using only the staircases provided to reach the exit. You may not jump over the edge of the levels (youre not Superman) and the exit is always on the far right of the ground floor. # 1. You are passed the carpark data as an argument into the function. # 2. Free carparking...
true
8b79cb22ebf59ff6dd2b8f1efbe840c8d519beb3
okazkayasi/03_CodeWars
/06_title_case.py
1,651
4.375
4
# A string is considered to be in title case if each word in the string is either (a) capitalised (that is, only the first letter of the word is in upper case) or (b) considered to be an exception and put entirely into lower case unless it is the first word, which is always capitalised. # # Write a function that will c...
true
1df122ea8c6cbe2473ffa0be8626f86c38d65760
abby2407/Data_Structures-and-Algorithms
/PYTHON/Graph/Graph_Finding_Mother_Vertex.py
1,339
4.15625
4
''' A mother vertex in a graph G = (V,E) is a vertex v such that all other vertices in G can be reached by a path from v.''' from collections import defaultdict class Graph: def __init__(self, vertices): self.vertices = vertices self.graph = defaultdict(list) def addEdge(...
true
04245a627a81d206fd76d72a9808524609498db9
S-Tim/Codewars
/python/sudoku_solver.py
1,926
4.1875
4
""" Write a function that will solve a 9x9 Sudoku puzzle. The function will take one argument consisting of the 2D puzzle array, with the value 0 representing an unknown square. The Sudokus tested against your function will be "easy" (i.e. determinable; there will be no need to assume and test possibilities on unknowns...
true
58ddbfe8f4eca1b019b54c2dcac4c73c94f145e9
clarkmp/CSCI215_Assignment_1
/portfolio/csci220/Assignment03/assignment03.py
2,218
4.15625
4
from math import * def checkIfPrime(): userNumber = eval(input("Give me a number: ")) if userNumber > 1: #this makes sure the number is greater than 1 which is not a prime number while userNumber > 1: #this only loops if the number is greater than 1 if userNumber % 2 == 0: #this will determ...
true
0678f44e86e93fdef14ff4f35e8b6e5b7fe3ad31
gkc23456/BIS-397-497-CHANDRATILLEKEGANA
/Assignment 2/Assignment 2 - Excercise 3.16.py
477
4.15625
4
# Exercise 3.16 largest = int(input('Enter number: ')) number = int(input('Enter number: ')) if number > largest: next_largest = largest largest = number else: next_largest = number for counter in range(2, 10): number = int(input('Enter number: ')) if number > largest: next_largest = lar...
true
d368e0f0e8acbbf8dbecb6a5e6a9a64f8f3efdd7
fmojica30/learning_python
/Palindrome.py
2,851
4.21875
4
# File: Palindrome.py # Description: # Student Name: Fernando Martinez Mojica # Student UT EID: fmm566 # Course Name: CS 313E # Unique Number: 50725 # Date Created: 2/20/19 # Date Last Modified: 2/20/19 def is_palindrome(s): #define if a string is a palindrome for i in range(len(s)//2): if...
true
1807e2597e8d8c7ac920d57a3dd53ed7d5e14033
manjusha18119/manju18119python
/python/swap.py
207
4.3125
4
#2.Write a program to swap two variables. a=input("Enter the value of a :") #a=int(a) b=input("Enter the value of b :") #b=int(b) temp=a a=b b=temp print("swap value of a=",a) print("swap value of b=",b)
true
3e0c9760a73a7629837f54f67d86ac97157cfa32
PriceLab/STP
/chapter4/aishah/challenges.py
575
4.25
4
#1 ------write function that takes number as input and returns it squared def func1(x): return x ** 2 print(func1(2)) #2---- write a program with 2 functions-- first one takes an int #and returns the int by 2. second one returns an integer * 4. #call the first function, save the number, then pass to the second on...
true
6f2f3648576cdf8da47ca0dc88ee1a8d9ea4d80d
Kotuzo/Python_crash_course
/Follow_Up/OOP.py
1,284
4.34375
4
import math # This is examplary class class Point: # This is constructor # Every method from class, needs to have self, as a first argument # (it tells Python that this method belongs to the class) def __init__(self, x, y): self.x = x # attributes self.y = y # typical method ...
true
66ec4ee68f6db85940fd3bd9e22f91179507e5c2
sushidools/PythonCrashCourse
/PythonCrashCourse/Ch.4/try it yourself ch4.py
1,434
4.28125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Sun Aug 5 15:55:17 2018 @author: aleksandradooley """ spc = "\n" pizzas = ['Hawaiin', 'BBQ chickcen', 'pepperoni'] friend_pizzas = pizzas[:] for pizza in pizzas: print "I like " + pizza + " pizza." print "I really love pizza!" pizzas.append('cheese') ...
true
dea18ed1dcc6504cf5d31352a5f76485418e18d6
catalanjrj/Learning-Python
/exercises/ex19.py
1,560
4.21875
4
# create a function named chees_and_crackers with two arguments. def cheese_and_crackers(cheese_count, boxes_of_crackers): # print the amount of cheeses. print(f"You have {cheese_count} cheeses!") # print the number of boxes of crackers. print(f"You have {boxes_of_crackers} boxes of crackers!") # print "Man t...
true
5bbf167d0de558186b79ad5aade880d6119973fb
catalanjrj/Learning-Python
/exercises/ex4.py
1,232
4.15625
4
# Assign a value of 100 to cars cars = 100 # Assign a value of 4 to space_in_a_car space_in_a_car = 4 # Assign a value of 30 to drivers drivers = 30 # Assign a value of 90 to passengers passengers = 90 # Assign the result of cars minus drivers to cars_not_driven cars_not_driven = cars - drivers # Assign the value...
true
3d33eb6cadd1028c81b2190b91fb3cdde5763a7c
sewald00/Pick-Three-Generator
/pick_three.py
951
4.28125
4
"""Random pick three number generator Seth Ewald Feb. 16 2018""" import tkinter as tk from tkinter import ttk from random import randint #Define the main program function to run def main(): #Define function to change label text on button click def onClick(): a = randint(0, 9) ...
true
7d3279e79e140c6feffd735171703b00a5310377
katcosgrove/data-structures-and-algorithms
/challenges/binary-search/binary_search.py
321
4.21875
4
def BinarySearch(arr, val): """ Arguments: A list and value to search for Output: The index of the matched value, or -1 if no match """ if len(arr) == 0: return -1 counter = 0 for item in arr: counter += 1 if item == val: return counter - 1 return -1...
true
3cbb921b6d67b3811de9e9e117d3013dd03bb5bc
renefueger/cryptex
/path_util.py
980
4.4375
4
def simplify_path(path: str, from_separator='/', to_separator='/') -> str: """Returns the result of removing leading/trailing whitespace and consecutive separators from each segment of the given path.""" path_parts = path.split(from_separator) stripped_parts = map(lambda x: x.strip(), path_parts) va...
true
da73cd924c0b1e5b33b8a47a882815fb8c232b3a
nramiscal/spiral
/spiral.py
1,598
4.25
4
''' Given a N by M matrix of numbers, print out the matrix in a clockwise spiral. For example, given the following matrix: [[1, 2, 3, 4, 5], <-- matrix[0] [6, 7, 8, 9, 10], <-- matrix[1] [11, 12, 13, 14, 15], <-- matrix[2] [16, 17, 18, 19, 20]] <-- matrix[3] You should print out the f...
true
adf804c78c165f98bff660077784aeca3bbc1932
BryantCR/FunctionsBasicII
/index.py
2,717
4.3125
4
#1 Countdown - Create a function that accepts a number as an input. Return a new list that counts down by one, from the number (as the 0th element) down to 0 (as the last element). # Example: countdown(5) should return [5,4,3,2,1,0] def countDown(num): result = [] for i in range(num, -1, -1): result....
true
1ef6cc0dd575247f5b227eca08802a0f623744f1
dhilankp/GameDesign2021
/Python2021/VarAndStrings.py
902
4.15625
4
#Dhilan Patel # We are learning how to work with Srtings # While loop # Different type of var num1=19 num2=3.5 num3=0x2342FABADCDACFACEEDFA #How to know what type of data is a variable print(type(num1)) print(type(num2)) print(type(num3)) phrase='Hello there!' print(type(phrase)) #String functions num=len(phrase) p...
true
c866c92036fbd6d45abb7efc3beca71b065abda9
DNA-16/LetsUpgrade-Python
/Day3Assign.py
679
4.21875
4
#Assignment1:Sum of N numbers using while sum=0 N=eval(input("Enter the number ")) flag=0 n=0 while n!=N+1: if(type(N)==float): flag=1 break sum=sum+n n+=1 if(flag==1): print(N,"is not a natural number") else: print("Sum of first",N,"natural number is ",sum) ...
true
594cd76e835384d665f0a8390f82265616e34359
stackpearson/cs-project-time-and-space-complexity
/csSortedTwosum.py
667
4.1875
4
# Given a sorted array (in ascending order) of integers and a target, write a function that finds the two integers that add up to the target. # Examples: # csSortedTwoSum([3,8,12,16], 11) -> [0,1] # csSortedTwoSum([3,4,5], 8) -> [0,2] # csSortedTwoSum([0,1], 1) -> [0,1] # Notes: # Each input will have exactly one so...
true
263e35c47464a3fee4967b212ac0b7ba6a2c286e
maheshbabuvanamala/Python
/LinkedList.py
839
4.15625
4
class Node: """ Node in Linked List """ def __init__(self,value): self.data=value self.next=None def set_data(self,data): self.data=data def get_data(self): return self.data def set_next(self,next): self.next=next def get_next(self): return self.ne...
true
12f482950563599c33857c3264b4ce5c56e6a64d
xwinxu/foobar
/p1/cake.py
2,679
4.1875
4
""" The cake is not a lie! ====================== Commander Lambda has had an incredibly successful week: she completed the first test run of her LAMBCHOP doomsday device, she captured six key members of the Bunny Rebellion, and she beat her personal high score in Tetris. To celebrate, she's ordered cake for everyone -...
true
f30a9c52b7223972fcacf450c8815820989f22a7
AdamJDuggan/starter-files
/frontEndandPython/lists.py
847
4.59375
5
the_count = [1, 2, 3, 4, 5] fruits = ["apples", "oranges", "pears", "apricots"] change = [1, "pennies", 2, "dimes", 3, "quarters"] #this kind of for loop goes through a list for number in the_count: print("This is count {}".format(number)) #same as above for adam in fruits: print("A fruit of type {}...
true
a8e5e788a73225147820189ea73a638e1547345e
sherrymou/CS110_Python
/Mou_Keni_A52_Assignment4/1. gradeChecker.py
1,188
4.125
4
''' Keni Mou Kmou1@binghamton.edu Assignment 4, Exercise 1 Lab Section 52 CA Kyle Mille ''' ''' Analysis Get grade from mark Output to monitor: grade(str) Input from keyboard: mark(float) Tasks allocated to Functions: gradeChecker Check the mark, determine the mark belongs to which grade '''...
true
c438c3f44c1a2e9b7e12d3a8289e058361f99228
sherrymou/CS110_Python
/Mou_Keni_A52_Lab9/#1-2.py
1,729
4.21875
4
''' Keni Mou Kmou1@binghamton.edu Lab9, Excerise 1-2 Lab Section 52 CA Kyle Mille ''' ''' Analyze To compute the max rain fall, min rain fall, and average rain fall use the readline() method Output to the monitor: maxrain(float) minrain(float) average(float) Input from keyboard: filename(str) Tasks: g...
true
cc2d9b75be11f392906fab1f1e840f0865773c87
vicasindia/programming
/Python/even_odd.py
376
4.5
4
# Program to check whether the given number is Even or Odd. # Any integer number that can be exactly divided by 2 is called as an even number. # Using bit-manipulation (if a number is odd than it's bitwise AND(&) with 1 is equal to 1) def even_or_odd(n): if n & 1: print(n, "is Odd number") else: print(n, "is Ev...
true
419411b48b60121fec7809cb902b8f5ad027a6d2
PDXDevCampJuly/john_broxton
/python/maths/find_prime.py
813
4.1875
4
# # This program inputs a number prints out the primes of that number in a text file # ################################################################################### import math maximum = eval(input("Please enter a number. >>> ")) primes = [] if maximum > 1: for candidate in range(2, maximum + 1): is_prime...
true
e80520fea7160878811113027d0483d028041d82
PDXDevCampJuly/john_broxton
/python/sorting/insertion_sort.py
1,441
4.25
4
def list_swap(our_list, low, high): insIst[low], insIst[high] = insIst[high], insIst[low] return insIst pass def insertion_sort(insIst): numbers = len(insIst) for each in range(numbers - 1): start = each minimum = insIst[each] for index in range(1, len(insIst)): ...
true
31ea7b76addea2e6c4f11acd957550a69c864ef1
DKNY1201/cracking-the-coding-interview
/LinkedList/2_3_DeleteMiddleNode.py
1,263
4.125
4
""" Delete Middle Node: Implement an algorithm to delete a node in the middle (i.e., any node but the first and last node, not necessarily the exact middle) of a singly linked list, given only access to that node. EXAMPLE Input: the node c from the linked list a -> b -> c -> d -> e -> f Result: nothing is returned, but...
true
bb3f4cde389b50ffa4157e4310c764f66d7f9cb0
KUSH2107/FIrst_day_task
/17.py
237
4.125
4
# Please write a program to shuffle and print the list [3,6,7,8] import random a1_list = [1, 4, 5, 6, 3] print ("The original list is : " + str(a1_list)) random.shuffle(a1_list) print ("The shuffled list is : " + str(a1_list))
true
bd4fb7517823537a46ff3d5b28ff2f5fe36efc32
ethanschafer/ethanschafer.github.io
/Python/PythonBasicsPart1/labs/mathRunner.py
957
4.125
4
from mathTricks import * inst1 = "Math Trick 1\n\ 1. Pick a number less than 10\n\ 2. Double the number\n\ 3. Add 6 to the answer\n\ 4. Divide the answer by 2\n\ 5. Subtract your original number from the answer\n" print (inst1) # Get input for the first math trick num = inpu...
true
8e80b1006bc765ff53493073f34731554ff52c27
yuliaua1/algorithms
/RandomList_01.py
382
4.3125
4
# This is a simple program to generate a random list of integers as stated below import random def genList(s): randomList = [] for i in range(s): randomList.append(random.randint(1, 50)) return randomList print(genList(30)) #This is creating the list using list comprehensions #randomList = [ ra...
true
37aaf1fd82c0ded9d0578e8a971eb146463ba95f
testlikeachamp/codecademy
/codecademy/day_at_the_supermarket.py
1,874
4.125
4
# from collections import Counter prices = { "banana": 4, "apple": 2, "orange": 1.5, "pear": 3 } # Write your code below! def compute_bill(food): stock = { "banana": 6, "apple": 0, "orange": 32, "pear": 15 } assert isinstance(food, (list, tuple, set)), "{...
true
20849ee4f75e876464e380437d45a5b0f8835f4d
shedaniel/python_3
/Lesson4.2.py
235
4.5
4
#Range #It is used for loops #it will run the loop form %start% to %stop% which each time added it by %plus% #range(start, stop) for x in range(1 , 6): print(x) #range(start, stop, plus) for x in range(100, 107, 3): print(x)
true
18c656d4e69e8c6ee881c0c9a4bd9af8908196c9
GlenboLake/DailyProgrammer
/C204E_remembering_your_lines.py
2,868
4.21875
4
''' I didn't always want to be a computer programmer, you know. I used to have dreams, dreams of standing on the world stage, being one of the great actors of my generation! Alas, my acting career was brief, lasting exactly as long as one high-school production of Macbeth. I played old King Duncan, who gets brutally mu...
true
26d5df3fd92ed228fb3b46e32b1372a0eb5e9664
UIHackyHour/AutomateTheBoringSweigart
/07-pattern-matching-with-regular-expressions/dateDetection.py
2,902
4.46875
4
#! python3 # Write a regular expression that can detect dates in the DD/MM/YYYY format. ## Assume that the days range from 01 to 31, the months range from 01 to 12, and the years range ## from 1000 to 2999. Note that if the day or month is a single digit, it’ll have a leading zero. # The regular expression doesn’t ...
true
24e238601bfe282712b8fbea574a98114ecf9b99
omarBnZaky/python-data-structures
/check_palanced_parenthece.py
1,231
4.3125
4
""" Use a stack to check whether or not a string has balanced usage of parnthesis. """ from stack import Stack def is_match(p1,p2): print("math func:" + str((p1,p2))) if p1 == '(' and p2 == ')': print("match") return True elif p1 == '{' and p2 == '}': print("match") return...
true
dacd4f6e242c40d72e9f5a664828d26c576d457d
Katt44/dragon_realm_game
/dragon_realm_game.py
1,195
4.1875
4
import random import time # having the user pick between to caves, that randomly are friendly or dangerous # printing text out slowly for suspense in checking the cave # asking user if they want to play again def display_intro(): print ('''Standing at the mouth of a cave you take one long inhale and you exhale as...
true
9cea2b8c8abb1262791201e1d03b12e2684673ea
gsandoval49/stp
/ch5_lists_append_index_popmethod.py
712
4.25
4
fruit = ["Apple", "Pear", "Orange"] fruit.append("Banana") fruit.append("Tangerine") #the append will always store the new at the end of the list print(fruit) #lists are not limited to storing strings # they can store any data type random = [] random.append(True) random.append(100) random.append(1.0) random.appe...
true
cf8f18ec1b0e9ae0ee1bfce22be037b352681437
afialydia/Intro-Python-I
/src/13_file_io.py
982
4.1875
4
""" Python makes performing file I/O simple. Take a look at how to read and write to files here: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files """ # Open up the "foo.txt" file (which already exists) for reading # Print all the contents of the file, then close the file # Note: pay close...
true
c48dcb189abf82abb6bee0cac9b92777b6ab1380
zuwannn/Python
/Tree based DSA/TreeTraversal.py
1,029
4.21875
4
# tree traversal - in-order, pre-order and post-order class Node: def __init__(self, item): self.left = None self.right = None self.value = item # left -> root -> right def inorder(root): if root: # traverse left inorder(root.left) # traverse root print(...
true
e367ed81791d2dfc42e60202b1c12e8d75d47de8
zuwannn/Python
/Tree based DSA/binary_tree.py
1,362
4.21875
4
#Binary Tree """ Tree represents the nodes connected by edges(Left Node & Right Node). It is a non-linear data structure. -One node is marked as Root node. -Every node other than the root is associated with one parent node. -Each node can have an arbiatry number of chid node. We designate one node as root node and then...
true
eac9eea7860abcb3474cfa2c4599b31c3e2a0af1
ayushiagarwal99/leetcode-lintcode
/leetcode/breadth_first_search/199.binary_tree_right_side_view/199.BinaryTreeRightSideView_yhwhu.py
1,597
4.125
4
# Source : https://leetcode.com/problems/binary-tree-right-side-view/ # Author : yhwhu # Date : 2020-07-30 ##################################################################################################### # # Given a binary tree, imagine yourself standing on the right side of it, return the values of the # nod...
true
3e75a6666d33bc5965ff3df6d54f7eef487a9900
sammienjihia/dataStractures
/Trees/inOrderTraversal.py
2,293
4.15625
4
class Node: def __init__(self, val): self.val = val self.rightchild = None self.leftchild = None def insert(self, node): # compare the data val of the nodes if self.val == node.val: return False if self.val > node.val: # make the new node the left chi...
true
20ce3fc899aa6766a27dfe73c6dd0c14aa3d4099
Julien-Verdun/Project-Euler
/problems/problem9.py
711
4.3125
4
# Problem 9 : Special Pythagorean triplet def is_pythagorean_triplet(a,b,c): """ This function takes 3 integers a, b and c and returns whether or not those three numbers are a pythagorean triplet (i-e sum of square of a and b equel square of c). """ return a**2 + b**2 == c**2 def product_pythagorean_triplet(N): ...
true
ccee97b325a717c7031159ee1c4a7569ff0675d6
digant0705/Algorithm
/LeetCode/Python/274 H-Index.py
1,647
4.125
4
# -*- coding: utf-8 -*- ''' H-Index ======= Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations eac...
true
e8163d4faddd7f6abeacdea9c6ebbb86a57dd195
digant0705/Algorithm
/LeetCode/Python/328 Odd Even Linked List.py
1,532
4.28125
4
# -*- coding: utf-8 -*- ''' Odd Even Linked List ==================== Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do it in place. The program should run in O(1) space compl...
true
f43f14fe47b99787333551c200df24d211f2f466
digant0705/Algorithm
/LeetCode/Python/156 Binary Tree Upside Down.py
823
4.25
4
# -*- coding: utf-8 -*- ''' Binary Tree Upside Down ======================= Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it upside down and turn it into a tree where the original right nodes turned into left leaf nodes...
true
bb74d28eb5e2fae422a278a02c920d856bd11b5d
digant0705/Algorithm
/LeetCode/Python/059 Spiral Matrix II.py
1,968
4.28125
4
# -*- coding: utf-8 -*- ''' Spiral Matrix II ================ Given an integer n, generate a square matrix filled with elements from 1 to n^2 in spiral order. For example, Given n = 3, You should return the following matrix: [ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ] ''' class Solution(object): '''算法思路: ...
true
422aa7064b6f08b428a782685507ecd3d6b8b98a
digant0705/Algorithm
/LeetCode/Python/117 Populating Next Right Pointers in Each Node II.py
1,611
4.28125
4
# -*- coding: utf-8 -*- ''' Populating Next Right Pointers in Each Node II ============================================== Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work? Note: - You may only use constant ...
true
49948daded2dd54ec0580b90f49602a9f109b623
digant0705/Algorithm
/LeetCode/Python/114 Flatten Binary Tree to Linked List.py
903
4.28125
4
# -*- coding: utf-8 -*- ''' Flatten Binary Tree to Linked List ================================== Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 ...
true
f70831de914e8e30bc7d5b585d604621b153d989
digant0705/Algorithm
/LeetCode/Python/044 Wildcard Matching.py
2,354
4.1875
4
# -*- coding: utf-8 -*- ''' Wildcard Matching ================= Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). The function pr...
true
676462bbeb65b4c86a49a3e15fda440170e117cb
digant0705/Algorithm
/LeetCode/Python/281 Zigzag Iterator.py
1,770
4.25
4
# -*- coding: utf-8 -*- ''' Zigzag Iterator =============== Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: v1 = [1, 2] v2 = [3, 4, 5, 6] By calling next repeatedly until hasNext returns false, the order of elements returned by next shoul...
true
b1d4c792fa5bed9318d6b06ef5040f8033da7b92
digant0705/Algorithm
/LeetCode/Python/371 Sum of Two Integers.py
663
4.21875
4
# -*- coding: utf-8 -*- """ Sum of Two Integers =================== 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. """ class Solution(object): def add(self, a, b): for _ in xrange(32): a, b = a ^ b, ...
true