Duck tape | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Duck tape

Hello. I am getting error on test #5, what is wrong with my code? Thank you very much. height_door=int(input()) weight_door=int(input()) door=height_door*weight_door*2 duc1=60/12 duc2=2 duck=duc1*duc2 print(round(door/duck)) You want to completely cover a flat door on both sides with duct tape. You need to know how many rolls of duct tape to buy when you go to the store. Task: Given the height and width of the door, determine how many rolls of duct tape you will need (a roll of duct tape is 60 feet long and 2 inches wide and there are 12 inches in each foot). Don't forget both sides of the door! Input Format: Two integers that represent the height and width of the door. Output Format: An integer that represents the total rolls of duct tape that you need to buy. Sample Input: 7 4 Sample Output: 6

6th Nov 2021, 3:47 PM
Adam Filip
3 Answers
+ 7
The issue is probably that you're rounding. For example assume you need 12.2 rolls. If you round this you get 12 rolls. But that is not enough. You actually need to buy 13 rolls. So instead of using round() import the math module and use math.ceil(). This will always round up.
6th Nov 2021, 3:58 PM
Simon Sauter
Simon Sauter - avatar
+ 1
Thank you very much. Its works!
6th Nov 2021, 4:03 PM
Adam Filip
+ 1
import math height = int(input()) width = int(input ()) total_tape = height *width*2 # 1 duck tape is equal to 10 feet(60*(2/12). 12 is divide to convert inch to feet). one_roller = 10 final = total_tape /one_roller print (int(math.ceil(final)))
27th Apr 2023, 4:46 AM
Jashwanth Goud
Jashwanth Goud - avatar