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

Software Lab Using Python

Uploaded by

Dev lal
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)
43 views2 pages

Software Lab Using Python

Uploaded by

Dev lal
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

Program No.

-1
Write a menu driven program to convert the given temperature from fahrenheit to celcius
and vice versa depending upon user's choice.
def fahrenheit_to_celsius(fahrenheit):

return (fahrenheit - 32) * 5.0/9.0

def celsius_to_fahrenheit(celsius):

return (celsius * 9.0/5.0) + 32

def main():

while True:

print("\nTemperature Conversion Menu:")

print("1. Fahrenheit to Celsius")

print("2. Celsius to Fahrenheit")

print("3. Exit")

choice = input("Enter your choice (1/2/3): ")

if choice == '1':

fahrenheit = float(input("Enter temperature in Fahrenheit: "))

print(f"{fahrenheit}°F is equal to {fahrenheit_to_celsius(fahrenheit)}°C")

elif choice == '2':

celsius = float(input("Enter temperature in Celsius: "))

print(f"{celsius}°C is equal to {celsius_to_fahrenheit(celsius)}°F")

elif choice == '3':

print("Exiting the program. Goodbye!")

break

else:

print("Invalid choice. Please enter 1, 2 or 3.")

if __name__ == "__main__":

main()

Output:

Temperature Conversion Menu:


1. Fahrenheit to Celsius

2. Celsius to Fahrenheit

3. Exit

Enter your choice (1/2/3):

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy