관련 문제
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
3
9
Example Output
You'll need 6 cans of paint.
페인트 너비높이 구해서 구매해야할 페인트통 구하기
import math
def paint_calc(height, width, cover):
number_of_paint = (height * width)/cover //페인트갯수 구하기
round_up_can = math.ceil(number_of_can) //페인트갯수 반올림하기
print(f"You'll need {round_up_can} cans of paint.")
# Write your code above this line 👆
# Define a function called paint_calc() so the code below works.
# 🚨 Don't change the code below 👇
test_h = int(input()) # Height of wall (m)
test_w = int(input()) # Width of wall (m)
coverage = 5
paint_calc(height=test_h, width=test_w, cover=coverage)
파이썬의 반올림하는 방법
https://stackoverflow.com/questions/2356501/how-do-you-round-up-a-number
How do you round UP a number?
How does one round a number UP in Python? I tried round(number) but it rounds the number down. Here is an example: round(2.3) = 2.0 and not 3, as I would like. Then I tried int(number + .5) but it
stackoverflow.com