DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Worksheet 1
Student Name:Vishal kumar UID:23BCS11866
Branch: BE.CSE Section/Group:706/B
Semester: 3RD Date of Performance:7/8/24
Subject Name: PYTHON PROGRAMMING Subject Code: 23CSP-201
1. Aim:
Set A: Time Converter
Background: Develop a program that converts time between
different units (seconds, minutes, hours, days).
2. Requirements (Hardware/Software): gdb compiler or visual
studio
3. Code/ Output:
def seconds_to_minutes(seconds):
return seconds / 60
def minutes_to_hours(minutes):
return minutes / 60
def hours_to_days(hours):
return hours/ 24
def time_conversion():
while True:
print("\nTime Conversion Menu:")
print("1. seconds to minutes")
print("2. minutes to hours ")
print("3. hours to days")
print("4. Exit")
choice = int(input("Enter your choice (1/2/3/4)"))
if choice ==4:
print("Exiting the time converter. Goodbye!")
break
value = float(input("Enter the time value to convert: "))
if choice == 1:
result = seconds_to_minutes(value)
print(f"{value} seconds is {result} minutes.")
elif choice == 2:
result = minutes_to_hours(value)
print(f"{value} minutes is {result} hours.")
elif choice == 3:
result = hours_to_days(value)
print(f"{value} hours is {result} days.")
else:
print("Invalid choice! Please select a valid option.")
if __name__ == "__main__":
time_conversion()
output: