Algorithm:
- Start
- Display menu options
- Option 1: Celsius to Fahrenheit
- Option 2: Fahrenheit to Celsius
- Get user's choice (1 or 2)
- If choice is 1:
- Get temperature in Celsius
- Calculate Fahrenheit = (Celsius × 9/5) + 32
- Display result
- If choice is 2:
- Get temperature in Fahrenheit
- Calculate Celsius = (Fahrenheit - 32) × 5/9
- Display result
- If invalid choice:
- Display error message
- End
Hello, dear reader! 👋
Thanks for visiting my blog! I’m a student just like you, sharing what I learn to help others with Python programming. I hope my posts are useful for your studies! 😊
If you find this post helpful, please leave a comment—even just a few emojis will make my day! 🐍✨ Your feedback keeps me motivated to create more content for everyone. 🚀
Happy programming!
— Abhin Krishna, S01, EB Department, MEC
Pseudocode:
BEGIN
DISPLAY "Temperature Conversion:"
DISPLAY "1. Convert Celsius to Fahrenheit"
DISPLAY "2. Convert Fahrenheit to Celsius"
INPUT choice
IF choice = "1" THEN
INPUT celsius
fahrenheit ← (celsius × 9/5) + 32
DISPLAY celsius + "°C is equal to " + fahrenheit + "°F"
ELSE IF choice = "2" THEN
INPUT fahrenheit
celsius ← (fahrenheit - 32) × 5/9
DISPLAY fahrenheit + "°F is equal to " + celsius + "°C"
ELSE
DISPLAY "Invalid choice. Please enter 1 or 2"
END IF
END
Program:
# Temperature Conversion Program
print("\nTemperature Conversion:")
print("1. Convert Celsius to Fahrenheit")
print("2. Convert Fahrenheit to Celsius")
choice = input("Enter your choice (1/2): ")
if choice == '1':
# Convert Celsius to Fahrenheit
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9/5) + 32
print(f"{celsius}°C is equal to {fahrenheit}°F")
elif choice == '2':
# Convert Fahrenheit to Celsius
fahrenheit = float(input("Enter temperature in Fahrenheit: "))
celsius = (fahrenheit - 32) * 5/9
print(f"{fahrenheit}°F is equal to {celsius}°C")
else:
print("Invalid choice. Please enter 1 or 2")
Important!
If you find any mistakes in my code or flowchart, please comment below this post. I will be happy to correct them and clear up any doubts you may have.