1
Edhesive Computer Science 2.3 Help!
linda231 (1)

The language used is Python and the question asks - Write a program that inputs the length of two pieces of fabric in feet and inches (as whole numbers) and prints the total.
Enter the Feet for the first piece of fabric: 3
Enter the Inches for the first piece of fabric: 11
Enter the Feet for the second piece of fabric: 2
Enter the Inches for the second piece of fabric: 5
It displays:
Feet: 6 Inches: 4

So far I have this:
x=float(input("Enter the Feet for the first piece of fabric:"))
y=float (input("Enter the Inches for the first piece of fabric:"))
j=float (input("Enter the Feet for the second piece of fabric:"))
k=float (input("Enter the Inches for the second piece of fabric:"))
print ("Total: "+str((x+j%(k+y))
And it just ain't working
Can someone help?

You are viewing a single comment. View All
Answered by heyitsmarcus (280) [earned 5 cycles]
View Answer
2
JustARatherRidi (185)

Problem 1: You're missing two closing parentheses after your print statement

Problem 2: What you're printing isn't quite right. After inputting the values, you should do something like this:

feet = x  + j
inches = y + k

# If we have 12 or more inches, add the
# appropriate number of feet
feet += inches // 12

# Divide inches by 12, get the remainder,
# and make that the value of 'inches'
inches = inches % 12

print('Feet:', feet, 'Inches:', inches)

Although I did answer this question because it wasn't too confusing, next time onwards you should definitely (at least) do the things @ash15khng has mentioned.

2
heyitsmarcus (280)

@JustARatherRidi they were missing 2 parenthesis. But also, your solution is not right as it is incorrect in the logic and missing requirements.

1
JustARatherRidi (185)

@heyitsmarcus Fixed it now, but I definitely messed that up 😛
You win this one

1
heyitsmarcus (280)

@JustARatherRidi No winning here man. We're all trying to help people, but we must be wary about giving them the correct information, that's all.

1
JustARatherRidi (185)

@heyitsmarcus True, but you won in the sense that you've managed to help the op better.

1
heyitsmarcus (280)

@JustARatherRidi As you learn more, so shall you too help better :)

1
linda231 (1)

@JustARatherRidi Thanks! I'll remember your advice!