Preparing git repo for final project

This commit is contained in:
2023-07-09 11:19:26 +02:00
parent 6a38966eef
commit 63d06d6b35
67 changed files with 1587 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
def main():
while True:
fuel = input("Fraction:\t\t")
try:
x, y = map(int, fuel.split('/'))
if x > y:
continue
result = x / y
break
except (ValueError, ZeroDivisionError):
continue
if result <= 0.01:
print("E")
elif result >= 0.99:
print("F")
else:
print(f"{int(round(result*100, 0))}%")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,16 @@
def main():
shopping_list = {}
while True:
try:
item = input("").upper()
except EOFError:
break
if item not in shopping_list:
shopping_list[item] = 0
shopping_list[item] += 1
for item, quantity in sorted(shopping_list.items(), key=lambda x: x[0]):
print(f"{quantity} {item}")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,41 @@
import re
months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
def main():
while True:
try:
entered_date = input("Date: ").strip()
except Exception:
continue
if re.match(r"\d+/\d+/\d+", entered_date):
month, day, year = map(int, entered_date.split('/'))
elif re.match(r"\w+ \d{1,2}, \d{4}", entered_date):
entered_date = entered_date.replace(",", "")
month, day, year = entered_date.split(' ')
month = months.index(month) + 1
day, year = map(int, (day, year))
else:
continue
if month > 12 or day > 31:
continue
break
print(f"{year:04d}-{month:02d}-{day:02d}")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,27 @@
menu = {
"Baja Taco": 4.00,
"Burrito": 7.50,
"Bowl": 8.50,
"Nachos": 11.00,
"Quesadilla": 8.50,
"Super Burrito": 8.50,
"Super Quesadilla": 9.50,
"Taco": 3.00,
"Tortilla Salad": 8.00
}
def main():
total = 0.0
while True:
try:
dish = input("Item: :\t\t").title()
except EOFError:
break
if dish in menu:
total += menu[dish]
print(f"Total: ${total:.2f}")
if __name__ == "__main__":
main()