0
Could anyone tell me how to solve the fruit bowl challenge with python.
fruit = int(input()) apples = fruit / 2 pie = apples / 3 if pie % 3 == 0: print(pie)
3 Answers
+ 4
Your attempt is missing in the question description
+ 4
fruit = int(input())
def apple(data):
data = data//2 # this code line was data = data/2 before solving
return data
b = apple(fruit)
print (b // 3)
----------------------------------------------
fruit=int(input()) converts a string into integer so basically asking a user to enter an integer
b=apple(fruit)
here apple function is called with fruit as argument for the parameter data and result returned from the apple function is assigned to variable b
b//3 is called floor division
If b is 7 then you will get 2 as output
In function apple ,
In line data=data//2 ,Data is assigned the result as a evaluation of data//2 and returned back to the function call
0
That's the code I could think of for that case could you help