101k views
2 votes
Write a program which takes user input of a number of inches, and then prints the number of whole feet in that many inches (remember there are 12 inches in a foot). For example if the user enters 56 The program should print 4 As there are 4 whole feet in 56 inches (56'' is the same as 4'8'')

User Ichbinblau
by
6.9k points

1 Answer

2 votes

Answer:

inches = int(input("Enter the number of inches: "))

whole_feet = int(inches / 12)

print("There are " + str(whole_feet) + " whole feet in " + str(inches) + " inches")

Step-by-step explanation:

*The code is in Python.

Ask the user to enter the number of inches

Calculate the whole_feet by dividing the inches by 12 (Since 1 inch = 1/12 feet) and casting the result to int so that you can get the number of whole feet. Note that if you do not cast it to the int, you would get a decimal value

Print the result

User Jean Regisser
by
7.5k points