I\'m having issues writing this problem in python correctly. I understand the co
ID: 3758967 • Letter: I
Question
I'm having issues writing this problem in python correctly. I understand the concept but I can't apply the modules correctly.
Problem 4
Define three functions to convert length:
inches_to_cm(inches): Convert inches to cm. 1 inch = 2.54 cm. Return cm.
feet_to_m(feet): Convert feet to m. 1 foot = 0.30 m. Return m.
miles_to_km(miles): Convert miles to km. 1 mile = 1.61 km. Return km.
Store these three functions in a length module.
Write a program to convert lengths. Ask the user to enter lengths in inches, feet and miles. Pass the lengths to the three functions in the length module. Display the converted lengths. The following is an example.
How many inches? 12
It is equivalent to 30.48 cm
How many feet? 4
It is equivalent to 1.2 m
How many miles? 26
It is equivalent to 41.86 km
Explanation / Answer
working python code:
# your code goes here
def cmtoinch(m):
return 2.54*m
def feettom(m):
return 0.3*m
def miltokm(m):
return 1.61*m
a=input("How many inches?")
cmtoinch(a)
print "It is equivalent to" + str(b) + " cm"
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.