Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In python language please, thank you in advance :) Write a complete Python scrip

ID: 3690459 • Letter: I

Question

In python language please, thank you in advance :)

Write a complete Python script that asks the users from which unit they want to convert (only gal, lb and mi) and to which unit they want to convert (only l, kg and km). Reject incompatible conversions such as gal rightarrow km. For a valid conversion, take a value to convert and display the result. Save your script as "PAl_Question2.py" in csMMPAl folder. The valid unit conversions arc as follow: You may follow the steps shown in the flowchart given below. The user interface of your script may look like as follows (Values in black arc user input):

Explanation / Answer

def conversion():
print "Unit Conversion"
input1 = raw_input("Convert from (only gal,lb and mi)? ")
input2 = raw_input("Convert from (only l, kg, km)? ")
if input1 == "gal":
if input2 == "l":
value = raw_input("Value? ")
print value,
print " gal = ",
print float(value) * 3.78541,
print " l"
else:
print "Error: Incompatible conversion"

if input1 == "lb":
if input2 == "kg":
value = raw_input("Value? ")
print value,
print " lb = ",
print float(value)*0.45359,
print " kg"
else:
print "Error: Incompatible conversion"

if input1 == "mi":
if input2 == "km":
value = raw_input("Value? ")
print value,
print " mi = ",
print float(value)*0.160934,
print " km"
else:
print "Error: Incompatible conversion"

conversion()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote