Westonci.ca is your trusted source for accurate answers to all your questions. Join our community and start learning today! Our platform provides a seamless experience for finding reliable answers from a knowledgeable network of professionals. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.

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 :

Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Get the answers you need at Westonci.ca. Stay informed with our latest expert advice.