Completed exercise 11 and began 12
This commit is contained in:
parent
ea38642c98
commit
0985d4ff14
@ -1,2 +1,28 @@
|
||||
import time
|
||||
|
||||
def get_birth_date():
|
||||
"""Prompts the user for year, month, and day as integers."""
|
||||
year = int(input("Enter birth year (e.g., 1997): "))
|
||||
month = int(input("Enter birth month (1-12): "))
|
||||
day = int(input("Enter birth day (1-31): "))
|
||||
return year, month, day
|
||||
|
||||
def display_birth_info(year, month, day):
|
||||
"""Converts the input integers to a time structure and displays formatted output."""
|
||||
date_tuple = (year, month, day, 0, 0, 0, 0, 0, -1)
|
||||
|
||||
parsed_time = time.struct_time(date_tuple)
|
||||
|
||||
seconds = time.mktime(parsed_time)
|
||||
formatted_struct = time.localtime(seconds)
|
||||
|
||||
# Format date string as DD/Mon/YY (e.g., 15/Jan/97)
|
||||
formatted_date = time.strftime("%d/%b/%y", formatted_struct)
|
||||
|
||||
day_of_week = time.strftime("%A", formatted_struct)
|
||||
|
||||
print(f"\nDate entered: {formatted_date}")
|
||||
print(f"You were born on a {day_of_week}.")
|
||||
|
||||
year, month, day = get_birth_date()
|
||||
display_birth_info(year, month, day)
|
||||
19
11/exercise-01.py
Normal file
19
11/exercise-01.py
Normal file
@ -0,0 +1,19 @@
|
||||
STARTERS = ["Tomato Soup", "Baked Camembert", "Prawn Cocktail", "Garlic Butter Mushrooms"]
|
||||
MAINS = ["Chicken Tikka Masala", "Beef Stew", "Chicken Parmesan", "Chicken Curry"]
|
||||
DESSERTS = ["Chocolate Cake", "Ice Cream", "Lemon Meringue Pie", "Cheesecake"]
|
||||
DRINKS = ["Coffee", "Tea", "Water", "Lemonade"]
|
||||
|
||||
import random
|
||||
|
||||
starter = random.choice(STARTERS)
|
||||
main = random.choice(MAINS)
|
||||
dessert = random.choice(DESSERTS)
|
||||
drink = random.choice(DRINKS)
|
||||
|
||||
print("***************************")
|
||||
print(" MENU")
|
||||
print(f"Starter: {starter}")
|
||||
print(f"Main : {main}")
|
||||
print(f"Dessert: {dessert}")
|
||||
print(f"Drinks : {drink}")
|
||||
print("***************************")
|
||||
|
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
8
12/exercise-01.py
Normal file
8
12/exercise-01.py
Normal file
@ -0,0 +1,8 @@
|
||||
# regular octagon in red
|
||||
# regular nonagon in blue
|
||||
|
||||
# condition controlled iteration
|
||||
# both shapes on same screen
|
||||
|
||||
import turtle
|
||||
|
||||
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Loading…
Reference in New Issue
Block a user