-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathexercise1.py
30 lines (22 loc) · 980 Bytes
/
exercise1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'''
You are painting a wall. The instructions on the paint can says that 1 can of paint can cover 5 square meters of wall. Given a random height and width of wall, calculate how many cans of paint you'll need to buy.
number of cans = (wall height ✖️ wall width) ÷ coverage per can.
e.g. Height = 2, Width = 4, Coverage = 5
number of cans = (2 ✖️ 4) ÷ 5
= 1.6
= 1.6
But because you can't buy 0.6 of a can of paint, the result should be rounded up to 2 cans.
'''
# Write your code below this line 👇
import math
def paint_calc(height, width, cover):
area = height*width
cans = area/cover
print(math.ceil(cans))
# 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)