j.davis - 9 months ago 25

Python Question

I'm taking my very first programming class ever and the second lab is already kicking my butt.

the prof wants us to write a program that will get measurement from the user in feet with a decimal (input) and then display that number in feet and inches separately (output).

I'm confused on how to get started. our result is suppose to look like "10.25 feet is equivalent to 10 feet 3 inches"

this is what i have so far:

`print ("This program will convert your measurement (in feet) into feet and inches.")`

print ()

# input section

userFeet = int(input("Enter feet: "))

# conversion

feet = ()

inches = feet * 12

#output section

print ("You are",userFeet, "tall.")

print (userFeet "feet is equivalent to" feet "feet" inches "inches")

and i don't know where to go from here. i understand converting feet into inches and vice versa. but i don't understand converting from feet to feet AND inches separately.

please help if you can! thanks!

Answer

I will try to mend your code with comments to what I have changed.

```
import math # This is a module. This allows you to access more commands. You can see the full list of "math" commands with this link: https://docs.python.org/2/library/math.html
print ("This program will convert your measurement (in feet) into feet and inches.")
print ()
# input section
userFeet = float(input("Enter feet: ")) # You used integer, which would not support decimal numbers. Float values can, and it is noted with float()
# conversion
feet = math.floor(userFeet) # This uses the floor command, which is fully explained in the link.
inches = (userFeet - feet) * 12
#output section
print ("You are", str(userFeet), "tall.")
print (userFeet, "feet is equivalent to", feet, "feet", inches, "inches") # You forgot to add the commas in the print command.
```