day 8-3 python (페인트 면적 계산기)
2023. 3. 10. 10:29ㆍ개인적인 공부/Python
Instructions
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 x wall width) ÷ coverage per can.
e.g. Height = 2, Width = 4, Coverage = 5
number of cans = (2 * 4) / 5
= 1.6
But because you can't buy 0.6 of a can of paint, the result should be rounded up to 2 cans.
IMPORTANT: Notice the name of the function and parameters must match those on line 13 for the code to work.
Example Input
test_h = 3
test_w = 9
Example Output
You'll need 6 cans of paint.
나의 코드
#Write your code below this line 👇
import math
def paint_calc(height, width, cover):
number_of_cans = math.ceil(height*width/cover)
print(f"You'll need {number_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)
'개인적인 공부 > Python' 카테고리의 다른 글
day 8-2 python (위치와 키워드) (0) | 2023.03.10 |
---|---|
day 8-1 python (입력 값이 있는 함수) (0) | 2023.03.10 |
day 7-3 hangman (0) | 2023.03.10 |
day 7-2 hangman (1) | 2023.03.10 |
day 7-1 hangman (0) | 2023.03.10 |