Westonci.ca is the premier destination for reliable answers to your questions, brought to you by a community of experts. Discover the answers you need from a community of experts ready to help you with their knowledge and experience in various fields. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.

Complete the following program to implement the user interface of the preceding exercise. For simplicity, only the units cm, m, and in are supported. Empty print statements are included for output formatting.

done = False
factor = 0.0

while not done :
getSecond = True
command = input("From unit (in, cm, m, again, quit): ")
print()
if command == "in" :
factor = 2.54 # Conversion factor from in to cm
unit1 = command
elif command == "cm" :
# Your code goes here
elif command == "m" :
# Your code goes here
elif command == "again" :
getSecond = False
elif command == "quit" :
done = True
getSecond = False
else :
print("Sorry, unknown unit.")
getSecond = False

if getSecond :
unit2 = input("To unit: ")
print()
if unit2 == "in" :
factor = factor / 2.54 # Convert factor from cm to in
elif # Your code goes here
elif # Your code goes here
print("Sorry, unknown unit.")
# Your code goes here
if not done and factor != 0.0 :
value = float(input("Enter the value to be converted: "))
print()
print(value, unit1, "=", value * factor, unit2)


Sagot :