blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
57035489aaee4fcf0e7386ffb07d1c2f2dfab01a
dipeshbabu/python-labs-codio
/recursion/recursion_exercise2.py
736
4.3125
4
# Recursion Exercise 2 # Write a recursive function called list_sum that takes a list of numbers as a parameter. # Return the sum of all of the numbers in the list. # Hint, the slice operator will be helpful in solving this problem. # Expected Output # If the function call is list_sum([1, 2, 3, 4, 5]), then the functio...
true
f2c702d1508f2e7dacb0e14d65dfcfd071626ad8
shonihei/road-to-mastery
/leetcode/find-duplicate-file-in-system.py
1,761
4.125
4
""" Given a list of directory info including directory path, and all the files with contents in this directory, you need to find out all the groups of duplicate files in the file system in terms of their paths. A group of duplicate files consists of at least two files that have exactly the same content. A single dire...
true
5a6f4091193bccde341bc3a84853bb66ed6af836
shonihei/road-to-mastery
/leetcode/degree-of-an-array.py
1,055
4.125
4
""" Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible length of a (contiguous) subarray of nums, that has the same degree as nums. Example 1: Input: [1, 2, 2, 3, 1] Output: 2 Explan...
true
5dd2e868c4845474110969c4461282bf62d6175d
shonihei/road-to-mastery
/leetcode/path-sum.py
1,170
4.125
4
""" Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ \ ...
true
ee16e99f0cab1225471383e1ccaea8e80be3c5e7
shonihei/road-to-mastery
/leetcode/construct-the-rectangle.py
1,166
4.3125
4
""" For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements: 1. The area of the rectangular web page you designed must equal to...
true
6fb3f01c62a8065ea22ba14e0e81716463e61ea5
shonihei/road-to-mastery
/data-structures/Trie.py
2,299
4.125
4
# task: implement a trie using a hashmap to store pointers to children class TrieNode: def __init__(self): self.children = dict() self.word_end = False def add_string(cur_node, string): for c in string: if c not in cur_node.children: cur_node.children[c] = TrieNode() ...
true
d503aff8d9ccf4d302a0fae16c6082b99dd63a16
shonihei/road-to-mastery
/leetcode/string-compression.py
780
4.125
4
""" Given an array of characters, compress it in-place. The length after compression must always be smaller than or equal to the original array. Every element of the array should be a character (not int) of length 1. After you are done modifying the input array in-place, return the new length of the array. Follow ...
true
44f57f7350f8838a461354a7150e2cc23da99734
sergeys04/introtopython
/2-4fe.py
346
4.28125
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 14 13:00:26 2016 @author: sergeys04 Find the largest odd number from a list of integers """ alist = [] blist = [] while len(alist) <= 10: num = int(input("Enter a number: ")) alist.append(num) if num % 2 != 0: blist.append(num) print ('The largest odd...
true
593f9a244a116aec8c24169068c17eabb6a86a37
gabriel-demes/algo-ds-practice
/sorting-algos/bubble_sort/bubble_sort.py
376
4.15625
4
#start with unordered array #compare consecutive elements. if left > right then swap them #O(n^2) def bubble_sort(array): n = len(array) for p in range(n - 1, 0, -1): for i in range(n-1): if array[i] > array[i+1]: array[i],array[i+1] = array[i+1], array[i] array = [3,7,4,...
true
2c0ccad155a1aef86ffb392e0e9bb58b5fa9c555
ShashwathDasa/searchengine
/db_management.py
2,148
4.125
4
import sqlite3 class dbm: cursor, conn =0,0 def __init__(self,filename): self.filename =filename def table_creation(self): """ Creates a connection with a database and creates a table in it. If the table already exists, it just continues Args: The functi...
true
96a94b60264fe41af66d5c0317895ee9cb6d4ddb
caofanCPU/Python
/project_euler/problem_14/sol2.py
741
4.1875
4
def collatz_sequence(n): """Collatz conjecture: start with any positive integer n.Next termis obtained from the previous term as follows: if the previous term is even, the next term is one half the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conject...
true
3742b13996ac7ca2ec053ff5293ec776a6ae50b4
caofanCPU/Python
/maths/Hanoi.py
808
4.1875
4
# @author willx75 # Tower of Hanoi recursion game algorithm is a game, it consists of three rods and a number of disks of different sizes, which can slide onto any rod import logging log = logging.getLogger() logging.basicConfig(level=logging.DEBUG) def Tower_Of_Hanoi(n, source, dest, by, mouvement): if n == 0:...
true
fa1220d5407850eb8cafbf42317e46dcca488de3
xoolive/cython-ocaml
/void-star/test.py
1,256
4.15625
4
""" Sample programm using pywrapper. The two class presented here implement distance at runtime. They are still evaluated by the cpp code. Mission accomplished! """ import pywrapper from math import sqrt, cos, pi class CartesianPoint(object): """ Class representing a point from its x and y coordinates. """ ...
true
cc5e80ed2c51f2c8c2b50aa3a613bc9d8a7a43d6
lvoinescu/python-daily-training
/check_bst_tree/main.py
1,292
4.3125
4
# You are given the root of a binary search tree. Return true if it is a valid binary search tree, and false otherwise. # Recall that a binary search tree has the property that all values in the left subtree are # less than or equal to the root, and all values in the right subtree are greater than or equal to the root....
true
85733ff859a3d9b52996d023910d4c9cbcf9c823
lvoinescu/python-daily-training
/custom_alphabetical_order/main.py
2,532
4.21875
4
# Given a list of words, and an arbitrary alphabetical order, verify that the words # are in order of the alphabetical order. # # Example: # # Input: # words = ["abcd", "efgh"], order="zyxwvutsrqponmlkjihgfedcba" # # Output: False # # Explanation: 'e' comes before 'a' so 'efgh' should come before 'abcd' # # Example 2: ...
true
14e962b44985c94cf79d1b16887e610f7c10678f
sarah-young/daily_coding_practice
/whole_alphabet.py
442
4.15625
4
import string def whole_alphabet(input_str): """Take in a string. Return 1 if all the letters in the alphabet are in the string. Return 0 otherwise.""" alphabet_set = set(string.ascii_lowercase) check_set = set() for letter in input_str: letter = letter.lower() if letter.isa...
true
2daf4e34c55f33f5c434c282506fc74bd4b4e2d7
Rushikesh-31/Rushi
/listSort.py
481
4.3125
4
#RUSHIKESH BANDIWADEKAR, SE-IT, A-37 #Program to sort list and print only odd numbers from list #Creating empty list list = [] #Taking size/total number of elements to be added in list num = int(input("How many numbers you wanted to add in list : ")) print("Enter numbers in list") #Adding elements in the list for i ...
true
1aedec3e6d7b87129411fc5849a21a9babdfecc2
TahaCoder43/TahaCoder43
/high level test/test for building a large data storage.py
452
4.125
4
DICT = { "Names": { "person_one": "Namme", "second person": "" }, "ages":{ "first person": "", "second person": "" } } x = 1 y = 2 while x != y: print("This is the start of the loop") x = 2 print("This is the end of the loop") DICT["Names...
true
511afc823d38255b61d2e5204d6608db81eea005
Alekhyo/Python
/HeapSort.py
1,243
4.1875
4
def heapify(array,size,root): largest=root #checks whether the parent element is less than its child left=2*root+1 right=2*root+2 if left<size and array[left]>array[largest]: largest=left if right<size and array[right]>array[larges...
true
c7a62b53ea702281408456e35616f2a4131a0f3d
JuktaGoyari/Fidget-spinner
/main.py
1,191
4.28125
4
# import object from module turtle from turtle import * # initial state of spinner is null (stable) state = {'turn': 0} # Draw fidget spinner def spinner(): clear() # Angle of fidget spinner angle = state['turn']/10 # To rotate in clock wise we use right # for Anticlockwise rotation we use ...
true
23431619e92ea30eee815656e4a0360af17615db
suchismitapadhy/PBC2016
/D08/mimsmind1.py
2,866
4.4375
4
# Once again, the program generates a random number with number of digits equal to length. If the command line argument length is not provided, # he default value is 3. This means that, by default, the random number is in the range of 000 and 999. # In this version, the program will establish a maximum number of roun...
true
f7f0f9c0c7440b520b3f8840c5a64e6c0a34eb41
nickmwangemi/Python-Bootcamp
/Week_02 - Printing Receipts Project.py
1,293
4.3125
4
# create a product and price for three items p1_name, p1_price = "Books", 49.95 p2_name, p2_price = "Computer", 579.99 p3_name, p3_price = "Monitor", 124.89 # create a company name and information company_name = "coding dojo" company_address = "76543 - 00508" company_city = "Nairobi, Kenya" # declare ending message m...
true
f448593940f3bdcf7c93b5317505664f2ca9b7c7
king-zar/Zadania---Python
/FibonacciSequence.py
364
4.125
4
n = int(input("Write the number of elements of the Fibonacci sequence: ")) fib = [0, 1] # tab keeps elements of the Fibonacci sequence i = 0 # used to while (i<n-2): # we have 2 first elements in tab fib - that's why we deduct 2 from n nextElement = fib[i] + fib[i+1] # counts next element fib.append(nextElemen...
true
1b5ee63717c19ecaaff24d807feecd3d8d2606da
tikareo/StorageBot
/Forefront.py
1,160
4.34375
4
from Tkinter import #creating a blank window root = Tk() topFrame = Frame(root) topFrame.pack() #frame at the bottom of the window bottomFrame = Frame(root) bottomFrame.pack(side=bottom) label_1 = Label(root, text="Enter email address" label_2 = Label(root, text="Enter password" entry_1 = Entry(root) #entry_...
true
c4c54b453202936452a003afa1c53266c358f648
csolorio94/Oregon-Tech-Lab-Files
/MIS285_Python/SolorioCarlos_MIS285_Lab7/Lab7_Exercise1.py
336
4.15625
4
#Collections funtions for most common import collections #Remove spaces to give the user a letter occurence back every time string = input('Enter a string: ') string = string.replace(" ","") #Print results print('You Entered: ' + string) print('The most common character was: ') print(collections.Counter(string).most_...
true
2f351c19000c1b79b2eb27afb2e174dcd728f07b
csolorio94/Oregon-Tech-Lab-Files
/MIS285_Python/SolorioCarlos_MIS285_Lab1/Lab1_Exericse2.py
364
4.21875
4
# Exercise 2 - Get user input: fuel used and miles driven (display as whole number //) miles_driven = int(input('How many miles did you drive? ')) fuel_used = int(input('How many gallons of fuel did you use? ')) mpg = miles_driven // fuel_used # Display mpg Calculation print('Thank you for your entry.') print('You tra...
true
8503aec5fe8d9e481d8c12ba381c3df50d27ccf1
douglasbruce88/CompletePython
/Section 5/HelloWorld.py
810
4.25
4
print('Hello, World!') print(1 + 2) print(7 * 6) print() print("The End") print('We can even include "quotes" in string') print("'quote' ") print("hello" + "world") greeting = "hello" name = "Doug" print(greeting + name) # if we want a space, we can add that too print(greeting + " " + name) # name = input("Please ente...
true
ba34dff1b365c3b217d734f87b556a6adc3da4c0
douglasbruce88/CompletePython
/Section 7/tuples.py
1,741
4.34375
4
# tuples are immutable sets of ordered items # same t1 = (1, 2) t2 = 1, 2 print(t2) # not same, parens needed to avoid syntactic ambiguty print("a", "b", "c") # a b c print(("a", "b", "c")) # ('a', 'b', 'c') # useful for line splitting t3 = ( 1, 2, 3 ) # different data types welcome = "Welcome To My ...
true
daee7e883daa846cb144581ec5742fee0364532b
jsutch/Python-Algos
/number_to_string.py
1,868
4.375
4
#!/usr/local/bin/python #Write a program that takes an array of numbers and replaces any number that's negative to a string. For example if array = [-1, -3, 2] after your program is done array should be ['somestring', 'somestring', 2]. my_array = [-3, 3, -50, 10, 14, -2, 21, -4] loop = 0 while loop < len(my_array): ...
true
0a2a47e2842648a981f2d4bfe26bb13573fe1050
jsutch/Python-Algos
/insertion_sort.py
362
4.25
4
def insertionSort(arr): """ move right through the unsorted portion of a list, ordering to the left in the sorted portion arr[0] is alwys the first sorted element """ for i in range(1,len(arr)): k = arr[i] j = i -1 while j >=0 and k < arr[j]: arr[j + 1] = arr[j] ...
true
c31fb320ee4830a6af609bc5b1ae95a2944b013b
jsutch/Python-Algos
/eliminate_negatives.py
913
4.5625
5
#!/usr/local/bin/python #Given an array of multiple values (e.g. [0, -1, 2, -3, 4, -5, 6]), write a program that removes any negative values in that array. Once your program is done, the array should be composed of only the non-negative numbers, in their original order. Do this without creating a temporary array; on...
true
85553963f3926f4250bd960cbdb557548955675f
nadiannis/simple-command-line-programs-in-python
/mini_programs/palindrome.py
274
4.1875
4
### Created on 26-04-2019 while True: text = input('Enter a text (blank to stop): ').lower() rev_text = text[::-1] if text == '': break elif text == rev_text: print('It is palindrome.\n') else: print('It is not palindrome.\n')
true
4a5ea783a332458a50413675fd479311b38f00bf
katrinviktoria/katrin-viktoria
/int_seq.py
500
4.3125
4
num = int(input("Enter an integer: ")) total = 0 even = 0 odd = 0 biggest = 0 if num > 0: while num > 0: if num > biggest: biggest = num total = total + num print("Comulative total: ", total) if num % 2 == 0: even += 1 else: odd += 1 ...
true
be2f7e5c8a217b9201ed8fd58a4ba8c5f8dbadbe
jailukanna/Python-Projects-Dojo
/10.Python Code Challenges/Level_02/03.01.waiting_game_counter.py
787
4.125
4
import random import time def waiting_game_counter(): target = random.randint(2,6) print(f"Your target time is {target} seconds.") print(f"--- How to play - Press Enter to Begin and press Enter again after {target} seconds. --- \n") input("--- Press Enter to Begin ---") start_time = time.perf_coun...
true
b4a4a9b5c0f72f469c88d4d557272d222d8e951a
jailukanna/Python-Projects-Dojo
/11.Learning Python - JM/map.py
339
4.5
4
names = ['Jerry', 'Kramer', 'Elaine', 'George', 'Newman'] # Use map to apply str.upper to each element in names names_map = map(str.upper, names) # Print the type of the names_map print(type(names_map)) # Unpack names_map into a list names_uppercase = [item for item in names_map] # Print the list created above pri...
true
c28e3cd726a09e6c4b7509a34b492c4ea4ff3057
jailukanna/Python-Projects-Dojo
/15.Python Decorators - JM/01.Functions/fibonacci_three.py
421
4.46875
4
def fibonacci_three(a, b, c): '''Accepts as 3 input fibonacci numbers''' def get_three(): '''returns 3 fibonacci numbers''' return a, b, c return get_three if __name__ == "__main__": print(fibonacci_three(1, 2, 3)) f = fibonacci_three(1, 2, 3) print(f) # as f is assigned w...
true
3c9842a23e978de2e061a8337eec5af910569edd
jailukanna/Python-Projects-Dojo
/04.100 Python Exercises Evaluate and Improve Your Skills - AS/Exercise 76-100/exercise80.py
1,973
4.34375
4
# Create a program that asks the user to enter a new password and # check that the submitted password should contain # at least one number, # one uppercase letter and # at least 5 characters. # If the conditions are met, print out the reason # why pointing to the specific condition/s that has not been satisfied....
true
9eded6cba9d9d5efa2e320fbc67f3c2480b9ef9a
jailukanna/Python-Projects-Dojo
/04.100 Python Exercises Evaluate and Improve Your Skills - AS/Exercise 51-75/exercise_72.py
1,230
4.21875
4
#create a script that let the user type in a search term and opens and search on the browser for that # term on google # Answer # import requests # user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36' # user_input = input('Enter anything t...
true
a0e7cda7f5264468dda3aa16063a90438a6265a1
jailukanna/Python-Projects-Dojo
/12.Python Object Oriented Programming - JM/01.OOP/instance.py
1,076
4.5
4
# Python Object Oriented Programming by Joe Marini course example # Using instance methods and attributes class Book: # the "init" function is called when the instance is # created and ready to be initialized def __init__(self, title, author, pages, price): self.title = title self.author =...
true
933fbc4faa972829646d3ecb518dbc23d0444ec3
jailukanna/Python-Projects-Dojo
/04.100 Python Exercises Evaluate and Improve Your Skills - AS/Exercise 26-50/exercise_41.py
718
4.1875
4
# Question: Create a script that generates a text file with all letters of # English alphabet inside it, one letter per line. # Answer: import string with open("output_41.txt", "w") as file: for letter in string.ascii_lowercase: file.write(letter + "\n") # Explanation: # The ascii_lowercase property of...
true
a6390e27e807ef118c69f888875df932da0ff3e9
jailukanna/Python-Projects-Dojo
/04.100 Python Exercises Evaluate and Improve Your Skills - AS/Exercise 01-25/exercise_09.py
468
4.21875
4
# Question: Complete the script so that it prints out a list slice containing the last three items of list letters . letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] # Expected output: # ['h', 'i', 'j'] # Answer: print(letters[-3:]) # Explanation: # [-3:] means from item with index -3 (i.e. h ) to t...
true
c30d0ebee9991638aafd9123b4ed896bb1f03490
jailukanna/Python-Projects-Dojo
/04.100 Python Exercises Evaluate and Improve Your Skills - AS/Exercise 76-100/exercise88.py
1,297
4.15625
4
# Question: Create a script that uses the attached countries_by_area.txt file as data source # and prints out the top 5 most densely populated countries # Expected output: # India # Pakistan # Nigeria # China # Indonesia # Hint 1: Use pandas. # Hint 2: Once you load the data as a pandas dataframe, create a new co...
true
0d576826fc9e0b07b1d66d03487e3dfa750c127f
jailukanna/Python-Projects-Dojo
/13.Learning Python Libraries/01.Learning Python Standard Library - KH/01.Python Built In/01_01_LogicalOperators.py
737
4.25
4
# Python Logical Operators: And, Or, Not: # What is a Boolean? isRaining = False isSunny = True # Logical Operators -> Special Operators for Booleans # AND # true and true --> true # false and true --> false # true and false --> false # false and false --> false if isRaining and isSunny: print("Rainbow might app...
true
6fdf43857f7760c4b34346cef2f4535eb2bcb921
jailukanna/Python-Projects-Dojo
/04.100 Python Exercises Evaluate and Improve Your Skills - AS/Exercise 01-25/exercise_07.py
510
4.5
4
# Question: List slicing is important in various data manipulation activities. Let's do a few more exercises on that. # Please complete the script so that it prints out the first three items of list letters. letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] # Expected output: # ['a', 'b', 'c'] # Answe...
true
e991a6043acab1acabdc3c6c904047378b288c53
aparnakn/myworkspace
/pythonII/abc_demo.py
1,363
4.34375
4
''' Teach how mixins work, what inheritance is really about, how to use multiple inheritance, and how to use ABCs (abstract base classes) to impose discipline on mixins. This is all about code re-use! ''' from abc import ABCMeta, abstractmethod class Capper: def capitalize(self): return ...
true
68dba304809d3a0b49fd8cf08d16674394df519c
MichaelGatesDev/CSC221_PSU
/lab09/products.py
1,379
4.21875
4
#!/usr/bin/env python3 # Michael Gates # 6 November 2017 # Binary Search # Function to read the names and serials into lists def getLists(): infile = open("products.txt",'r') line = infile.readline() names = [] numbers = [] while line != "": line = line.strip() name, number = l...
true
cb6832e27c6caab9497102338c13ef541759500a
jaikherajani/PythonCodes
/head_first/c3p3_initializing_dictionary.py
913
4.15625
4
# though dictionaries are dynamic but we can't just try to update the # value of the key that doesn't exists (has not been initialized) # empty dictionary fruits = {} fruits['apples'] = 10 # trying to update value of the non-existent key, throws KeyError: 'bananas' # fruits['bananas'] +=1 # to sort out we can use 'i...
true
2979b36e0d8eaa60130736f4f7411eac96a3746a
jaikherajani/PythonCodes
/head_first/c2p1_vowels_list.py
723
4.1875
4
# list : an ordered mutable collection of objects # it is just like an array but is dynamic in nature and heterogenous # list of vowels vowels = ['a','e','i','o','u'] # an empty list el = [] # word in which we have to check for vowels word = "Milkiway" # "in" is used to see if something is inside of some other thin...
true
ebd5c71bed2eb930c81689bec98a9b7bb28b3e8f
reddyprasade/Python-Basic-For-All-3.x
/Module/Clock_Pro.py
2,073
4.5625
5
""" The class Clock is used to simulate a clock. """ class Clock(object): def __init__(self,hours,minutes,seconds): """ The Parmenter hours,minutes,seconds have to be integers and must satisfy the following equations: 0 <= h < 24 0 <= m < 60 0...
true
a38d16f176e302f7a8f5210949fa300056ddfefa
reddyprasade/Python-Basic-For-All-3.x
/username.py
506
4.3125
4
# username.py # Simple string processing program to generate usernames. def main(): print("This program generates computer usernames.\n") # get user's first and last names first = input("Please enter your first name (all lowercase): ") last = input("Please enter your last name (all lowerca...
true
4d751ef069f6f4eb637a02210491022b4f98cf40
reddyprasade/Python-Basic-For-All-3.x
/numbers2text.py
687
4.40625
4
# numbers2text.py # A program to convert a sequence of Unicode numbers into # a string of text. def main(): print("This program converts a sequence of Unicode numbers into") print("the string of text that it represents.\n") # Get the message to encode inString = input("Please ...
true
c696d28283b5f913932969b52ecfea58403a8c37
reddyprasade/Python-Basic-For-All-3.x
/Module/Run.py
1,370
4.15625
4
""" Modul, which implements the class CalendarClock. """ from Clock_Pro import Clock from Calendar_pro import Calendar class CalendarClock(Clock, Calendar): """ The class CalendarClock implements a clock with integrated calendar. It's a case of multiple inheritance, as it inherits ...
true
475a78e79a5e2feffa07bfb6f00a6ff23dfdcd19
reddyprasade/Python-Basic-For-All-3.x
/futval_graph3.py
1,181
4.46875
4
# futval_graph3.py from graphics import * def drawBar(window, year, height): # Draw a bar in window starting at year with given height bar = Rectangle(Point(year, 0), Point(year+1, height)) bar.setFill("green") bar.setWidth(2) bar.draw(window) def main(): # Introduction pri...
true
e781040f6ce67572c5065364c16fdf36e0cefbf3
MehranJanfeshan/python-samples
/statements/if.py
275
4.28125
4
# if/else hungry = True if hungry: print('I am hungry!') else: print('I am not hungry!') # if/elif/else my_number = 1 if my_number == 2: print('My number is 2') elif my_number == 3: print('My number is 3') else: print('My number is not 2 and is not 3')
true
2f439995ca0aa3a4dbfffba30349b2bf3891552c
MehranJanfeshan/python-samples
/data-structures/dictionary.py
671
4.375
4
# Dictionaries are not in order so, if you iterate over them you may not get them in order my_dict = {'key1': 'value1', 'key2': 'value2'} print(my_dict) # get value for the key print(my_dict['key1']) # dictionary is very flexible and can hold list, or another dictionary my_dict2 = {'key1': [1, 3, 4, 5], 'key2': {'key...
true
ceba4dc7694dccf59552a3e28a23a574d3dca8e8
IvanovOleg/python-programming-masterclass
/DateAndTime/timechallenge.py
1,636
4.53125
5
# Create a program that allows a user to choose one of # up to 9 time zones from a menu. You can choose any # zones you want from the all_timezones list. # # The program will then display the time in that timezone, as # well as local time and UTC time. # # Entering 0 as the choice will quit the program. # # Display the...
true
836bc7d8e16b7543f42a853f308c15270af86d1b
IvanovOleg/python-programming-masterclass
/Sets/challenge.py
399
4.53125
5
# Create a program that takes some text and returns a list of # all the characters in the text that are not vowels, sorted in # alphabetical order. # # You can either enter the text from the keyboard or # initialise a string variable with the string. text_string = "My name is Oleg." vowels = frozenset("aeiouyAEIOUY") ...
true
aebe284d0f89b788f4b8a5459eb0d5833213e9d2
jzhangfob/jzhangfob.csfiles
/CreditCard2.py
1,869
4.15625
4
# File: CreditCard.py # Description: Create a program that will determine if a credit card is valid, as well as what type it is # Student Name: Jonathan Zhang # Student UT EID: jz5246 # Course Name: CS 303E # Unique Number: 50860 # Date Created: 4/9/2016 # Date Last Modified: 4/9/2016 ...
true
0ae80c8de74c4f18b1da4f99a749ae1279f6ff04
jzhangfob/jzhangfob.csfiles
/DNA.py
2,580
4.125
4
# File: DNA.py # Description: Create a program that will output the largest matching nucleotide sequence between pairs of DNA strands # Student Name: Johnny Zhang # Student UT EID: jz5246 # Course Name: CS 303E # Unique Number: 50860 # Date Created: 3/21/2016 # Date Last Modified: 3/22/201...
true
28697161634b3e2102cee47ead24e4b45ccab46e
Mayank-Bhatia/Pythagorean-triples-checker
/triples_checker.py
1,460
4.28125
4
print('Welcome to the Pythagorean Triples Checker.' '\n' '\n' 'This simple program checks to see whether your choice of' '\n' 'three side-lengths are able to form a right-angled triangle.') happy_message = 'Yes! These are the sides of a right-angled triangle.' neutral_message = 'These sides do not form a r...
true
df87e91eeea83425026dbb4544387f533cef66dc
jomibg/snippets-python
/Arrays/ContinuousSum.py
701
4.15625
4
# for given array count biggest continuous sum # (sum consisting of successive elements) # array can contain positive and negative integers def max_continuous_sum(arr): print(f'Counting max sum for {arr}:') if len(arr) == 0: raise Exception('Array must contain at least one element') current_sum=max_sum=arr[0] ...
true
b97946ae6af2480795971ca6984c38912ef9ea6f
npatel007/Computer-Science-Notes
/Data Science/lab04-solutions/lab04-solutions/select_v2.py
753
4.125
4
import sys # Check we have enough arguments if len(sys.argv) < 3: print("Must specify at least two command line arguments") # exit the script sys.exit() # Find out what line numbers we want line_numbers = [] try: for s in sys.argv[2:]: # convert string to integer num = int(s) line_numbers.append( num ) exce...
true
edb912d61e354e291d4917a9c102ac74b559083c
RYANCOX00/PANDS_PROBLEM_SHEETS
/5.SquareRoot/squareRoot.py
868
4.5
4
# A program that finds the square root of a number using Newtons Method. # Author: Ryan Cox # Creating a function squareRoot to be recalled later. def squareRoot(squared, root=1000): # Arguement 1 parameter from code below. Arguement 2 parameter set to 1000. for i in range(root): # The for loop will use the range...
true
465d0cb9019d1a61a3fba3e4ac32fd1e5857f2ec
gruntfutuk/codecoach
/week3/my_python_file.py
396
4.28125
4
# example script to print the command line arguments # should be invoked with the command line: # python my_python_file.py 45 'John Smith' import sys # imports the sys module which has the code we need x = sys.argv # assigns to x a tuple of the arguments from the command line print(x[0]) # should output my_pytho...
true
20cabd2f3d6a3e2caeb2ddf2c1f8969f4d9483ca
pythonck12repo/Python_Level_1
/simple calculator/simplecalculator.py
638
4.4375
4
print("Simple Calculator") #Use of print statement x = 10 #Integer data type can be changed y = 20 #Integer data type can be changed sum = x + y #Sum of x and y difference = x - y #Difference of x and y product = x * y #Product of x and y quotient = x / y #Quotient of x by y remainder = x % y #Remainder of x by y pri...
true
34725fd6235ed180b4e111f75c6c405be8ad0d2a
alesalsa10/python_course
/cats_everywhere.py
559
4.375
4
# Given the below class: class Cat: species = 'mammal' def __init__(self, name, age): self.name = name self.age = age # 1 Instantiate the Cat object with 3 cats cat1 = Cat('cat1', 3) cat2 = Cat('cat2', 4) cat3 = Cat('cat3', 7) cats_list = [cat1, cat1, cat3] # 2 Create a function that finds ...
true
54c9763b9bb0125633120d2fe821da67e602f07e
nimirthon/acadview-projects
/ExcersiceFiles/largestofthree.py
475
4.4375
4
# program to find maximum between three numbers print ("Enter any three numbers: ") num1 = int(input()) num2 = int(input()) num3 = int(input()) flag = 0 if num1 > num2 and num1 > num3: maximum = num1 flag = 1 elif num1 < num2 and num3 < num2: maximum = num2 flag = 1 elif num1 < num3 and num2 < num3: ...
true
1c99a8fddef99c5ea6b8e985c2225fb5af86f487
ktp-forked-repos/algorithms-8
/python/dynamic_programming/longest_palindromic_subsequence/longest_palindromic_subsequence.py
1,207
4.125
4
# coding=utf-8 """ Given a sequence, find the length of the longest palindromic subsequence in it. if the given sequence is “BBABCBCAB”, then the output should be 7 as “BABCBAB” is the longest palindromic subseuqnce in it. “BBBBB” and “BBCBB” are also palindromic subsequences of the given sequence, but not the longest...
true
e5e5d2d31f4a8122c260bb23ebb66a65fba56270
khushboo1510/leetcode-solutions
/30-Day LeetCoding Challenge/June/Medium/468. Validate IP Address.py
2,089
4.125
4
# https://leetcode.com/problems/validate-ip-address/ # Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither. # IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, separated by dots (...
true
cba41f115d833d34701da39e6d1608c41a9cdb0e
khushboo1510/leetcode-solutions
/30-Day LeetCoding Challenge/August/Medium/211. Add and Search Word - Data structure design.py
1,908
4.125
4
# https://leetcode.com/problems/add-and-search-word-data-structure-design/ # Design a data structure that supports the following two operations: # 1. void addWord(word) # 2. bool search(word) # search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . mean...
true
829e0fc8f9242e5450388c582ec97d1f90a3277f
khushboo1510/leetcode-solutions
/30-Day LeetCoding Challenge/April/Medium/Leftmost Column with at Least a One.py
1,863
4.15625
4
""" (This problem is an interactive problem.) A binary matrix means that all elements are 0 or 1. For each individual row of the matrix, this row is sorted in non-decreasing order. Given a row-sorted binary matrix binaryMatrix, return leftmost column index(0-indexed) with at least a 1 in it. If such index doesn't exi...
true
d5020b423c339b33020328555b7ff4f9b7cc45c2
gauravjha13/LetsUpgrade-Python-for-Beginners
/assignment 1.py
458
4.21875
4
#LetsUpgrade Assignment 1 #To build a calculator that does addition, subtraction, multplication and division print("-----SIMPLE CALCULATOR-----") print("Enter your first number : ") x = int(input()) print("Enter your second number") y = int(input()) add = x + y sub = x - y mul = x * y div = x / y print...
true
fa00e1f4562539674c9f6378ca36e3428287a6bc
juliencol/python-challenges
/level-2/level2.py
1,470
4.5
4
# Warning # All following functions can take up to 3 arguments as input but should only return one value as output # Exercise 1.1 (medium) # Implement the following function get_sum_of_even_elements_in_list_with_for_loop # input: a list of integers L # output: an integer equals sum of all element in L # restrictions: ...
true
0d989dfa624fe06659fbeac06c938cdf4da801aa
nantsou/udacity-data-analyst
/proj-3-wrangle-open-street-map-data/src/mapparser.py
652
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # mapparser.py # Nan-Tsou Liu """ Uses to invstigate how many of each tag there are. Print the dictionary with tag name as keys and the number of times as the value. """ import xml.etree.cElementTree as ET import pprint def count_tags(filename): tags = {} parsed = E...
true
3849b944ea2dabb9078e9b4f136d688afd0e046b
kklan99/algorithms
/lib/python/linked_lists/linked_list.py
1,075
4.21875
4
class Node(object): def __init__(self, val): self.val = val self.next = None def print_list(self): p = self string = "" while p != None: string += str(p.val) + " " p = p.next print(string) # utility function to create a linked list from a...
true
4332355db3db909f0aaeaff7edbff315bd1442e6
kklan99/algorithms
/leetcode/longest_common_prefix/lcp.py
1,081
4.125
4
def longest_common_prefix(strs): if strs == []: return "" # Find minimum length string, because the longest prefix will be found in # the shortest string. min_str = min(strs, key=len) prefix = "" low, high = 0, len(min_str) - 1 # Do binary search on min_str, finding the longest com...
true
3e7aed839f91f096ac9c9be1124ba638927c1f2b
wenwang2/assignments
/calculator.py
383
4.21875
4
# This function adds two numbers def add(a, b): return a + b # This function subtracts two numbers def subtract(a, b): return a - b # This function multiplies two numbers def multiply(a, b): return a * b # This function divides two numbers def divide(a, b): return a / b print("I'm going use the calcul...
true
2a4f61a8cf5a0b1eb65957209bdf15215f4845aa
craymondd/assignment7.2
/assn7.2.py
884
4.34375
4
## 7.2 Write a program that prompts for a file name, then opens that file and reads through the file, looking for ## lines of the form: ## X-DSPAM-Confidence: 0.8475 ## Count these lines and extract the floating point values from each of the lines and compute the average of those ## values and produce an output as...
true
5099ad44485f89e684e63e4d89b976e1861c87d7
sunnysidesounds/InterviewQuestions
/general/merge_sorted_arrays.py
1,925
4.28125
4
# Given 2 sorted arrays merge them into one array # [1, 3, 4, 6, 7, 8], [2, 5, 9, 12, 15, 25, 99] # Method 1 : def merge_arrays(arr1, arr2): merged_list = (arr1 + arr2) # combine lists merged_list.sort() # used pythons built in to sort the list return merged_list # returnn the merged sorted list # Me...
true
26450bffaab0b0d58bca73fefd0d8064f770bd5c
sunnysidesounds/InterviewQuestions
/general/flatten_binary_tree.py
2,451
4.15625
4
""" Write a function that takes in a Binary Tree, flattens it, and returns its leftmost node. A flattened Binary Tree is a structure that's nearly identical to a Doubly Linked List (except that nodes have left and right pointers instead of prev and next pointers), where nodes follow the original tree's ...
true
ec037d8c92243e6680f49bca32443e5bd5ad9f85
Tejaswini-Jayashanker/ClassesAndFiles
/read_notes.py
1,315
4.40625
4
'''This is one approach to the given Problem Statement: Write a function read_notes() that does the following A. First asks the user's name. B. Asks the user to enter a word. C. Print all the notes with that word in the user's notes, as created using record_notes() . record_notes : Write a function record_notes...
true
67f8d75315e3015d56024e9651be2c5fb347e214
janlee1020/Python
/shapeCalculator.py
2,086
4.3125
4
#shapeCalculator.py from math import pi def rectArea(length, width): area=length * width return area def circleArea(radius): area=pi*radius*radius return area def welcome(): print("Welcome to the shape calculator!") name=input("What is your name? ") return name def askDim...
true
2859e4a3d06ebef70b9b6f7880554fe302983726
janlee1020/Python
/Rhombus.py
585
4.1875
4
#Rhombus.py #Janet Lee #Lab 2 MW 2:15) #Compute the area and perimeter of a rhombus import math def main(): #Ask for the length of a side e = eval(input("Enter length of a side: ")) #Ask for the length of the longer diagonal d = eval(input("Enter the length of the longer diagonal: ")) ...
true
2fb350525e93cd0ab4414b96c1659951469e180d
MikaelTornwall/ml_challenge
/knn.py
845
4.21875
4
import numpy as np from sklearn.neighbors import KNeighborsClassifier # KNN of Unknown Data Point # To classify the unknown data point using the KNN (K-Nearest Neighbor) algorithm: # Normalize the numeric data (check if necessary with sklearn) # Find the distance between the unknown data point and all trainin...
true
a8cef3c5e285e212a327608fea2cc78466993402
lope512q09/Python
/Chapter_4/Lopez_TIY4.10.py
206
4.1875
4
num = list(range(1,22)) print(num) print(f"The first 3 items in this list are: {num[:3]}") print(f"The middle 3 items in this list are: {num[9:12]}") print(f"The last 3 items in this list are: {num[-3:]}")
true
0a3d12a6b56126b18fd36e402813cde8b0ed2af2
lope512q09/Python
/Chapter_6/Lopez_Kata_Binary_Search.py
1,302
4.15625
4
from bisect import bisect_left # First Attempt: (iterative function using bisect function) def binary_search_iterative(array, x, lo=0, hi=None): # can't use array to specify default for hi if hi is None: hi = len(array) # hi defaults to len(array) pos = bisect_left(array, x, lo, hi) # find insert...
true
90680b2a67af24e9227f475bb859793e4dbc4606
arg2211/Python
/mathfunction_cube.py
317
4.375
4
''' This is a simple function using an "if else" statement. ''' def cube(number): print number ** 3 def by_three(number): if number % 3 == 0: return cube(number) else: print "That number is not divisible by 3 - try again!" number = int(raw_input("Choose a number: ")) by_three(number)
true
cd6d30de2acc930a6c7df4dc027376ab633925ad
prabwizkid/CrackingTheCodingInterview
/DataStructures/LinkedList.py
1,979
4.125
4
class Node: # Function to initialise the node object def __init__(self, data): self.data = data self.next = None class LinkedList: # Function to initialize head def __init__(self): self.head = None def insertEnd(self, data): node = Node(data) if self.head...
true
2f0aa1309f9140a530ba6e810ee0b317736a4f9f
markcharyk/public-library
/Library.py
2,735
4.3125
4
#!/usr/local/bin/python2.7 #Author: Mark Charyk #Version 1.0 class Book(object): """A class that makes books for Shelving in a Library""" def __init__(self, title, author, genre, lib): self.title = title self.author = author self.genre = genre self.lib = lib lib.unshelve...
true
7814a54d8eb675ede5fed2cd116459b372b8bf44
Iamprakashkhatri/basics
/intern/common letters.py
749
4.25
4
# The function is expected to return an integer. # The function accepts an string array(list of input) and an integer(length of input) as parameters. def logic(inputs, input_length): alphabet='abcdefghijklmnopqurstuvwxyz' count=0 temp=0 for word in inputs: for j in range(len(word)): ...
true
58398221d978dd001a8295e4bf69078013c119ba
Iamprakashkhatri/basics
/regularexpression.py
377
4.125
4
import re #\d equivalent to [0-9] p =re.compile('\d') print(p.findall('I went to him at 11 A.M on 4th July 1886')) #\d+ will match a group on [0-9],group of one or greater size p=re.compile('\d+') print(p.findall('I went to him at 11 A.M on 4th July 1886')) txt='The rain in Spain' x=re.findall('portugal',txt) if(x): ...
true
cfe6b62effa4b8e9acaf4e957b730425dd96b44b
AdityaPunetha/Python-Thunder
/diffOfSquares.py
380
4.125
4
''' Probem Task : This program returns the difference in areas of two squares. Problem Link: https://edabit.com/challenge/NNhkGocuPMcryW7GP ''' def square_areas_difference(r): print("The difference in area of incircle square and circumcumcircle square is : " + str(((2*r)**2)-(r**2)*2)) radius = int(float("Enter th...
true
4c8cc57d8982da347a4349e9023673c90ec0ed50
ninankkim/python-functions
/tempconver.py
807
4.125
4
temperature = [] while True: action = input('Would you like to convert to?\n(C TO F, F TO C, STOP)').upper() if action == "C TO F": celcius = int(input('Please enter the celcius temperature you would like to convert to fehrenheit: \n')) fehrenheit = (celcius * 9/5) + 32 print ("The conv...
true
6d1389723357609ea1a25c30bf288434e77e12f4
NehaDua-BITS/python-learning
/if-else.py
692
4.1875
4
#IF, ELSE sunny = True if sunny: print("It's sunny") print("It's too sunny") print("It's too much sunny") else: print("It's not sunny") print("It's not sunny at all") #IF, ELSE & ELIF num = 4 if num > 10: print("num > 10") elif num > 5: print("5 < num <= 10") elif num > 2 and num%2==0: ...
true
415aefa786e67e4690d718ce532c395947898700
kinga-k-farkas/Project-Euler
/number4.py
1,903
4.3125
4
# -*- coding: utf-8 -*- """ A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ from math import sqrt #identifying a pallindrome def is_pallindrome(n): ...
true
80a88d746bbd5efa35b5f592fc09050171e924ad
balam909/python
/base/006-functions.py
2,792
4.84375
5
print("To define a new function, you use 'def+<your_function_name>+(+<your_params_comma_separated>+)', example: 'def myFunction(param1, param2, ..., paramn)'") # Creating a simple function and calling it print("Creating simple function and calling it") def sayHello(name): print("Hello",name) sayHello("balam909") # D...
true
34577e9df9dcf6643b9f655a9c060c2bfe311022
Basma23/snakes-cafe
/snakes-cafe/snakes_cafe/snakes_cafe.py
1,633
4.15625
4
def snakes_cafe(): print(''' ************************************** ** Welcome to the Snakes Cafe! ** ** Please see our menu below. ** ** ** To quit at any time, type "quit" ** ************************************** Appetizers ---------- Wings Cookies Spring R...
true
9291e5772740d28497609c39777aa34181bb1716
canokulmus/CENG_METU
/Ceng111/PYTHON-1/example4.py
1,269
4.1875
4
# EXAMPLE-4 # Write a script which will take input as a list of 3 groups of strings where each group is separated by a pipe '|'. # Your solution will print a list which compounds all 3 groups in a special order. # The ordering will be done in the following way: # elements of group1 in the original order + elements...
true
e0937674ad6d996834436cd63ff6dd647297fb9d
canokulmus/CENG_METU
/Ceng111/PYTHON-2/example3.py
1,709
4.21875
4
# EXAMPLE-3 # Write a function that takes two arguments whose name is "isSpaceEnough". # The first argument is available free space on hardisk which is a string. # It can be in terms of MB or GB. # The second parameter is also a string which is the size of the folder to be copied which can be in terms of MB, GB.(e...
true
b19e4e2e5bb820a4ba1c12cfc0cde3881419c10a
ChrisIngham/PythonPratice
/TraingularNumber.py
557
4.15625
4
''' Take a number and turn it into its triangular number everytime a base 10 number increases it adds an extra row to the bottom of a triangle 1 1 1 = 1 1 1 = 2 so 3 in triangular 1 1 = 3 which is 6 in triangular ...
true