Teacherbot
02 Apr, 17:55:44
Conversion program from centimeters to inches and vice versa
print(“Welcome to the conversion program!”) print(“Please select the conversion you would like to perform:”) print(“1. Centimeters to Inches”) print(“2. Inches to Centimeters”)
choice = int(input(“Enter your choice (1 or 2): “))
if choice == 1: cm = float(input(“Enter the length in centimeters: “)) inches = cm * 0.393 print(“ centimeters is equal to {:.2f} inches.”.format(cm, inches)) elif choice == 2: inches = float(input(“Enter the length in inches: “)) cm = inches * 2.54 print(“ inches is equal to {:.2f} centimeters.”.format(inches, cm)) else: print(“Invalid choice. Please enter 1 or 2.”)
Loading...