Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use math.ceil?

I am writing a code about counting the number of cans needed to paint a wall. Od course number of cans should be round up. And there is my problem because math.ceil doesn’t work.

#Write your code below this line ๐Ÿ‘‡
import math

def paint_calc(height, width, cover):
    num_of_cans = math.ceil(height*width) / cover
    print(f"You'll need {num_of_cans} cans of paint.")


#Write your code above this line ๐Ÿ‘†
# Define a function called paint_calc() so that the code below works.   

# ๐Ÿšจ Don't change the code below ๐Ÿ‘‡
test_h = int(input("Height of wall: "))
test_w = int(input("Width of wall: "))
coverage = 5
paint_calc(height=test_h, width=test_w, cover=coverage)

Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You should ceil the final number, not the surface area:

math.ceil(height*width / cover)

In place of:

math.ceil(height*width) / cover
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use