0% found this document useful (0 votes)
3 views2 pages

Python 01 Assesment

This document is a worksheet for a Python programming assignment focused on creating a time converter. It includes the aim, requirements, and a sample code that allows users to convert time between seconds, minutes, hours, and days. The program features a menu-driven interface for user interaction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Python 01 Assesment

This document is a worksheet for a Python programming assignment focused on creating a time converter. It includes the aim, requirements, and a sample code that allows users to convert time between seconds, minutes, hours, and days. The program features a menu-driven interface for user interaction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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:

You might also like