blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
51d4e110fa914f72d9acbf1a0f2e45c8c726650f
mystor/ugrad-thesis
/figs/canasta.py
750
4.125
4
def value(num, suit): if num <= 2: return 20 elif 3 == num and suit in ['H', 'D']: return 100 # red 3s are worth 100 elif 3 <= num < 8: return 5 elif 8 <= num: return 10 def main(): # Read in the type of card. numbers := ['A', '2', '3', '4', '5', '6', '7', '8', '...
true
2dce48e58b3a4682acb9787e9bf06f6b82a9f2ad
rosajong/population
/Population.py
1,606
4.34375
4
""" Define class Human which has the following : gender hair eyes AGE For every baby a Human gets Population must be += 1 Only women can have babies Human grows from baby > child > adolescent > adult The attributes gender hair eyes are randomly given to Human Give population a starting number and make that amount of h...
true
a4d8597b95e2597a4ba85080248dc67819d515a6
mhiloca/PythonBootcamp
/challenges/valid_parentheses.py
539
4.125
4
def valid_parentheses(string): # check = [] # for p in string: # if p == '(': # check.append('(') # if p == ')': # check.remove('(') if check else check.append('(') # return not check count = item = 0 while item < len(string): if string[item] == '(': ...
true
b8115f4ebdea6c62c79d545587ff159b893f046d
melipefelgaco/project_madLibs
/project_madLibs.py
1,397
4.3125
4
# Reads text files and lets user add their own text anywhere the words ADJECTIVE, NOUN, VERB or NOUN appears in the text. # Read the file panda.txt stored on this same folder. # Path = yourpath # The results should be printed to the screen and saved to a new text file. (newpanda.txt) from pathlib import Path import os...
true
bd43128053f6a3e8e88e860cd103f09f8288d8e7
marioabz/python-cheat-sheet
/data_types/collections/dictionaries.py
1,423
4.375
4
# Dictionary is a collection that stores values in a key-value fashion # Dictionaries are changeable and don't allow duplicates person = { "age": 67, "name": "Jinpig", "last_name": "Xi", "ocupation": "President", "country_of_origin": "China", } # Accesing the 'age' key of dict 'person' print(pers...
true
83144e045f2852d5219c6d7c4b73b67d8fe53b29
lee000000/leetcodePractice
/434.py
1,015
4.125
4
''' 434. Number of Segments in a String Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. Please note that the string does not contain any non-#printable characters. Example: Input: "Hello, my name is John" Output: 5 ''' class Solution(object)...
true
25f8cf1be395e35ac62c3334e9b6264512a9abc6
pramo31/LeetCode
/Completed/group_anagrams.py
662
4.125
4
from typing import List """ Given an array of strings, group anagrams together. """ class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: anagram_dict = {} for word in strs: sorted_word = "".join(sorted(list(word))) if (sorted_word in anagram_dict.ke...
true
9817dccf295e2f42f3548a9e1282e5ba71557f66
IndranilRay/PythonRecipes
/GeeksForGeeks/Int2Bin.py
247
4.1875
4
""" Program displays binary equivalent of an integer > 0 """ def display_bin(n): if n == 0: return display_bin(n//2) print(n % 2) if __name__ == "__main__": number = input("Enter a number") display_bin(int(number))
true
bb3455c61e127d8462c979b13ac4c61104cafcca
IndranilRay/PythonRecipes
/GeeksForGeeks/stringIsPalindromeRecursive.py
526
4.34375
4
""" WAP to check if input string is palindrome recursive version """ def isPalindrome(input_string, start=0, end=0): if start >= end: return True return (input_string[start] == input_string[end]) and isPalindrome(input_string, start+1, end-1) if __name__ == '__main__': string = input("Enter the...
true
f812c8ea740c64c629b3c325152c12d249b31412
Supermac30/CTF-Stuff
/Mystery Twister/Autokey_Cipher/Autokey Encoder.py
327
4.1875
4
""" This script encodes words with the AutoKey Cipher """ plaintext = input("input plaintext ") key = input("input key ") ciphertext = "" for i in range(len(plaintext)): ciphertext += chr((ord(plaintext[i]) + ord(key[i]))%26 + ord("A")) key += plaintext[i] print("Your encoded String is:",cipher...
true
5a98e54f9762d2fab78ea8134bb80bb385dce851
vaibhavs33/RockPaperScissors
/loops.py
1,110
4.1875
4
keepPlaying = True player1 = input("What is player 1's choice? ") while(player1 != "rock" and player1 !="paper" and player1 != "scissors"): player1 = input("Please choose a valid choice (rock,paper, or scissors): ") # print(player1,"is the right choice") player2 = input("What is player 2's choice? ") while(pla...
true
ccfc5b68b5272b0ed16c06f5c44793e8dea81923
king-tomi/python-learning
/family.py
2,621
4.5625
5
class Family: """This is a program representation of a nuclear family. parent_name: name of the mother or father of the family. children_name: a list of the children in the family. child_gender: a list of the corresponding genders of each child.""" def __init__(self,parent_name,children...
true
e6e4a103b43fd3dae304d8b953ac6f3532e1851e
dexter2206/redis-classes
/examples/sets.py
980
4.15625
4
"""Basic examples of using sets.""" from redis import Redis import settings if __name__ == '__main__': client = Redis( host=settings.HOST, port=settings.PORT, password=settings.PASSWORD, decode_responses=True ) name = 'kj:set' # Create some set by adding elements to it...
true
87ec263519dcd85bc7b003549ff02d2421dd1aa4
LauraBrogan/pands-problem-set-2019
/solution-1.py
1,024
4.4375
4
# Solution to Problem 1 # Ask the user to Input any positive integer and output the sum of all numbers between one and that number. # n is asking the user to input a postive integer. n = int(input("Input a Positive Integer: ")) # If the user inputs a negative number or a zero the programe displays "this is not a pos...
true
c32e91fef72a2d2a87d0f63dca588965d3f83cd9
ericel/python101
/hypotenuse.py
1,882
4.25
4
import math # Calculates length of the hypotenuse of a # right trianle given lengths of other 2 legs def hypotenuse(a, b): # should return a float print(0.0) return 0.0 # return 0.0 hypotenuse(3, 4) # Calculates length of the hypotenuse of a # right trianle given lengths of other 2 legs def hypotenuse(...
true
d124c6551c0f8d07c3737d412b690cac1af08876
ericel/python101
/volume_of_sphere.py
982
4.34375
4
import math # Calculate the volume of a sphere def volume_of_sphere(r): print('returns a float 0.0') return 0.0 # Call to check function initial works volume_of_sphere(2) # Calculate the volume of a sphere def volume_of_sphere(r): # calculate cubed of radius r r3 = r ** 3 print('Sphere Radius cub...
true
f5ed880f569a31a33a77d7968835351baf81e70e
Fortune-Adekogbe/ECX_30_days_of_code_Python
/Python files/Fortune_Adekogbe_day_25.py
751
4.25
4
def desc_triangle(a,b,c): ''' This function takes in 3 integers a,b,c representing the length of the sides of a triangle and Returns a tuple of 2 elements whose first element is a string describing the triangle and second element is the area of the triangle... ''' s= (a+b+c)/2 area = ((s...
true
c5e1ebe304d4912e18203c00702e6d3f2967be21
Fortune-Adekogbe/ECX_30_days_of_code_Python
/Python files/Fortune_Adekogbe_day_23.py
736
4.40625
4
def find_Armstrong(x,y): ''' find_Armstrong is based on a definition for armstrong numbers that involves summing the cubes of the digits in the number. Parameters: x: an integer representing the start of the interval y:an integer representing the last number in the interval Returns: A list of all the armstro...
true
fbc42a844313b04a8c38ea4f5b7c08f4fb08a276
Fortune-Adekogbe/ECX_30_days_of_code_Python
/Python files/Fortune_Adekogbe_day_6.py
463
4.15625
4
def power_list(List): """ This function takes a list as parameter and returns its power list (a list containing all the sub lists of a particular super list including null list and list itself). """ if List==[]: return [[]] a=List[0] b=power_list(List[1:]) c=[] for d in ...
true
f34b7153bc2df4a97fcbbe8a41ebfcf7e5ffc0b2
DemetrioCN/random_walk
/1D_random_walk.py
1,028
4.25
4
# Random Walk in One Dimension # DemetrioCN import random # Choose the next step and add it to the previous one def walk_1D(steps): count = 0 for i in range(steps): walk = random.choice([(1),(-1)]) count += walk return count # Compute the distance from 0 def random_walk_1D(steps, atte...
true
5abb7140a4733fbbed83230dcea680826002f5f6
ian-gallmeister/sorting_algorithms
/pep8/radixsort.py
1,259
4.21875
4
#!/usr/bin/env python3 """ An implementation of radixsort """ import random SHOW_LISTS = True def radixsort(seq): """ The radix sort algorithm """ max_val = max(seq) oom = 0 #order of magnitude while max_val // 10**oom > 0: countingsort(seq, oom) oom += 1 #adapt to take arg for which...
true
535a90af8ae6c271edaa538259579ee69cc24c0f
ES2Spring2019-ComputinginEngineering/hw3-sofialevy
/ES2BubbleLevel.py
2,893
4.25
4
# HOMEWORK 3 --- ES2 # Bubble Level # FILL THESE COMMENTS IN #***************************************** # YOUR NAME: Sofia Levy # NUMBER OF HOURS TO COMPLETE: 6 # YOUR COLLABORATION STATEMENT(s): # I worked with Rene Jameson on this assignment. # I received assistance from Dr. Cross on this assignment. #*************...
true
1ff4255feadcfcd2d20c8de6c5622fefd2354f45
kmoreti/python-masterclass
/CreateDB/checkdb.py
321
4.15625
4
import sqlite3 conn = sqlite3.connect("contacts.sqlite") name = input("Please enter a name to search for: ") select_sql = "SELECT * FROM contacts WHERE name = ? " result = conn.execute(select_sql, (name,)) print(result.fetchone()) # for row in conn.execute("SELECT * FROM contacts"): # print(row) conn.close() ...
true
0ef62d90642adc8a915ce64ae750fd0ee554c2d8
mef21/GirlsWhoCode
/Lesson 1 - Variables/examples/example1.py
1,041
4.59375
5
""" WELCOME TO VARIABLES EXAMPLE 1 BEFORE YOU DO ANY CODING COPY THE BELOW TEXT INTO THE .replit FILE language = "python3" run = "cd 'Lesson 1 - Variables'; cd examples; clear; python3 example1.py" Below are a series of examples using different types of variables and how to manipulate them: """ """ STRING EXAMPL...
true
0d0f05a92e4d6662322708f86ccf50a94699938b
mef21/GirlsWhoCode
/Lesson 2 - Conditionals/examples/examples.py
888
4.46875
4
""" WELCOME TO CONDITIONAL EXAMPLES BEFORE YOU DO ANY CODING COPY THE BELOW TEXT INTO THE .replit FILE language = "python3" run = "cd 'Lesson 2 - Conditionals'; clear; cd examples; python3 examples.py" """ """ EXAMPLE 1 """ if(1 < 2): print("1 is less than 2") else: print("1 is not less than 2") """ EXAMPLE 2...
true
9a08902a1af1388c059b11369ec44726a9f09944
IgnacioZentenoSmith/notable_challenges
/All or Any.py
1,475
4.21875
4
''' CREDITS TO HACKERRANK FOR THIS CHALLENGE TASK You are given a space separated list of integers. If all the integers are positive, then you need to check if any integer is a palindromic integer. Input Format The first line contains an integer . is the total number of integers in the list. The second lin...
true
a21cc3d5bc986b700af3d5c863c0ef80b1d41b51
Samarkina/PythonTasks
/6.py
907
4.125
4
# Monthly interest rate = (Annual interest rate) / 12.0 # Monthly payment lower bound = Balance / 12 # Monthly payment upper bound = (Balance x (1 + Monthly interest rate)^12) / 12.0 balance = float(input("balance - the outstanding balance on the credit card: ")) AnnualInterestRate = float(input("annualInterestRate - ...
true
ea6a053af6727ae9a3c09ac44e21ad29230235a4
dfilter/udemy-flask-restapi
/section-2/29-lambda-functions.py
719
4.34375
4
def add(x, y): return x + y # Same as above function add = lambda x, y: x + y print(add(1, 2)) # lambda function can be executed without being named like this: sum_ = (lambda x, y: x + y)(5, 7) print(sum_) def double(x): return x * 2 sequence = [1, 3, 5, 9] doubled = [double(x) for x in sequence] # sam...
true
f04e411b6921aff654df609b8ac717beedd27b7c
Ellis-Anderson/Pluralsight_Python
/Getting_Started/hs_students.py
703
4.15625
4
class HighSchoolStudent(Student): """ Adds a High School Student to the list. :param name: string - student name :param student_id: integer - optional student ID """ # Derived/child class. Attributes, like school_name, can be overridden school_name = "Springfield High School"...
true
e8e49bbf5245a46172cd6e1b36124e3337c9de65
Ran05/cwd-marketing-bot
/bot.py
1,930
4.15625
4
def greetings(bot_name): outputLine = f"""===========================================================================""" print(outputLine) print("Hello! My name is {0}.".format(bot_name)) print("We'd like to help you with your digital marketing needs! \nWe'll help you build your brand online by creati...
true
249ffde4bd50f3d91ba7e4cf03bb0d76197a32d1
sheleh/homeworks
/lesson_25/task_25_3.py
1,176
4.375
4
# Implement a queue using a singly linked list. from lesson_25.task_25_1 import Node class Queue: def __init__(self): self._head = self._tail = None def is_empty(self): if self._head is None: return True else: return False def enqueue(self, item): ...
true
6d1bdf281cb4c1a2ece1b5944ece0aa444acfc4b
sheleh/homeworks
/lesson11/task_11_1.py
1,798
4.15625
4
#School #Make a class structure in python representing people at school. Make a base class called Person, a class called Student, # and another one called Teacher. Try to find as many methods and attributes as you can which belong to different classes, # and keep in mind which are common and which are not. For example,...
true
0340793c8ad45699b466d2a4d25e4f6ad630e7e1
sheleh/homeworks
/lesson3/task_3.py
807
4.1875
4
#Write a program that has a variable with your name stored (in lowercase) # and then asks for your name as input. The program should check if your input is equal to the stored name # even if the given name has another case, e.g., if your input is “Anton” and the stored name is “anton”, # it should return True. name = '...
true
0bde00df76938a0e0dbf9938b2ce4ccfce89b8a2
leecmoses/intro-to-cs
/18-how-programs-run/notes.py
2,624
4.1875
4
############# # Notes # # Lesson 18 # ############# ''' Algorithm - is a procedure that always finishes and produces the correct result Procedure - is a well defined sequence of steps that can be executed mechanically Equivalent Expressions * A property 'ord' and 'chr' is that they are inverses. * This means ...
true
e5952bd822051b4e4a0a5fb7f0f6a8c9d08ecbc3
Pav0l/Sorting
/src/searching/searching.py
2,544
4.21875
4
# STRETCH: implement Linear Search def linear_search(arr, target): res = False for i in arr: if arr[i] == target: res = i if not res: print('Linear Search: Target not found!') else: print(f'Linear Search: Found the target value at index {res}') # linear_search([0, ...
true
9d001981862c261062a6ae6b0507c5e24c9b2cc8
zackguerra/git_practice
/PycharmProjects/IntroToAlgorithmsPython/6_Conditionals/conditional_statements.py
373
4.25
4
# Conditional Statements # (if-else statements) # Getting user input # input(prompt) - atkes user input and returns as string # Later (Error handling and validation) age = int(input("Enter your age:")) # or use age = int(age) if age >= 21: print("You can start drinking!") elif 13 < age < 21: print("Study...
true
21949834637a1b26e3264dbe55536f0b35d23ec6
zackguerra/git_practice
/PycharmProjects/IntroToAlgorithmsPython/Labs/Lab_Binary_Linear_Search.py
1,607
4.375
4
# In this lab, you will be using two searching algorithms we covered in class to # search for a word in dictionary. Compare the performance for each algorithm. # You will have to output the number of steps for both algorithms when used for searching # for the same word. (case-insensitive) # Your output should look like...
true
8d0e859942bbf5c1c23304140465496ee8fb4f54
zackguerra/git_practice
/PycharmProjects/IntroToAlgorithmsPython/12_SortingAlgorithm/bubble_sort.py
887
4.21875
4
# Bubble Sort # - Time Complexity: O(n^2) # # For each scan, # For each comparison (two adjacent items), # if left item > right item: # "swap" two items items = [5, 2, 1, 4, 3] # Naive Bubble Sort -> can be improved! def naive_bubble_sort(items): steps = 0 for scan in range(len(items)):...
true
2f265398b7026b9291f91c99981fbc0024a12e96
np-n/Python-Basics-GCA
/Session 1/Variable.py
1,499
4.4375
4
"""-------------------------------------------------""" ##print("Hello World") # First program msg = "Hello World" ##print(msg) """-------------------------------------------------""" # Knowing the type of the variable ##print("Msg is of type: ", type(msg)) ##print("1 is of type: ", type(1)) ##print("-1 is of type:...
true
925f6c07306067409e400ce657ac9a00932c61e5
np-n/Python-Basics-GCA
/Session 3/reverse_string.py
431
4.25
4
""" Module to reverse a string either a word or sentence using loops and inbuilt methods """ sentence = "Python is beautiful" _reverse = [] # print(len(sentence)) # Using loops ##for c in range(len(sentence)-1, -1, -1): ## # print(sentence[c]) ## _reverse.append(sentence[c]) ## ### print(_reverse) ## ...
true
e1fb187e9da12e64a048cc922a2ef8c753f02200
8chill3s/py4e
/ex_5_2.py
546
4.1875
4
largest = None smallest = None while True: num = input('Enter a number: ') if num == 'done': break #validate input try: num = int(num) except: print('Invalid input') continue #compare integers if largest is None: largest = num elif nu...
true
641a2855da5e639eaa2b6f2bd0219fe29bbd39f1
techsoftw/General-Coding
/Python/lab8.2.py
1,644
4.21875
4
#!/usr/bin/python # NAME: Dylan Tu # FILE: lab8.2.py # DESC: Connect to sqlite3 database, insert and prints data import sqlite3 # sqlite3.connect creates a file named 'databasefile.db' on the system. connection = sqlite3.connect('week16.db') # The cursor is the control structure that traverses records in the database....
true
d3ac5b7e14663381177c3d0a2ca40d63cecfe139
Wambita/pythonprework
/looping/forloop/for_loop.py
327
4.375
4
#A for loop is used when one wants to repeat something a number of times. Just like the if statements, blocks of code in a for loop are indented, otherwise they will not run. numbers = [1,2,3,4,5] for number in numbers: print(number) letters = ['a','b','c','d','e','f','g','h'] for letter in letters: print(...
true
16108ab9efad2788494da28d46bb1074c77d9458
AJV1416/test2
/Story.py
981
4.21875
4
start = ''' You are now playing as Alice from Wonderland, Try and get through all the Disney characters! ''' keepplaying = "yes" print(start) while keepplaying == "yes" or keepplaying =="Yes": print("Mickey is your first character, make sure you answer his question to get through") userchoice = input("What i...
true
62d58174a8ded907a52059b474528397a55d694d
dlx24x7/Automate_boring_stuff_w_Python
/vampire.py
348
4.21875
4
# this code teaches you how to program # Its a great way to learn coding name = 'sam' age = 2001 print(age) if name == 'Alice': print('Hi, Alice.') elif age < 12: print('You are not Alice, kiddo.') elif age > 2000: print('Unlike you, Alice is not an undead, immortal vampire.') elif age > 100: print('Yo...
true
8518c2915a015826ba851b3f509e9b323d6d7bd5
bgoldstone/Computer_Science_I
/Labs/5_factorial.py
444
4.3125
4
# 5_factorial.py # A program that asks the user for input and tells user what that numbers factorial is # Date: 9/22/2020 # Name: Ben Goldstone num = 0 while num >= 0: num = int(input("Enter an integer (negative to quit): ")) factorial = 1 # if negative print a goodbye message if num < 0: print(...
true
d53451899b3bc1a4dc06537a2be24b93bf2a1ec4
syth3/Teaching-Tech-Topics
/Python/Loops/break_keyword.py
335
4.21875
4
print("Break Keyword with a while loop") counter = 0 while counter < 10: counter += 1 if counter == 3: print("Exit the loop entirely") break print(counter) print() print("Break Keyword with a for loop") for i in range(10): if i == 5: print("Exit the loop entirely") brea...
true
36f66aa5e656cc03fe2997b5c1817d454ee6566f
haticerdogan/python-3-sandbox
/lessons/intro_to_classes.py
2,572
4.1875
4
name = 'Me' age = 92 qaimah = [1, 2, 3] qamous = {"A":1, "B":2, "C":3} type(name) #=> <class 'str'> type(age) #=> <class 'int'> type(qaimah) #=> <class 'list'> type(qamous) #=> <class 'dict'> # class name must have capitol letter class Planet: # initializer (init function) that runs when we create a new insta...
true
c3939d358034b7645abb3cf0502b4a5541f927be
haticerdogan/python-3-sandbox
/lessons/comprehension.py
835
4.53125
5
# let's say we have a list of prizes and we want to double each one prizes = [5, 10, 50, 100, 1000] double_prizes = [] # create an empty array for prize in prizes: double_prizes.append(prize*2) print(double_prizes) # comprehension method: this gives the same values as above but is much shorter double_prizes = [pri...
true
77c108253545d0b02b5928afd024cc83d5937158
haticerdogan/python-3-sandbox
/lessons/dictionary.py
1,622
4.625
5
# Lesson 14 - Dictionaries # https://www.youtube.com/watch?v=Gqby4v5JOu4&list=PL4cUxeGkcC9idu6GZ8EU_5B6WpKTdYZbK&index=14 # Dictionaries are the same as Javascript objects or Ruby hashes. people_ages = {'ron':12, 'bob':5, 'tom':36, 'dan':41, 'cat':39, 'alf':73} print(people_ages) # check to see if a key exists insid...
true
955a214fdc776fff7f4d5d1771dffebdb8bdac7a
TungTNg/itc110_python
/Mon_07_09/volumArea.py
568
4.375
4
# volumeArea.py # a program which calculates the volume and surface are of a sphere from its radius, given as input import math def main(): print('# This is a program which calculates the volume and surface are of a sphere') print() radius = float(input('Enter the radius of the sphere: ')) volume...
true
5cc1874098689afa851baf216a254d2259dfa46f
TungTNg/itc110_python
/Assignment/wordCalculator.py
600
4.375
4
# wordCalculator.py # A program to calculate the number of words in a sentence # by Tung Nguyen def main(): # declare program function: print("This program calculates the number of words in a sentence.") print() # prompt user to input the sentence: sentence = input("Enter a phrase: ") ...
true
a61f6d3b35429b5596e9eca89cac63e55b3e2160
ottersome/progra_class
/python2/HW/0616115_hw9-2.py
2,154
4.53125
5
#!/usr/bin/python import math #this function is always run to check the validity of the input def filterinput(inputo): #the given string is stripped from its parenthesis and then split into three through at the commas divider = inputo[1:] divider = divider[:-1] divider = divider.split(",") #we test ...
true
3bbf75477b3424bc848e21ee6b6c161a7e60853c
Candy-Sama/Python-Mini-Programs
/Validating Inputs.py
1,071
4.1875
4
def user_choice(): #Variables #inital variables choice = 'Wrong' #initialise the variable as a false non-digit acceptable_range = range(0,10) within_range = False #Check for two conditions in while loop #digit OR within_range == False while choice.isdigit() == False or with...
true
0012a3e390179373f71989e4154dc4f383042efb
muthuguna/python
/Sample4.py
583
4.15625
4
myDictionary ={} def addItem(): inptCity = input("Enter the City:") inptZip = input("Enter the Zip:") myDictionary[inptCity]=inptZip def printItem(): print(myDictionary); def deleteItem(): itemToDelete = input("Enter the City to delete:") myDictionary.pop(itemToDelete) while(1): ...
true
674e8f75bfc2d8087dcbfdec8721e8fd268e9401
muthuguna/python
/Sample3.py
929
4.15625
4
""" myDictionary= {} def add(): nameValue = input("Enter name to add:") movieValue = input("Enter movie to add:") myDictionary[nameValue] = movieValue def printItems(): print(myDictionary) def deleteItem(): nameValue = input("Enter name to delete:") del myDictionary[nameValue] while(...
true
1c7b12aae485cd956ed12bb8d3c4b8dc34950de0
RiddhiDamani/Python
/Ch3/dates_start.py
1,142
4.375
4
# # Example file for working with date information # # we are telling the python interpreter here that from the datetime standard built in module that comes with the standard library - importing date, time, datetime classes. These are the predefined pieces of functionality in the Python library. To use it, you need to ...
true
c94ea9fb0e996c7c1bd777a4562f347c2bc2ad7e
RiddhiDamani/Python
/Chap11/hello.py
2,075
4.6875
5
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # Strings are the first class objects in Python3. # The below is a literal string. You can call methods on it. # A string is immutable - it cannot be changed. So, when we use one of the below transformation methods, # the return string is a different obje...
true
353faed27acb5088ba6d0fa4bb25e32bdf25cea2
RiddhiDamani/Python
/Chap06/while.py
461
4.25
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ secret = 'swordfish' pw = '' auth = False count = 0 max_attempt = 5 # the below loop ends when u enter 'swordfish' as the password. then, pw == secret breaks the loop. while pw != secret: count += 1 if count > max_attempt: break if count == 3...
true
4a6a6028a00df460c4de1e2ae9f539c16a4b215f
RiddhiDamani/Python
/Ch6/definition_start.py
1,672
4.21875
4
# Python Object Oriented Programming by Joe Marini course example # Basic class definitions # TODO: create a basic class class Book: # pass statement is used as a placeholder for future code. # When the pass statement is executed, nothing happens, but you avoid getting an error when empty code is not allowe...
true
027eb6a226bc7d565613976080d423cdafdde799
RiddhiDamani/Python
/Chap09/methods.py
1,973
4.21875
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # A function that is associated with a class is called a method. # This provides the interface to the class and its objects. class Animal: def __init__(self, **kwargs): self._type = kwargs['type'] if 'type' in kwargs else 'kitten' self...
true
f455463a341d56c4005d6000fb83fd840a9d53fb
ThompsonBethany01/Python_Practice_Problems
/Codeup_Challenges/Alphabet_Soup.py
1,007
4.375
4
# Alphabet Soup Solution # By Bethany Thompson # 1/20/2021 def alphabetize_words(my_string): ''' This functions accepts a string and returns the string sorted alphabetically by each word. ''' # splitting string by spaces my_string_list = str.split(my_string) # initialzing variable as...
true
e8004ef41a316324731cc23854912343acdda8d9
HanBao224/code_sample
/code_sample/data-cleansing-sample/dir_to_file.py
2,711
4.125
4
import os def dir_to_file(dir, file="dir.txt"): """ Find the files and directories in 'dir', remove hidden files, also get the files at the next level, and put everything into 'file' with this format: Contents of dir f1 f2 D: d1 ...
true
dde0477c5129a5a37fc7136e36ffaec4c897360a
MohammedHmmam/Python_a-z
/lists/map_function.py
1,266
4.5
4
#The map() Function executes a specified for each item in an iterable. ##The item is sent to the function as a parameters #### Syntax: map(Function , iterable) ############# Parameters : ############################# Function: Required|| - The function to execute for each item ############################# Iterab...
true
cb5cefb219b9ca70489678e164e45ac1c4258f7e
Levijom/nth_Digit_of_PI
/nth_Digit_of_PI.py
611
4.21875
4
import math #find the nth digit of PI userInput = int(input("what digit of PI would you like?: ")) if userInput <= 0: print("You must input a value larger than 0!") #get the nth value to one's place, convert to int digit = userInput - 1 power = 10 ** digit digit = math.pi * power integer = ...
true
337d1156a06f5202b51579a0defeb4c1b6bb6ad3
Anurag-Bharati/pythonProjectLab
/First.py
1,476
4.25
4
# Program to convert Binary to Decimal or vice versa import keyboard print("\nPress 'b' to convert decimal number into binary, 'd' to convert binary to decimal or 'e' to exit.\n") while True: if keyboard.is_pressed("b"): keyboard.send("backspace") print("\nDecimal to binary\n") keyboard....
true
d1622fc0447894b03a0e125dfb7a695304fb5bfa
VijayUpadhyay/python
/PythonBasics/com/vijay/basics/GeekForGeeks/ClosureTest1.py
391
4.1875
4
#As we can see innerFunction() can easily be accessed inside the outerFunction body #but not outside of it’s body. Hence, here, innerFunction() is treated as nested #Function which uses text as non-local variable. def outerFunction(text): custName = text def innerFunction(): print(custName) in...
true
58e4039bc04d16727bebc574ccbec57f98e2a8c6
VijayUpadhyay/python
/PythonBasics/com/vijay/basics/GeekForGeeks/ItrTest3.py
539
4.15625
4
import itertools from collections import Counter list1 = [1, 2, 3, 4, 5, 6, 44] list2 = [44, 55, 77, 55, 68, 88] list3 = [44, 77, 854, 545, 8, 89] print("Summation of 1st list: ", list(itertools.accumulate(list1))) print("Summation of 2nd list: ", list(itertools.accumulate(list2))) print("Summation of 3rd list: ", list...
true
5e73e6155f45815605950c6411eb592aa1863347
Joes-BitGit/LearnPython
/DataStructs_Algos/list_based/stacks.py
1,638
4.21875
4
class Element(object): def __init__(self, value): self.value = value self.next = None class LinkedList(object): """ Linked list class is used to hold elements but will act as a stack. Which means it will delete and insert only from the top of the Stack """ def __init__(self, he...
true
253602612d0e10cfa6c1af5e39ea8b3c7af46b5b
mikewarren02/PythonReview
/strings.py
671
4.21875
4
# Data types in Python print("Hello World") company = "digitalCrafts" cohort = "Feb 2021" message = f"Welcome to {company} and cohort is {cohort}" print(message) full_name = input("Please ener your full name: ") car_make = input("Please ener your car make: ") car_model = input("Please ener your car model: ") add...
true
76b5f30ed149e32b4435d8859678e1355a3eb3b2
EmanuelGP/pythonScripts
/dataStructuresAlgorithms/poo/pooEjemplo6/claseSequence.py
974
4.125
4
from abc import ABCMeta, abstractmethod class Sequence(metaclass=ABCMeta): """Our own version collections.Sequence abstrac base class.""" @abstractmethod def __len__(self): """Return the length of the sequence.""" @abstractmethod def __getitem__(self, j): """Return the element at index j of the sequence.""...
true
2532033dbec188409ffa1434369c059414268151
justanotheratom/Algorithms
/Python/DynamicProgramming/Fibonacci/Staircase/staircase_bottomup.py
567
4.375
4
def countways(n): ''' Given a staircase with n steps, find the number of was you can climb it by taking 1 step, 2 steps, or 3 steps at each turn. :param n: Number of steps in the staircase :return: Number of possible ways. >>> countways(0) 1 >>> countways(1) 1 >>> countways(2) ...
true
9c15808f00f1964de2dfc605b3e106a0ed6b56af
jmwoloso/Python_2
/Lesson 8 - GUI Layout/grdspan.py
1,603
4.125
4
#!/usr/bin/python3 # # A Program Demonstrating the 'rowspan' and 'columnspan' Keywords # for the grid() Method Geometry Manager in Tkinter # # Created by: Jason Wolosonovich # 03-11-2015 # # Lesson 8 - Exercise 3 """ Demonstrates the 'rowspan' and 'columnspan' keywords of the Geometry Manager for the grid() method. "...
true
a81209dbff0df01c8f4324bcb93d0a917abb24a6
jmwoloso/Python_2
/Lesson 3 - TDD/adder.py
521
4.34375
4
#!/usr/bin/python3 # # Lesson 3 Exercise 1 Adder Module # adder.py # # Created by: Jason Wolosonovich # 02-20-2015 # # Lesson 3, Exercise 1 """adder.py: defines an adder function according to a slightly unusual definition.""" import numbers def adder(x, y): if isinstance(x, list) and not isinstance(y, lis...
true
be3e61e14026462d2014682dc71d6d511610f628
jmwoloso/Python_2
/Lesson 11 - Database Hints/animal.py
1,910
4.21875
4
#!/usr/bin/python3 # # A Program That Uses a Class to Represent an Animal in the Database # animal.py # # Created by: Jason Wolosonovich # 03-20-2015 # # Lesson 11 - Exercise 2 """ animal.py: a class to represent an animal in the database """ class Animal: def __init__(self, id, name, family, weight): ...
true
19dd21f1ee8babc06d3b444dfdbb06fdee9480e5
philipslan/programmingforfun
/2_basicds/queuelist.py
567
4.34375
4
# Implement the Queue ADT, using a list such that the rear of the queue # is at the end of the list. class Queue: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def enqueue(self, item): self.items.append(item) print self.items def dequeue(self): a= self.items[0] del s...
true
c70f0169560febece4f7f18e8c57ecc9055e073a
PeterELytle/LTCTHW-Python
/ex18.py
1,328
4.28125
4
# This line defines the "print_two" function, and it will have arguments. def print_two(*args): # This line defines two arguments to be used in the function. arg1, arg2 = args # This line displays some text, and both variables (which are defined as the function arguments). print "arg1: %r, arg2: %r" % (arg1, arg2) ...
true
4198371c811f2f7eab2395c816dae90267f43c9c
PeterELytle/LTCTHW-Python
/ex3.py
1,621
4.4375
4
print "I will now count my chickens:" # This line displays some text describing what the next lines will do. print "Hens", 25.00 + 30.00 / 6.00 # This line displays a descriptor and the result of an arithmetic equation. print "Roosters", 100.00 - 25.00 * 3.00 % 4.00 # This line displays a descriptor and the result of...
true
da90149afebf3c0afc560a90b3c7583ede002ba3
nordhagen/cs
/python/3-lists.py
1,358
4.3125
4
bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print bicycles # Python has string operation functions like .title() for title casing. print bicycles[0].title() # Negative array access will count from the end print bicycles[-1] message = 'My first bicycle was a '+ bicycles[0].title() + '.' print message ...
true
efd841d774d8cdb7ccfe887fb158d3432ccfa0b1
chintaluri/Coding-Exercises
/p-prac-ex1.py
892
4.1875
4
# Create a program that asks the user to enter their name and their age. # Print out a message addressed to them that tells them the year that they will turn 100 years old. # Extras: # # Add on to the previous program by asking the user for another number and printing out that many copies of the previous message. # (H...
true
deb01bf8f07f75fd93feb197f5bdaf5a7aa3db16
adityakaria/3-Sem
/py/labs/lab3/mystack.py
865
4.3125
4
class Stack: """Define the Stack class here. Write a constructor and implement the push, pop and isEmpty functions using Python lists. """ def __init__(self): self.my_stack = [] self.top = -1 def push(self, x): self.my_stack.append(x) self.top += 1 print ("Push Successful\nThe stack now is: " + s...
true
a08ace17e89a52ed82d2467cb7dea5823fac6923
RansomBroker/self-python
/Recursive/binarySearchTree.py
1,101
4.15625
4
class Node: #make constructor for insert data def __init__(self, key): self.left = None self.right = None self.value = key #insert item based on root def insertTree(self, root, node): if root is None: root = node else: #insert value ...
true
36be5969915f5f20c67366462148ba4e34d2528b
marlavous/intro-to-programming-class
/listproject.py
1,792
4.4375
4
master_list = {"Target": ["socks", "soap", "detergent", "sponges"], "Safeway": ["butter", "cake", "cookies", "bread"]} test_list = ["apples", "wine", "cheese"] def main_menu(): print "Select one" print "0 - Main Menu" print "1 - Show all lists." print "2 - Show a specific list." print "3 - Add a new shopping lis...
true
4fa482193c3c69a6f7fdb43d7a936bb34ebc12f3
osiddiquee/SP2018-Python220-Accelerated
/Student/osiddiquee/lesson09/Acitivity09.py
1,824
4.125
4
''' Notes for concurrency and async ''' import sys import threading import time from Queue import Queue ''' This is an intengration function def f(x): ''' return x**2 def integrate(f, a, b, N): s = 0 dx = (b-a)/N for i in xrange(N): s += f(a+i*dx) return s * dx ''' This starts...
true
615773162eb00f0f6052e5165174a3085d5e40b1
Bdnicholson/Python-Projects
/Imperial-To-Metric/Bora_Nicholson_Lab3a.py
1,311
4.25
4
print('Hello, Please input the Imperial values!') #Miles Miles = float(input('Miles to Kilometers: ')) totalKilometers = (1.6 * Miles) if Miles < 0: print('Please no negative numbers') else: if Miles > 0: print("The metric conversion is ", totalKilometers) #Fahrenheit Fahrenheit = float(input('Fahrenhe...
true
703a54f231c85e320e10950ed1c7403daa6a6d09
YabZhang/algo
/remove_element.py
798
4.15625
4
#!/usr/bin/env python3 # coding: utf8 """ @Author: yabin @Date: 2017.5.20 “Given an array and a value, remove all occurrences of that value in place and return the new length. The order of elements can be changed, and the elements after the new length don't matter. Example Given an array [0,4,4,0,0,2,4,4], value=4 ...
true
745304d06b6afc863d2b76b498f0370f6d05cff2
JARVVVIS/ds-algo-python
/sorting_algo/rec_bubble.py
674
4.21875
4
## just for fun things def rec_bubble(arr): ## bring the largest element to the last for i in range(len(arr)-1): if arr[i] > arr[i+1]: temp = arr[i] arr[i] = arr[i+1] arr[i+1] = temp ## now call the function on last-1 elements ## we are basical...
true
38057ac597ef329b7afc371c8cc7b9225d0072fb
reesep/reesep.github.io
/classes/summer2021/127/lectures/examples/calculator.txt
1,186
4.21875
4
# Write a calculator program that will ask for # two numbers from the user. The program # should then as the user what operation they # want to do (addition, subtraction, # multiplication, division). The program # should then do the requested operation and # print out the answer. def addition(num1, num2): return ...
true
0c7cf800ec9927506315dfdac8ce5c83fe3f560b
reesep/reesep.github.io
/classes/snowmester2020/127/lectures/examples/pizza_price.py
343
4.3125
4
# Write a program that will calculate the cost per square inch of a # circular pizza, given its diameter (inches) and price. diameter = float(input("Enter diameter of pizza: ")) price = float(input("Enter price of pizza: ")) area = (3.14159) * (diameter / 2) ** 2 ppsi = price / area print("The price per square i...
true
1a821d4a20223b0cd5ec519fbc91e062ae3582ed
andpet27/Python
/StringFormatting/StringsEx2.py
716
4.28125
4
string = "Strings are awesome!" print("Lenghts of string = %d" % len(string)) print("The first occurence of letter a = %d" %string.index("a")) print("a occures %d times" %string.count("a")) print("the first five characters are '%s'" %string[:5]) print("the next five characters are '%s'" %string[5:10]) print("the 13th c...
true
39525d30ac77a038f0277bcd6d39838b7df14912
olugbengs12/pythonlearn
/classwork.py
454
4.40625
4
#program that takes count of numbers entered by a user and also notes the number, do a sum and return an average total = 0 count = 0 average = 0 while True: number = input("Enter a number:") try: if number == "done": break total += float(number) count += 1 ...
true
48f2ba2e155b451e7934815738bad75cb9123f58
GenerationTRS80/JS_projects
/python_starter/tuples_sets.py
912
4.3125
4
# A Tuple is a collection which is ordered and >> unchangeable <<. Allows duplicate members. # Create tuple # You create a tuple using parenthese in stead brackets like lists fruits = ('Appels', 'Grapes', 'Oranges') #fruits2 = (('Apples','Grapes','Oranges')) #Trailing value needs a single comma fruits2 = ('Apple',)...
true
40d316229ad3450f817516625f950fa29d9af9df
srithanrudrangi/PythonCoding
/color.py
224
4.15625
4
color1 = input('Enter one primary color: ') color2 = input('Enter another primary color: ') if ((color1 == 'red' and color2 == 'blue') or (color1 == 'blue' and color2 == 'red')): print('Your secondary color is Purple.')
true
2472673124d46f00d6f260fcf33d9c27205ac68a
srithanrudrangi/PythonCoding
/rectangle.py
239
4.125
4
length = int(input('What is the length of your rectangle? ')) width = int(input('What is the width of your rectangle? ')) area = length*width perimeter = 2 * (length+width) print('The perimeter is ', perimeter) print('The area is ', area)
true
49ba51faa633d6244d4dfe8a176fe03c63d20ec8
srithanrudrangi/PythonCoding
/4_5_averagerainfall.py
546
4.21875
4
numOfYears = int(input('How many years? ')) for i in range(numOfYears): totalInchesOfrainfall = 0 currentMonth = 1 for currentMonth in range(1, 13): inchesOfrainfall = int( input('How many inches of rainfall for the month of ' + format(currentMonth, "d") + ': ')) totalInchesOfra...
true
2ee3775ee7145d9f9483874807811f5dc29fb1b5
david-assouline/personal-projects
/Sudoku Solver.py
2,848
4.28125
4
import time board = [ [0,8,0,4,0,0,1,2,0], [6,0,0,0,7,5,0,0,9], [0,0,0,6,0,1,0,7,8], [0,0,7,0,4,0,2,6,0], [0,0,1,0,5,0,9,3,0], [9,0,4,0,6,0,0,0,5], [0,7,0,3,0,0,0,1,2], [1,2,0,0,0,7,4,0,0], [0,4,9,2,0,6,0,0,7] ] def board_generator(): """ optional function. gives...
true
06e4663d0c88fafcc266ed5bcf7923beb22778b9
karenseunsom/python102
/todos.py
1,312
4.15625
4
# want to ask user what they want to add to list. import json # todos = ["pet the cat", "go to work", "shop for groceries", "go home", "feed the cat"] with open('todos.json', 'r') as file_handle: # contents = file_handle.read() # print(contents['name']) todos = json.load(file_handle) def print_todos(): ...
true
60ff157dd08174723fd53794c323a35e61a3cb76
aly22/cspython
/week1/return_day.py
208
4.1875
4
day1 = int(input("Please enter the starting day number: ")) length_of_stay = int(input("Please enter the length of your stay: ")) leave_day =day1+length_of_stay%7 print("The leaving day will be: ",leave_day)
true
77dc3f01c0e6e865de7a863e51fb67dc344c4082
Ziweili-12/BigData
/Assignment1_MapReduce/babynames.py
2,087
4.21875
4
#!/usr/bin/python import sys import re def extract_names(filename): """ Given a file name for baby<year>.html, returns a list starting with the year string followed by the name-rank strings in alphabetical order. ['2006', 'Aaliyah 91', Aaron 57', 'Abagail 895', ' ...] If this seems too daunting, r...
true
f1d1023de7cdc6db4723f1f44df605b550890639
anmsuarezma/Astrof-sica-Computacional
/02. Plotting and classes/code/curveplot1.py
649
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on 23 Dec 2018 @author: ashcat Curve Plotting """ import numpy as np import matplotlib.pyplot as plt def f(t): return t**2*np.exp(-t**2) # range of the independent variable # 50 points between 0 and 3 t = np.linspace(0, 3, 50) # values of the functio...
true