You have a bowl on your counter with an even number of pieces of fruit in it. Half of them are bananas, and the other half are apples. You need 3 apples to make a pie.
Task
Your task is to evaluate the total number of pies that you can make with the apples that are in your bowl given to total amount of fruit in the bowl.
Ihis task in this way. Is there a better solution than this?
fruit = int(input())
pie = 0
apple = int(fruit /2)
while apple >= 3:
apple -= 3
pie += 1
print(pie)
>Solution :
replace the while statement with a floored division.
pie = floor(apple / 3)
print(pie)
to use floor you need to import the math library
it is similar to round but always rounds down and essentially truncates by 0 dp
if you don’t want to use floor, a cleaner syntax is
pie = apple // 3
print(pie)