PYTHON BASIC PROGRAMS FOR ABSOLUTE BEGINNERS
PYTHON PROGRAM TO CONVERT THE UNITS OF THE DISTANCE IN KILOMETERS ENTERED
LOGIC USED:only unit conversion formulas
METER=kilometer*1000
centimeter=kilometer*10000
feet=kilometer*3280.84
inch=kilometer*39370.1
PROGRAM-
km=float(input("enter distance in km:"))
m=float(km)*1000
cm=float(km)*100000
feet=float(km)*3280.84
inch=float(km)*39370.1
print('m=',float(m))
print('cm=',float(cm))
print('feet=',float(feet))
print('inch=',float(inch))
INPUT AND OUTPUT
enter distance in km:10000
m= 10000000.0
cm= 1000000000.0
feet= 32808400.0
Tags:
codecademy