This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
verses = ["a Partridge in a Pear Tree", "Two Turtle Doves", "Three French Hens", "Four Calling Birds", | |
"Five Gold Rings", "Six Geese-a-Laying", "Seven Swans-a-Swimming", "Eight Maids-a-Milking", | |
"Nine Ladies Dancing", "Ten Lords-a-Leaping", "Eleven Pipers Piping", "Twelve Drummers Drumming"] | |
days = {index - 1: ', '.join(reversed(verses[:index - 1])) for index, verse in enumerate(verses)} | |
def get_day(day): | |
return "On the {} day of Christmas my true love sent to me,".format(day) + days[day] | |
def get_presents(start, end=None): | |
return sum(range(start, end + 1)) if end else sum(range(start)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import winsound | |
sound_path = r"" | |
def play_sound(path): | |
winsound.PlaySound(path, winsound.SND_FILENAME) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def get_contents(file_name): | |
return open(file_name).readlines() # Return a list of the lines of text | |
last_version = get_contents('test.txt') | |
while True: | |
current_version = get_contents('test.txt') | |
if last_version != current_version: # Has it changed from what it was before? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
while True: | |
how_many_loops = input("How many grades will you be entering? ") | |
if '.' not in how_many_loops: | |
for _ in range(int(how_many_loops)): | |
while True: | |
score = int(input("Please enter a grade between 0 and 100: ")) | |
if score > 100 or score < 0: | |
print('Your number is out of range!', end=' ') | |
continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How many grades will you be entering? 3 | |
Please enter a grade between 0 and 100: 2000 | |
Your number is out of range! Please enter a grade between 0 and 100: 2000 | |
Your number is out of range! Please enter a grade between 0 and 100: 2000 | |
Your number is out of range! Please enter a grade between 0 and 100: 2000 | |
Your number is out of range! Please enter a grade between 0 and 100: 2 | |
Please enter a grade between 0 and 100: 3 | |
Please enter a grade between 0 and 100: 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_prime(number): | |
for x in range(2, number): | |
if number % x == 0: | |
return False | |
return True | |
for n in range(1, 101): | |
if is_prime(n): | |
print(n, 'is prime') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import praw | |
def _get_question_comment(comment): | |
if comment.is_root: | |
return | |
parent_comment = r.get_info(thing_id=comment.parent_id) | |
if parent_comment.is_root: | |
return parent_comment, comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
JAPANESE_CHARACTERS = [ | |
['いちまい', 'にまい', 'さんまい', 'よんまい', 'ごまい', 'ろくまい', 'ななまい', 'はちまい', 'きゅうまい', 'じゅうまい'], | |
['いっさつ', 'にさつ', 'さんさつ', 'よんさつ', 'ごさつ', 'ろくさつ', 'ななさつ', 'はっさつ', 'きゅうさつ', 'じゅさつ'], | |
['いっぽん', 'にほん', 'さんぼん', 'よんまい', 'ごまい', 'ろくまい', 'ななまい', 'はちまい', 'きゅうまい', 'じゅうまい'], | |
['ひとつ', 'ふたつ', 'みっつ', 'よっつ', 'いつつ', 'むっつ', 'ななつ', 'やっつ', 'ここのつ', 'とお'] | |
] | |
answer_selections = ["a", "b", "c", "d"] |