time,py
timeunknown
plain_text
7 months ago
9.7 kB
6
Indexable
def seconds_to_minutes(seconds):
return seconds / 60
def minutes_to_hours(minutes):
return minutes / 60
def hours_to_minutes(hours):
return hours * 60
def minutes_to_seconds(minutes):
return minutes * 60
def cooking_time(weight, time_per_unit):
return weight * time_per_unit
def tim_for_men():
print("\n" + "="*50)
print(" " * 15 + "Time Conversions Menu")
print("="*50)
print("[1] Seconds to Minutes")
print("[2] Minutes to Hours")
print("[3] Hours to Minutes")
print("[4] Minutes to Seconds")
print("[5] Cooking Time Adjustments")
print("[6] Return to Main Menu")
print("="*50)
def tim_sec_min():
while True:
try:
print("\n" + "-"*50)
print(" Enter an option (1-6): ")
print("-"*50)
time_select = input("-- ")
if not time_select.isdigit():
print("="*50)
print("# INVALID INPUT! Please enter a numeric value. #")
print("="*50)
continue
time_select = int(time_select)
match time_select:
case 1:
while True:
sec_to_min = input("\n" + "-"*50 + "\n[Seconds to Minutes Conversion]\nEnter Second/s: ")
if not sec_to_min.replace(".", "", 1).isdigit():
print("="*50)
print("# INVALID INPUT! Please enter a numeric value. #")
print("="*50)
continue
sec_to_min = float(sec_to_min)
print(f"\n{sec_to_min:.2f} Second/s is {seconds_to_minutes(sec_to_min):.2f} Minute/s!")
while True:
back = input("\n[1] Choose another option \n[2] Stay \n[3] Return to Main Menu\n-- ")
if back.isdigit():
back = int(back)
if back == 1:
return
elif back == 2:
break
elif back == 3:
print("\nReturning to Main menu...")
return "RETURN_MAIN"
else:
print("="*50)
print("Invalid entry, Please choose 1, 2, or 3.")
print("="*50)
case 2:
while True:
min_to_hr = input("\n" + "-"*50 + "\n[Minutes to Hours Conversion]\nEnter Minute/s: ")
if not min_to_hr.replace(".", "", 1).isdigit():
print("="*50)
print("# INVALID INPUT! Please enter a numeric value. #")
print("="*50)
continue
min_to_hr = float(min_to_hr)
print(f"\n{min_to_hr:.2f} Minute/s is {minutes_to_hours(min_to_hr):.2f} Hour/s!")
while True:
back = input("\n[1] Choose another option \n[2] Stay \n[3] Return to Main Menu\n-- ")
if back.isdigit():
back = int(back)
if back == 1:
return
elif back == 2:
break
elif back == 3:
print("\nReturning to Main menu...")
return "RETURN_MAIN"
else:
print("="*50)
print("Invalid entry, Please choose 1, 2, or 3.")
print("="*50)
case 3:
while True:
hr_to_mins = input("\n" + "-"*50 + "\n[Hours to Minutes Conversion]\nEnter Hour/s: ")
if not hr_to_mins.replace(".", "", 1).isdigit():
print("="*50)
print("# INVALID INPUT! Please enter a numeric value. #")
print("="*50)
continue
hr_to_mins = float(hr_to_mins)
print(f"\n{hr_to_mins:.2f} Hour/s is {hours_to_minutes(hr_to_mins):.2f} Minute/s!")
while True:
back = input("\n[1] Choose another option \n[2] Stay \n[3] Return to Main Menu\n-- ")
if back.isdigit():
back = int(back)
if back == 1:
return
elif back == 2:
break
elif back == 3:
print("\nReturning to Main menu...")
return "RETURN_MAIN"
else:
print("="*50)
print("Invalid entry, Please choose 1, 2, or 3.")
print("="*50)
case 4:
while True:
mins_to_sec = input("\n" + "-"*50 + "\n[Minutes to Seconds Conversion]\nEnter minute/s: ")
if not mins_to_sec.replace(".", "", 1).isdigit():
print("="*50)
print("# INVALID INPUT! Please enter a numeric value. #")
print("="*50)
continue
mins_to_sec = float(mins_to_sec)
print(f"\n{mins_to_sec:.2f} Minute/s is {minutes_to_seconds(mins_to_sec):.2f} Second/s!")
while True:
back = input("\n[1] Choose another option \n[2] Stay \n[3] Return to Main Menu\n-- ")
if back.isdigit():
back = int(back)
if back == 1:
return
elif back == 2:
break
elif back == 3:
print("\nReturning to Main menu...")
return "RETURN_MAIN"
else:
print("="*50)
print("Invalid entry, Please choose 1, 2, or 3.")
print("="*50)
case 5:
while True:
weight = input("\n" + "-"*50 + "\n[Cooking Time Adjustments] \nEnter the weight (kg or lb): ")
if not weight.replace(".", "", 1).isdigit():
print("="*50)
print("# INVALID INPUT! Please enter a numeric value. #")
print("="*50)
continue
weight = float(weight)
time_per_unit = input("\n[Cooking Time Adjustments] \nEnter time (in minute/s): ")
if not time_per_unit.replace(".", "", 1).isdigit():
print("="*50)
print("# INVALID INPUT! Please enter a numeric value. #")
print("="*50)
continue
time_per_unit = float(time_per_unit)
total_time = weight * time_per_unit
print(f"\nThe total cooking time for {weight:.2f} kg (or lb) at {time_per_unit:.2f} minute/s per unit is {total_time:.2f} minute/s!")
while True:
back = input("\n[1] Choose another option \n[2] Stay \n[3] Return to Main Menu\n-- ")
if back.isdigit():
back = int(back)
if back == 1:
return
elif back == 2:
break
elif back == 3:
print("\nReturning to Main menu...")
return "RETURN_MAIN"
else:
print("="*50)
print("Invalid entry, Please choose 1, 2, or 3.")
print("="*50)
case 6:
print("\nReturning to main menu...")
return "RETURN_MAIN"
case _:
print("="*50)
print(" Enter a valid selection (1-5) ")
print("="*50)
except ValueError:
print("="*50)
print(" INVALID INPUT! Enter a numeric value only.")
print("="*50)
Editor is loading...
Leave a Comment