+ 1

How do you solve this, and what's the real explanation of int(input()) it's confusing

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. Input Format An integer that represents the total amount of fruit in the bowl.

4th Dec 2021, 8:01 PM
Bobby Richard
4 Respuestas
+ 3
Bobby Richard input () function bydefault returns String so if you want to take integer value as input then you need to cast with int function. So int(input())
4th Dec 2021, 8:15 PM
A͢J
A͢J - avatar
+ 3
input() returns a string, even if a number was given as input. It's going to be codified as a string, rather than an integer. In order to use that number for calculations, you need to convert it to an integer, and then, of course, store it in a variable. Therefore, you'll do: fruit = int(input()) This problem is way easier than it looks. Remember that the number of apples is equal to half the amount of pieces of fruit. Also, remember that // will give you the result of an integer division. For example: 5/2 equals 2.5 5//2 equals 2 You'll want to use // for this problem. Basically, you only need to perform one simple calculation and print the result.
4th Dec 2021, 8:14 PM
Gilpow
Gilpow - avatar
+ 1
Thanks both of you, finally was able to solve it, and it was surprisingly easy 🤔🤣
5th Dec 2021, 11:38 AM
Bobby Richard