0
I need help identifying the mistake i made
THE QUESTION: Write a program that prompts the user to read in two input values: a number of feet, followed on a separate line by a number of inches. The program should convert this amount to centimeters. Assume that all input values are ints. 1 foot is 12 inches and 1 inch is 2.54 centimeter. Here is a sample run of the program. Sample run: This program converts feet and inches to centimeters. Enter number of feet: 4 Enter number of inches: 8 4 ft 8 in = 142.24 cm MY ATTEMPT: (i'm getting it wrong for some reason) print("This program converts feet and inches to centimeters") a=(float(input("Enter number of feet:"))) b=(float(input("Enter number of inches:"))) c=a*12 d=b*2.54 r=c+d print(c "ft" + d "in" + "=" + format(r) + "cm")
3 Antworten
+ 2
check for to format number and string
In yout code you have to do this:
print("{0} ft {1} in = {2} cm").format(a,b,r)
0
May you need just
r = (a*12+b)*2.54
Edit :
print("This program converts feet and inches to centimeters")
a=(float(input("Enter number of feet:")))
b=(float(input("Enter number of inches:")))
d=(a*12+b)*2.54
#r=c+d
print(f"{a} ft {b} in = {d} cm")
0
Hello