blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
22125169c0acacdd42f0ae9fb4e02c9f99dced1c
HystericHeeHo/testingPython
/country.py
288
4.1875
4
country = input("What Country are you from? Please choose USA or Canada") if country == "USA" or "usa": print("*Cue Guiles Theme* Welcome to America!") elif country == "Canada" or "canada": print("Hello, eh.") else: print("You have entered an incorrect choice. Please try again.")
true
10a9ae26005808559262c2d94111220aa437f093
NiveditaSingh1709/tathastu_week_of_code
/day4/program4.py
337
4.21875
4
n=int(input("enter the number of elements")) my_dict = dict() for i in range(n): key = input("Enter the key: ") value = input("Enter the value: ") my_dict[key] = value result = {} for key,value in my_dict.items(): if value not in result.values(): result[key] = value print(result) #for remove d...
true
c55a9f449aa50697db40035de94e290ed45dedb0
0utfoxed/reticulated_python
/Real Python/objects_and_methods.py
821
4.65625
5
# Practice with the input() method # user_input = input("Hey, what's up? ") # print("You said: ", user_input) response = input("What should I shout? ") print("Well, if you insist...", response.upper()) print("The stored value of \"response\" is ", response) response = response.upper() print("Well, if you insist....
true
b48afc8b1f24e7ef4ab3cace5fbe8bc22024fd9e
0utfoxed/reticulated_python
/Real Python/streamlined_print_statements.py
338
4.15625
4
# Streamlined printing using the format() method. # Method 1 peaches = 2 apricots = 3 print("She has {} peaches and {} apricots.".format(peaches, apricots)) # Method 1 Mod using indexing print("She has {0} peaches and {1} apricots.".format(peaches, apricots)) # Method 2 print(f"She has {peaches} peaches and {apri...
true
790fad27ecd368a2c1934ce24406997933fa52d7
prashantstha1717/IWPythonProject
/IWPythonProject/functions/f15.py
270
4.25
4
# Write a Python program to filter a list of integers using Lambda. lis = list(range(1, 21)) result = filter(lambda x: x % 2 == 0, lis) print("Evens Numbers: ") print(list(result)) result1 = filter(lambda x: x % 2 != 0, lis) print("Odd Numbers: ") print(list(result1))
true
56b86d71d207bcaa0d11a2e97b3b66e74a435859
prashantstha1717/IWPythonProject
/IWPythonProject/data_types/Q25.py
316
4.1875
4
# Write a Python program to check whether all dictionaries in a list are empty or # not. # Sample list : [{},{},{}] # Return value : True # Sample list : [{1,2},{},{}] # Return value : False sample1 = [{}, {}, {}] sample2 = [{1, 2}, {}, {}] print(all(not d for d in sample1)) print(all(not d for d in sample2))
true
07a67a9afb153ec67b8eee0c404dacb8bff7fc64
prashantstha1717/IWPythonProject
/IWPythonProject/data_types/Q9.py
294
4.1875
4
# Write a Python program to change a given string to a new string where the first # and last chars have been exchanged. def out9(string): first_char = string[0] last_char = string[-1] final = last_char + string[1:-1] + first_char return final print(out9('Insight Workshop'))
true
f09f516e6dfc5feccc35c6f66ca32e4e5f312dfa
CodeNamor/Crossing-the-River
/crossingTheRiver.py
1,369
4.125
4
#F. Derek Roman - GitHub Profile Name: CodeNamor #SWDV - 610-3W: Data Structures Week 7 Assignment Crossing the River #import the state class from state import State from Node import Node from collections import deque import time #implement a breadth first search for solving the problem def bre...
true
0ff294d7f3268f726c3206282ba53801278230de
cristianlepore/python_exercises
/Sandbox/Problem1/exercise3.py
865
4.21875
4
''' @author: cristianlepore ''' def longest(s): ''' input: a str s in alphabetical order. output: a str. A substring of s. Return the longest substring of s in alphabetical order. ''' def less(str): ''' input: a str of two characters. returns True if the first char is l...
true
4bf835a0bbc059d1b8cc4f529cb2da189f2de175
icculp/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
488
4.28125
4
#!/usr/bin/python3 '''5-text_indentation''' def text_indentation(text): '''Prints some text with two lines after ? . or :''' if type(text) is not str: raise TypeError("text must be a string") text = text.strip() flag = 0 for char in text: if char in '?.:': print(char) ...
true
7d14642d1167af685d4309af3f99516c52998715
totally-not-eli/hello-ugly-ass-world
/isuniquefac.py
1,598
4.125
4
""" This code will show the all the combinations of integer came across with such that when its individual factorial is taken, it will be equal to the integer given. e.g. 1 = 1! 145 = 1! + 4! + 5! """ import keyboard class Stack: def __init__(self): self.stack = ["1"] def add(self, dataval): ...
true
7554cc6c5fb80d35427989fa7c6a603089d914c7
amit133/PythonTraining
/Exercises/Ex2_AreaOfTriangle.py
807
4.375
4
def getAreaOfTriangle(base, height): """ Calculate the area of a triangle. Area is calculated using the formula: Area = 0.5 * base * height. This function throws an assertion error if either base or height is non-positive number """ assert base > 0 and height > 0 return 0.5 * base * height i...
true
cf2494a72b7b32b5e8984044ffcb632749f01299
verdi07/crypto
/basicStuff/cesar2.py
748
4.28125
4
# Cipher or decipher a message with the Cesar method and a selected key import pyperclip # copy function ALPH = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # Create a blank string and add new letters to it exit = '' # Select the program use mode = input('Do you want to chyper or decypher the code? (c/D)') # Text and key text = i...
true
38968ff282409af3355a3fe7fed47eb66bbf97fa
verdi07/crypto
/basicStuff/cesar1.py
459
4.15625
4
# Program that codes an entered message with the cesar method import pyperclip # Copy to the clipboard # Text CLARO = 'abcdefghijklmnopqrstuvwxyz ' CIFRADO = 'ZYXWVUTSRQPONMLKJIHGFEDCBA ' # Store the output exit = '' # Enter the plain text text = input('Enter your text: ') # Execute the ciphring for symbol in text...
true
02bb2d4fd1773551abebd7dfd95290f290a97839
bwilliams512/calendar
/calendar.py
2,357
4.34375
4
""" This is a basic calendar that the user can interact with from the command line. """ from time import sleep, strftime user_first_name = input("Please enter your first name: ") calendar = {} # create a welcome message function def welcome(): print("Welcome, " + user_first_name + ".") print("Open...
true
55334845408730b48e26aad588008278d0068a40
kimsisingh/python_exercises
/sets_examples.py
1,059
4.53125
5
#What are sets? # They are unordered collection of unique elements, with no repetition # Use single quotes when adding elements to any data type or in the print # Use set() method to create an empty set or grab a unique set from lists # This method does not return any ordered sequence. my_set = set() print(f"My set is ...
true
f8768f0ea8291f3ed95511f2170a9d29177fd692
HotsauceLee/Leetcode
/Categories/Hash/129.Rehashing.py
2,442
4.3125
4
""" The size of the hash table is not determinate at the very beginning. If the total size of keys is too large (e.g. size >= capacity / 10), we should double the size of the hash table and rehash every keys. Say you have a hash table looks like below: size=3, capacity=4 [null, 21, 14, null] ↓ ↓ 9 ...
true
65883f624df2bec892f7f6e781e14a65bae7471e
HotsauceLee/Leetcode
/Categories/No_Fucking_Clue/L_627.Longest_Palindrome.py
1,131
4.125
4
""" Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This is case sensitive, for example "Aa" is not considered a palindrome here. Notice Assume the length of given string will not exceed 1010. Have you met this questi...
true
3c69d7665c4305bee2f1265eac9a3abdba59ebaf
HotsauceLee/Leetcode
/Categories/DP/115.Unique_Paths_II.py
1,901
4.15625
4
""" Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively in the grid. Notice m and n will be at most 100. Have you met this question in a real interview? Yes Example For example, The...
true
852f619a7cc1937496807da4b110accc56a2f5d1
HotsauceLee/Leetcode
/Categories/Prefix_Sum/R__L_402.Continuous_Subarray_Sum.py
1,172
4.125
4
""" Given an integer array, find a continuous subarray where the sum of numbers is the biggest. Your code should return the index of the first number and the index of the last number. (If their are duplicate answer, return anyone) Have you met this question in a real interview? Yes Example Give [-3, 1, 3, -3, 4], retu...
true
03515b069e7105ab96008db74ae27b57d4ce56c0
otteydw/python-learning
/snakify/lesson2/clock_face1.py
831
4.34375
4
# https://snakify.org/en/lessons/integer_float_numbers/problems/ # H hours, M minutes and S seconds are passed since the midnight(0 ≤ H < 12, 0 ≤ M < 60, 0 ≤ S < 60). Determine the angle(in degrees) of the hour hand on the clock face right now. # Number of seconds in 12 hour period seconds_per_clock = 43200 hours = ...
true
507662df7a293583d28f61f5794396e25379899d
otteydw/python-learning
/snakify/lesson3/equal_numbers.py
521
4.4375
4
# https://snakify.org/en/lessons/if_then_else_conditions/problems/ # Given three integers, determine how many of them are equal to each other. # The program must print one of these numbers: 3 (if all are the same), 2 (if two of them are equal to each other and the third is different) or 0 (if all numbers are different...
true
a67b0848d5dbc2f186d5ab2c5fc568ce7a547ec1
otteydw/python-learning
/snakify/lesson2/digital_clock.py
622
4.46875
4
# https://snakify.org/en/lessons/integer_float_numbers/problems/ # Given the integer N - the number of minutes that is passed since midnight - how many hours and minutes are displayed on the 24h digital clock? # The program should print two numbers: the number of hours(between 0 and 23) and the number of minutes(betwe...
true
e7252eeccdc84107a702acfe1eac42726eb7d30d
miguelAvina1/ProgrammingFoundations
/Exercise Files/3 Recursion/countdown_start.py
271
4.1875
4
# use recursion to implement a countdown counter level = 0 def countdown(x, level): level += 1 if x < 0: print("Done") return else: print(x) countdown(x-1, level) print(f"Current level:{level}") countdown(5, level)
true
34a82ef2a68d5bd02b585fbf62634165ac144a00
yeyeto2788/uStatusBoard
/examples/dht_status.py
2,050
4.28125
4
""" Example script using a DHT11 sensor to read the temperature and humidity. The temperature and the humidity are measured every 5 mins and based on that measurement represent the value of them on the board using a thresholds. If temperature is above `max_temp` the led will light up `red` If temperature is below `mi...
true
4b0bae273b05eeff2c423943b56ab8b550547b7f
PlumpMath/DesignPatternInPython-1
/Construct/Maze.py
2,133
4.15625
4
class Maze(object): def __init__(self): self.rooms = {} def add_section(self, section): self.rooms[section.room_number] = section def get_room(self, room_number): return self.rooms[room_number] class Section(object): def enter(self): print 'Entering a Section' cla...
true
adfe4beefd4e159dddc93944fe6c4642d6ad25fa
fredford/maze-generator
/src/button.py
1,764
4.15625
4
import pygame as pg class Button(): """Object used to represent a button used in the GUI """ def __init__(self, color, x, y, width, height, text="", action=None): self.color = color self.x = int(x) self.y = int(y) self.width = int(width) self.height = int(height) ...
true
07f938a9a29434c6a38977f774ead60f703f4316
anan17-meet/Y2YL201617_Week5
/warmup5.py
1,147
4.40625
4
''' You've built an in-flight entertainment system with on-demand movie streaming. Users on longer flights like to start a second movie right when their first one ends, but they complain that the plane usually lands before they can see the ending. So you're building a feature for choosing two movies whose total runti...
true
30895cb777d2ce06f307550689b8b643ea3cc9a5
naveenkatepalli/python
/sequences.py
655
4.375
4
#string data type name="naveen" print(name[0]) print(name[3]) #lists data type names=["naveen","ravi","pavan"] print(names) print(names[1]) #taple data type cordianteX=55.0 cordinateY=45.0 cordinates=(55.0,45.0) print(type(cordinates)) print(cordinates) #set data structure name={4,5,6,1,2,3,9,8,7} print(name) print(f...
true
1b484ce6fe94014edb6a60c21873da856306ee2c
shinobuzac/Automate-the-Boring-Stuff-with-Python
/Madlibs.py
570
4.28125
4
#! python3 # madlibs.py - read in text files and lets the user add their own text anywhere import re text = 'The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was unaffected by these events.' repWordList = re.compile(r'[A-Z]{2,}').findall(text) repList = [] for wordString in repWordList: if wor...
true
98b56519059e5a58a74c030a76e13bd6783e12f4
ivovun/python_exercises
/w3resource_com_python_exercises_006_basic1.py
428
4.375
4
# 6. Write a Python program which accepts # a sequence of comma-separated numbers # from user and generate a list # and a tuple with those numbers. # Sample data : 3, 5, 7, 23 # Output : # List : ['3', ' 5', ' 7', ' 23'] # Tuple : ('3', ' 5', ' 7', ' 23') inp_str: str =\ input('Write a sequence of' '\n ...
true
8f43899b971ed1b50d7168ec2b3cd5fdc0513e2a
karanadapala/dsa_python_mit6.006
/lecture4.py
2,358
4.25
4
''' In this lecture version the concept of Heaps is covered. We will be implementing the following concepts: i. Max_heapify a.k.a Heapify the ds in descending Tree order. ii. Extract_max - maximun number from the heap is extract and the rest of the heap is Heapified. iii. Heap_Sort A Heap is an array representation o...
true
328dfa952f4c70d2d804590b14e8aa53ee3f79b7
oyeyemidamilola/python-practice
/recursion_sum.py
643
4.125
4
def find_sum(arr): ''' using divide and conquer technique to recursively find the sum of a list of numbers ''' result = 0 if len(arr) == 1 : result = arr[0] else: result = arr.pop() + find_sum(arr) return result def count_list(arr): ''' rec...
true
b4f271ad13680e6ba255ead41c2ba15233d4b663
camadog/learn-arcade-work
/ScratchWork/if_statements.py
1,307
4.375
4
# Variables used in the example ''if'' statemests a = 5 b = 4 c = 2 # Basic comparisons if a < b: print("a is less than b") if a > b: print("a is greater than b") if a == b: print("a is equal to b") if a != b: print("a and b are not equal b") if a < b and a < c: print("a is less than b and c") if a...
true
d9413c35cb847b113c3cb88f2d4b1eb42acb0ef5
merimem/Data-Structures
/LinkedLists/testlinkedlist.py
1,752
4.125
4
class Node: def __init__(self, data, next = None): self.data = data self.next = next #print the linked linkedList def printList(headNode): currentNode = headNode; while currentNode is not None: print(currentNode.data) currentNode=currentNode.next def insertNodeBeginning (hea...
true
582082dfd26401e8b51065c848355123a66b47d4
merimem/Data-Structures
/Strings/uniqueChars.py
672
4.15625
4
#Approach 0 #We create a hash table and we go through the string and #we add the chars in the hash table #if it exists in the hash table then we def is_unique(str): dict = {} for i in range(len(str)): if str[i] in dict: return False else: dict[str[i]]= True return Tru...
true
e50b58c33187abbd0d08ab0621a6b07d6901f23e
brianchiang-tw/Code-wars
/Isograms/isograms.py
977
4.25
4
''' Description: An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case. is_isogram("Dermatoglyphics" ) == true is_isogram("aba" )...
true
fd25df18cd4011d633cdeebee9ce92dedffbd921
brianchiang-tw/Code-wars
/Explosive Sum/explosive_sum.py
2,356
4.1875
4
''' Description: How many ways can you make the sum of a number? From wikipedia: https://en.wikipedia.org/wiki/Partition_(number_theory)# In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers. Two sums that diffe...
true
41d5c9acf033c5c3e92983441adc176a93f73d41
imrajashish/python
/python22.py
1,216
4.15625
4
#Write a Python program to make file lists from current directory using a wildcard. import glob file_list = glob.glob('*.*') print(file_list) #Write a Python program to remove the first item from a specified list. lst = [1,2,3,4] print(lst.remove(2)) print(lst) #Write a Python program to input a number, if it is not a...
true
ff94a737c029074a286a0ca470db49dec7b2123c
kchen6600/15softdev2
/listcomp.py
1,999
4.4375
4
# Write a function that uses list comprehension to return whether a password meets a minimum threshold: # it contains a mixture of upper- and lowercase letters, and at least one number # Write a function that uses list comprehension to return a password's strength rating. # This function should return a lower integer f...
true
f90625e47be0fd667a34ba87980c08da8f20a429
wilson51678/sc-projects
/stanCode_Projects/boggle_game_solver/largest_digit.py
1,363
4.53125
5
""" File: largest_digit.py Name: Wilson Wang ---------------------------------- This file recursively prints the biggest digit in 5 different integers, 12345, 281, 6, -111, -9453 If your implementation is correct, you should see 5, 8, 6, 1, 9 on Console. """ def main(): print(find_largest_digit(12345)) # 5 pri...
true
1e6ed8c82dcdc329f3944ad46c77aa3a8eb8ea1a
wilson51678/sc-projects
/stanCode_Projects/hangman_game/rocket.py
2,161
4.21875
4
""" File: rocket.py name: Wilson ----------------------- This program should implement a console program that draws ASCII art - a rocket. The size of rocket is determined by a constant defined as SIZE at top of the file. Output format should match what is shown in the sample run in the Assignment 2 Handout. ...
true
f55f0f705d9a75ad47e5c76d5e1ac6ec63234bca
wilson51678/sc-projects
/stanCode_Projects/weather_master/hailstone.py
1,687
4.5
4
""" File: hailstone.py Name: Wilson Wang ----------------------- This program should implement a console program that simulates the execution of the Hailstone sequence, as defined by Douglas Hofstadter. Output format should match what is shown in the sample run in the Assignment 2 Handout. """ STOP = 1 def main(): ...
true
7e7d6caba5a590180611c4c649a6f1c9b4fa3b06
Roscode/word-grid-traversal
/words.py
1,546
4.21875
4
#!/usr/bin/env python class AlphabetTree: """ A class for searching words and word prefixes """ def __init__(self, value): self.endsWord = False self.value = value self.subtrees = [] def insert(self, word): """ A method to insert the given word into this alphabet tree """ if word == "": ...
true
de297543fc27f577142c4b6cbffebe28cc1e3e3f
edu-athensoft/stem1401python_student
/py200714_python2/day05_py200728/string_ex.py
1,426
4.40625
4
"""""" """ 1. Write a Python program to calculate the length of a string. 2. Write a Python program to count the number of characters (character frequency) in a string. Sample String : google.com' Expected Result : {'o': 3, 'g': 2, '.': 1, 'e': 1, 'l': 1, 'm': 1, 'c': 1} 3. Write a Python program to get a string mad...
true
9c304935abfea650e410b7643815739d1195a89b
edu-athensoft/stem1401python_student
/py200703_python1/day19_py200905/for_3_ex.py
438
4.4375
4
""" for loop Get the prod of a number sequence 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8x 9x10 = ? """ """ analysis 1. how to represent the data 2. for loop, determine the number of iteration 10 times 3. how to do factorial or multiplication """ numbers = [1,2,3,4,5,6,7,8,9,10] # len(numbers) prod = 1 for n in numbers...
true
5b4662fc655b00116b9087f6961b8b5701ff7031
edu-athensoft/stem1401python_student
/py210123a_python2a/day07_210313/homework/homework_zilin_20210227.py
570
4.3125
4
""" 1. Write a Python program to remove duplicates from a list. 2. Write a Python program to check a list is empty or not 3. Write a Python program to clone or copy a list. """ # 1 list1 = ['a','a','a','b','b','b','c','c','c'] print(list1) list2 = [] for items in list1: if items not in list2: list2.appen...
true
ddaa36ffc49faa924ede0227e6d0ab64cc6f1246
edu-athensoft/stem1401python_student
/py200622_python2/day03_py200629/review_q2.py
789
4.15625
4
""" 2. Write a Python function to sum all the numbers in a list. """ # step 1. trail algorithms # list1 = [1,2,3,4,5] # # sum = 0 # for num in list1: # sum += num # # print(sum) # step 2. generic and implementation def get_sum(mylists): """ calculate the sum of the list items :param mylists: a list ...
true
56edcd9227ba0d13fef9961d90aabb21f97a6b0c
edu-athensoft/stem1401python_student
/py200510_python2/day16_py200708/sample/ex_1.py
486
4.1875
4
""" dictionary - ex 1 by key """ demo_dict = { 3: "c", 2: "a", 1: "b" } # sorting by key # converting to iterable items = demo_dict.items() print(items, type(items)) b = list(items) print(b, type(b)) # sorted(iterable, key, reverse=False) c = sorted(items) print(c) print() # before print([value for k...
true
2e4b8a52954fd847e6a16772c3cbd4db4e17e69e
edu-athensoft/stem1401python_student
/sj200116_python2/py200507/quiz8_10.py
484
4.1875
4
""" Author: Yun Gong Zhang """ days = int(input("Please enter a number of days: ")) TODAY = int(input("Please input today's day: ")) daysleft = days % 7 rest = daysleft + TODAY if rest == 1: print("It is a Monday.") elif rest == 2: print("It is a Tuesday.") elif rest == 3: print("It is a Wednesday.") e...
true
b93f8aea639e29404249c6d26f7b349e7e898688
edu-athensoft/stem1401python_student
/py200913b_python2m8/day01_200913/file_6_mode_w.py
2,586
4.4375
4
""" 1. Open (with a mode) 2. R/W 3. Close write a file mode: w open() write() try-except-finally close() text content is multiple line string conclusion: The mode of 'w' create a new file if it does not exist. or it will truncate the old file and rewrite with new content. """ # case 1. truncating # by zeyue ''' ...
true
fa85184b4e8e82ed85f9f93c53f096c37e172134
edu-athensoft/stem1401python_student
/py210110d_python3a/day19_210516/homework/stem1403a_hw_0509_guangzhu.py
955
4.40625
4
""" [Homework] Date: 2021-05-09 Design and implement a multiple option button list on the main window. Click on each button to show a specific toplevel window. The number of options should be at list 5. Due date: by the end of next Sat. """ from tkinter import * def toplevel(enter): toplevel_window = Toplevel(roo...
true
c20f2652a7f3cbcaf2200dea129cd50ca987c465
edu-athensoft/stem1401python_student
/py210109b_python3a/day13_210403/homework/stem1403a_homework_11_0327_steven.py
934
4.34375
4
""" Homework Date: 2021-03-27 Input N numbers from your keyboard Put them into a list (i.e. [1,3,5]) Create a window Then place(add) N buttons to the window anchor=S side=LEFT, side=RIGHT Button text is the current number you get Create an 'Exit' button which allows you to press it to close the window Hint: Lambda pas...
true
b6dff0a4433a9268d715bfd7e39cdea409ac8a7e
edu-athensoft/stem1401python_student
/sj190912_python2/py1128/func_argument.py
991
4.125
4
# function argument def my_func(): print() my_func() # one argument def my_func2(fname): print("Hello {}".format(fname)) my_func2("Puca") my_func2("Emma") # two arguments def adding(x, y): result = x + y return result print(adding(1, 2)) print(adding(3, 2)) print(adding(5, 6)) def sum3(a, b, c): ...
true
63326886ea5e475051371e35d0af233fbb82fd2a
edu-athensoft/stem1401python_student
/py200901_python2_kevin/day08_py200909/set_12_subset.py
533
4.375
4
""" set method issubset() """ # case 1. A = {1, 2, 3, 4, 5} B = {1, 2, 3, 4, 5} is_subset = A.issubset(B) if is_subset: print("A is a subset of B") else: print("A is not a subset of B") print() # case 2. A = {1, 2} B = {1, 2, 3, 4, 5} is_subset = A.issubset(B) if is_subset: print("A is a subset of B"...
true
69d4e9f6b9c9a2b937b3bb701f1b951bcf31332e
edu-athensoft/stem1401python_student
/py200622_python2/day19_py200824/sample/string_7_find.py
604
4.1875
4
""" find() The find() method returns the index of first occurrence of the substring (if found). If not found, it returns -1. str.find(sub[, start[, end]] ) """ # Example 1 quote = 'Let it be, let it be, let it be' result = quote.find('let it') print("Substring 'let it':", result) result = quote.find('small') print...
true
3e40a6e476f7b309d50e838dde6551907a8b5a8d
edu-athensoft/stem1401python_student
/py200912f_python2m7/day04_201003/homwork3.py
434
4.21875
4
""" [Homework] 1. Map two lists into a dictionary for day of week list1 = ['MON','TUE','WED','THU','FRI','SAT','SUN'] list2 = ['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY'] 2. Create a dictionary properly and sorting by age in ascending order, then sorting by score in descending order. Both r...
true
fe18017c0566eb56f5bec60ed6c8780fa5155efc
edu-athensoft/stem1401python_student
/py200421_python2/day16_py200623/set_3.py
540
4.1875
4
""" remove item(element) from a set discard() remove() clear() del - keyword """ # step 1. create a set with some items set1 = {'1', '2', '3'} # step 2. try out discard() set1.discard('1') print(set1) set1.discard('1') print(set1) print() # step 3. try out remove() set1.remove('2') print(set1) # KeyError: '2' # s...
true
19d245ab7a282313a9f2eb24e59b515d09384a78
edu-athensoft/stem1401python_student
/py210109b_python3a/day13_210403/homework/stem1403a_homework_11_0327_max.py
1,001
4.125
4
""" Homework 11 Date: 2021-03-27 Input N numbers from your keyboard Put them into a list (i.e. [1,3,5]) Create a window Then place(add) N buttons to the window anchor=S side=LEFT, side=RIGHT Button text is the current number you get Create an 'Exit' button which allows you to press it to close the window Hint: Lambda ...
true
39310293aacf31a23bcbdd1f7fc765ac918bda6d
edu-athensoft/stem1401python_student
/py200912f_python2m7/day01_200912/review/exception_8_raise.py
440
4.15625
4
""" exception handling raise an error assert """ # input a positive number # even number (extra) try: a = int(input("Enter a positive integer:")) if a <= 0: raise ValueError("That is not a positive number ") if a % 2 != 0: raise ValueError("That is not an even number ") if a>100: ...
true
2f4ec36a7d1a56df89456e83197af7085f2b461f
edu-athensoft/stem1401python_student
/py200913d_python2m4/day15_201227/project_converter_v1_Yin_Zilin.py
374
4.28125
4
""" My simple converter kilometers -> miles """ input('=== Kilometers to miles converter ===') kilometer = (float(input("Please enter the number of kilometers that you want to convert:"))) mile = kilometer * 0.621371 if kilometer <= 0: print("Please enter a number grater than 0") else: print(print("{} kilom...
true
05844d12e6cba7ae4fe7213c6acf52c40cd5d8f2
edu-athensoft/stem1401python_student
/py210628e_python1b/day11_210805/for_14.py
408
4.46875
4
""" multiplication table 1 Python Program to Display the multiplication Table Required: Python for Loop Python Input, Output and Import Sample Result: input from keyboard: N N x 1 = N N x 2 = N .... N x N = N*N """ # input num = int(input("Enter a number (num > 0):")) # print out table A = num STOP = num + 1 for...
true
fe66f0c26996f5655614dff34aba80b3905ec24a
edu-athensoft/stem1401python_student
/py200512_python1/day20_py200723/leap_year_checker.py
504
4.3125
4
""" Leap year checker. """ print("Leap year checker.") print() year = int(input("Input year: ")) # if year is not divisible by 4, not a leap year. if year%4 != 0: print("It is not a leap year.") # elif year is not divisible by 100, leap year. elif year%100 != 0: print("It is a leap year.") # elif year is di...
true
e3d752f2b3e3e7e66163429c27439f845e3a6e0e
edu-athensoft/stem1401python_student
/py210110d_python3a/day15_210418/homework/stem1403a_hw_14_0411_zeyueli.py
1,461
4.1875
4
""" [Homework] Date: 2021-04-10 Design and write program for a login form Requirements: A GUI interface Preset the username is 'admin' and the password is '123456' User may input username User may input password, and the password should show mask char ('*') instead If the user's input matches the presetting, then the p...
true
052a39397b393099c08bc39119f38b891b374d85
edu-athensoft/stem1401python_student
/py200714_python2/day06_py200801/q4.py
365
4.75
5
""" 6. Write a Python program to add 'ing' at the end of a given string (length should be at least 3). If the given string already ends with 'ing' then add 'ly' instead. If the string length of the given string is less than 3, leave it unchanged. """ str1 = "work" # len >=3 # ends with 'ing' # i.e. singly # not ends...
true
1ad46942d6c22cd688dc53237ecb559b814e3309
edu-athensoft/stem1401python_student
/py200325_python1/py200529/stem1401_python_homework_quiz10_Kevin.py
1,394
4.21875
4
""" Quiz 10 and homework """ # Question 3. A class of student just look a midterm exam on French course. # Please figure out the average of this class. And how many students got A. # s is score, and s is student s_s = [ ("Marie", 85), ("Phoebe", 78), ("Sabrina", 96), ("Emma", 85), ("Amy", 73), ...
true
92c503634bd7cd648bae2528d577fac5cf2d669b
edu-athensoft/stem1401python_student
/py210110c_python1a/day19_210516/format_3.py
723
4.625
5
""" String formatting alignment of numbers < Left aligned ^ Center aligned > Right aligned (default) = Forces the sign (+ / -) to the leftmost position """ # original example print("The number is |{:5d}|".format(123)) # right aligned print("The number is |{:<5d}|".format(123)) # centered print("The number...
true
23d0e0828ee736e08159276ea543741803e3b935
edu-athensoft/stem1401python_student
/py200325_python1/py200506/project_1_loginform_v1_Neilson.py
301
4.125
4
""" Login form """ print("Login form") # Getting input from user username = input("Please enter your username: ") password = input("Please enter your password: ") # Echoing the user's inputs print("Welcome {} and your password is {}".format(username, password)) print("Goodbye {}!".format(username))
true
e1bee3def3cf7fda2dc48dc0560ff856adb64961
edu-athensoft/stem1401python_student
/py200912b_python2m6/day08_201031/exception_8.py
395
4.1875
4
""" try...except...else to calculate the reciprocal of a number when it is an even number keyword: assert """ try: num = int(input("Enter a number.")) assert num % 2 == 0 except AssertionError as ae: print("this is an AssertionError") print(ae) except Exception as e: # print("this is an Asserti...
true
b39e70b256bf506c8e36ccccfb02413db4a2c0d4
edu-athensoft/stem1401python_student
/sj200917_python2m6/day07_201029/exception_9.py
405
4.21875
4
""" raise an error throw throws raise keyword: raise 1. we can raise an error as we want to (when, where and what) 2. we can add a message when raising an error logical error / exception """ # input a positive integer try: num = int(input("Enter a positive integer: ")) if num <= 0: raise ValueErr...
true
adaee5bf9d4091c3bcbce87cf19b96052a1c5eae
edu-athensoft/stem1401python_student
/py200622_python2/day04_py200702/homework3/homework_question.py
590
4.40625
4
""" [Homework] 1. Write a Python function to find the Max of three numbers. 2. Write a Python function to sum all the numbers in a list. 3. Write a Python function to multiply all the numbers in a list. 4. Write a Python program to reverse a string. 5. Write a Python function to calculate the factorial of a number (a n...
true
4710275b5929891363736f9bcb12e7edcaba341b
edu-athensoft/stem1401python_student
/py200622_python2/day06_py200709/review_lambda.py
411
4.28125
4
""" What is the lambda function? anonymous function """ # syntax # lambda para1,[para2,..] : expr # convert a regular function to a lambda ? def double(n): return 2*n dbl = lambda n : 2 * n print(dbl(5)) # using filter() mylist = [1,2,3,4,5,6,7,8] # how to pick up all the odd numbers from the list using lamb...
true
ed2a2bdcd4e96f05868333f206845f6c583bc68e
edu-athensoft/stem1401python_student
/py200913b_python2m8/day03_200927/homework/kevin/stem1402_homework_q4_Kevin.py
354
4.34375
4
""" 4. Write a Python program to read last n lines of a file. """ try: f = open("text_Kevin.txt", "r") last_n_lines = int(input("Last number of lines you want to read: ")) for l in (f.readlines()[-last_n_lines:]): print(l) except FileNotFoundError as fe: print(fe) except Exception as e: ...
true
2f8c6340b5917223afa0cc1048191b230c8f6157
edu-athensoft/stem1401python_student
/py210628e_python1b/day13_210812/homework/stem1401_hw12_andy_210805.py
544
4.25
4
""" [Homework] Date: 2021-08-05 Quiz 11 Due date: this Wednesday """ """ q1: pseudo-code start -> A -> True -> B -> back to A -> False -> end """ # q2: num_terms = int(input("How many terms?(integer number only) : ")) num_1 = 0 num_2 = 1 count = 0 if num_terms <= 0: print("Error, this is not a positi...
true
5d4fd4b5674f6f63673b60a6785468a5612170ec
edu-athensoft/stem1401python_student
/py200512_python1/day13_py200630/input_1.py
358
4.34375
4
""" input() """ # use a variable to save or accept the input from your keyboard myinput = input("text message") # datatype of input() print(myinput, type(myinput)) # input two numbers # multiply them # print out the result n1 = input("Enter the first num: ") n2 = input("Enter the second num: ") result = float(n1) ...
true
8aaf79cce856f39e29b413cd5553a1dfc3c64981
edu-athensoft/stem1401python_student
/py200901_python2_kevin/day04_py200905/list_3_slicing.py
699
4.21875
4
""" slicing """ # ex. words = 'Python is a good programming language.' words = ['p','y','t','h','o','n'] # case 1. slicing from the index of 0 print("=== case 1 ===") result = words[0:1] print(result) result = words[0:2] print(result) # ex. result = words[0:4] print(result) result = words[:4] print(result) print...
true
c48ca95e6f3589de83665e9a31b8d21eb43f761c
edu-athensoft/stem1401python_student
/py210123a_python2a/day13_210424/homework/homework_0423_Yin_Zilin.py
722
4.6875
5
""" 1. Write a Python program to convert a list to a tuple. 2. Write a Python program to remove an item from a tuple. 3.Write a Python program to add an item in a tuple. Hints: list(collection_object) - convert collection_object to a list tuple(collection_object) - convert collection_object to a tuple 4. Write a Python...
true
de5b1745f4952f986f3cfe15bf7c60c3360db4b9
edu-athensoft/stem1401python_student
/py210110d_python3a/day05_210207/homework/stem1403a-hw-4-0130-guangzhu.py
1,021
4.28125
4
""" [Homework] Date: 2021-01-30 1. Try out label widget Description: create a window based on previous homework set icon, title, dimension, maxsize, minsize, bg and any other options for the window as much as you know create a text Label set dimension, font, fg, bg, font and any other options which are necessary you th...
true
9f7226c1eaa6107fc795072d234f916ad9bea9e8
edu-athensoft/stem1401python_student
/sj200625_python2/day09_py200820/string_q7.py
919
4.125
4
""" 7. Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string. Sample String : 'The lyrics is not that poor!' 'The lyrics is poor!' Expected Result : 'Th...
true
91fcebc11b281315452f64b9ee9ec43cef3f53e9
edu-athensoft/stem1401python_student
/py200512_python1/day11_py200623/datatype_convertion2.py
797
4.21875
4
""" implicit conversion explicit conversion 6.4 Key Points to Remember Type Conversion is the conversion of object from one data type to another data type. Implicit Type Conversion is automatically performed by the Python interpreter. Python avoids the loss of data in Implicit Type Conversion. Explicit Type Conversion...
true
ecbbd6cde289c65e17b65f8a376f867cbf80ac4f
edu-athensoft/stem1401python_student
/py200510_python2/day11_py200614/set_1.py
405
4.375
4
""" set items of set are immutable set itself is mutable """ # testlist = [(),(),()] # create a set set1 = {1,2,3,4} # create an empty set set2 = {} list2 = [] print("empty set {}, the type is {}".format(set2, type(set2))) set2 = set() print("empty set {}, the type is {}".format(set2, type(set2))) # create a spec...
true
eb706b7c19baeae007856b060c5559df7d5e409d
edu-athensoft/stem1401python_student
/py200703_python1/day10_py200805/datatype_1.py
877
4.375
4
""" datatype conversion """ print(12,34) print('12','34') print(12+34) print('12'+'34') # how to perform datatype conversion # to change the datatype of a value/variable # string -> number (int, float) n1 = '123' n2 = '234' result = float(n1) + float(n2) print("Result 1 =",result) n1 = '123' n2 = '234' result = in...
true
4e18dd49ef5518562b546dde2ff86b8721e8cacf
edu-athensoft/stem1401python_student
/py210109b_python3a/day15_210417/homework/stem1403a_homework_13_0410_max.py
1,423
4.15625
4
""" Homework 13 Date: 2021-04-10 Design and write program for a login form Requirements: A GUI interface Preset the username as 'admin' and the password as '123456' User may input username User may input password, and the password should show mask char ('*') instead If the user's input matches the presetting, then the...
true
138cd3a84ce6cac0bd9ec0e73366488802812742
edu-athensoft/stem1401python_student
/py200622_python2/day06_py200709/homework/stem1402_python_homework_4_p2_steven.py
383
4.21875
4
""" stem1402_python_homework_4_p2_steven """ # 1. def fib(nums): num1 = 0 num2 = 1 num3 = 0 for nums in range(nums): num3 = num2 num2 = num1 num1 = num2 + num3 return num1 nums = int(input("Please write the position of the fibonnaci number you want to check:")) print(f"The...
true
aab304c9258ff5a7d8e8f89721b34d8317eee8aa
edu-athensoft/stem1401python_student
/py210110d_python3a/day13_210404/homework/stem1403a_hw_0403_12_tengyuhao.py
1,317
4.21875
4
""" [Homework] Date: 2021-03-28 Input N numbers from your keyboard Put them into a list (i.e. [1,3,5]) Create a window Then place(add) N buttons to the window anchor=S side=LEFT, side=RIGHT Button text is the current number you get Create an 'Exit' button which allows you to press it to close the window Hint: Lambda p...
true
947247a80734c85e0b8b7146547ab0ecf51d40dc
edu-athensoft/stem1401python_student
/py200913b_python2m8/day12_201129/project_zeyue/quiz_1.py
1,493
4.40625
4
""" Quiz date: 2020-11-29 to be scored Problem: Renaming files in a batch Write a program to rename multiple files in a specified directory Requirements: design and plan sample design: assuming 1: file1.html, file2.html, file3.html,..., filen.html change file extension of each one to .txt assuming 2: ch...
true
c7698437ebfd8bad0f114aecd1d9e08949939d0e
edu-athensoft/stem1401python_student
/py200912b_python2m6/day08_201031/homework/stem1402b_python_homework_7_Kevin (1).py
1,962
4.15625
4
""" [Homework] 1. Rewriting arithmetic calculator. Accepting 2 inputs from a keyboard by users and output the division of these 2 values. Requirements: The 2 inputs should be converted to Integer before calculating. Exception handling is required. Your program should never crash in any case of input. You may optimize ...
true
3ce12164d2ddef9ab8937414cad330dd591d1b9d
edu-athensoft/stem1401python_student
/py210110d_python3a/day03_210124/homework/stem1403_Kevin_Liu.py
831
4.25
4
""" [Homework] 2021-01-17 1. Create a main window with specified width and height user may input width and height 2. Please center the window 3. Please add image icon to your window """ """ score improper file name (-1) """ import tkinter root = tkinter.Tk() root.title("Homework - Kevin Liu") # after some researc...
true
bc9cc56cb0b779693e13b4c37a1982732aed3c11
oneiromancy/leetcode
/medium/1282. Group the People Given the Group Size They Belong To.py
1,646
4.125
4
def groupThePeople(groupSizes): groupMap = {} finalGrouping = [] for idx, groupToEntry in enumerate(groupSizes): if groupToEntry in groupMap: groupMap[groupToEntry].append(idx) else: groupMap[groupToEntry] = [idx] if len(groupMap[groupToEntry]) == groupToEnt...
true
1b8bd44cf778e2c6ad80e07c342f9df6123cdf74
oneiromancy/leetcode
/easy/206. Reverse Linked List.py
1,083
4.1875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next import copy class Solution: def reverseList(self, head: ListNode) -> ListNode: prev_node = None curr_node = head while curr_node: ...
true
18df58734e279b8ebd36fea04e763fa6065e9b37
Martakan/YUMS
/src/mud/text/split.py
1,158
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Aug 1 10:46:16 2020 @author: AzureD Useful tools to splitting and cleaning up input text. """ def cleanly(text: str): """ Splits the text into words at spaces, removing excess spaces. """ segmented = text.split(' ') clean = [s for...
true
fd64cee90e7cceae9bfb4148942e49d0686aeeaf
k-lowen/Mod-5-6-7
/count_negatives.py
539
4.3125
4
def count_negatives(list_of_numbers): '''function: counts how many negative numbers in a list parameters: one list returns: how many negatives in the list''' negatives_list = [] i = 0 while i < len(list_of_numbers): if list_of_numbers[i] < 0: negatives_list....
true
53303321afae8695759c1aad1f1ffc2dcd95694c
k-lowen/Mod-5-6-7
/ convert_tuple (done).py
455
4.3125
4
def convert_tuple(tuple_input): ''' function: takes tuple and converts to list parameters: one tuple returns: same tuple but as a list''' index = 0 list_form = [] while len(list_form) < len(tuple_input): list_form.append(tuple_input[index]) index += 1 return list_for...
true
ddf96372bac8fd7fc706824db84c030c34a3b6ca
k-lowen/Mod-5-6-7
/compare_lists.py
559
4.15625
4
def compare_lists(list_one, list_two): ''' function: compares two lists and returns true if order and numbers are the same parameters: two lists returns: true or false''' for i in range(8): if (list_one[i] == list_two[i]) and (len(list_one) == len(list_two)): result = "T...
true
3b97deae721c5893de69b37534d2312e3cd870da
k-lowen/Mod-5-6-7
/add_ten.py
415
4.125
4
def add_ten(list_of_numbers): '''function: adds ten to each integer in list parameters: list of integers returns: list with 10 added to each integer''' new_list = [] for i in range (5): new_value = list_of_numbers[i] + 10 new_list.append(new_value) return new_list def ...
true
b04d0c9817d31af1f7d47628f8451e9bcbc6e54c
Ericksmith/CD-projects
/Python/small-projects/foo_bar.py
745
4.28125
4
"""Write a program that prints all the prime numbers and all the perfect squares for all numbers between 100 and 100000. For all numbers between 100 and 100000 test that number for whether it is prime or a perfect square. If it is a prime number print "Foo". If it is a perfect square print "Bar". If it is neither pri...
true
cb6d955710adc103d65252586d45cdf73cb3747f
eriks0n/coding-challenges
/highest_square.py
562
4.59375
5
#!/usr/bin/env python3 def highest_square_below(number): """ Calculating and returning the highest square below a given number. Args: number: Given number which acts as the upper bound Returns: highest_square: The highest square which es less than the given number """ highest...
true
25ba1cb73c8c2df7d57c633689217603981d21aa
ditiansm2015/Digit-recognization
/Digit recognisation using SVM.py
936
4.1875
4
#A python program to recognise digit #Uses Scikit-learn module to recognise digits #Uses Support Vector Mechanism(SVM) alorithm #Dataset is already given under Scikit-learm module (digits) #Dataset contains an already structured and labeled set of samples that contains #pixel information for numbers up to 9 that w...
true
2f35e8706e962ee082996f24411c89c945c86e16
JorgePerC/PythonBasics
/TryoutNewThings.py
340
4.125
4
def myfunc (string: str): string_as_list = [] is_even = False for letter in string: if is_even: string_as_list.append(letter.upper()) else: string_as_list.append(letter.lower()) is_even = not (is_even) string = "" return string.join(string_as_list) p...
true
741b47936cc4e9ffc2a4a11323728a389d48feeb
neibips/MaxMisha
/python.py
347
4.25
4
value = (input("Enter a value you want to convert: ")) if value == "km": value_km = input("Enter amount of km you want to convert into miles: ") elif value == "mile": value_mile = input("Enter amount of miles you want to convert into km: ") else: print("Type the correct form") def convert_km (value_km): ...
true