Calculations and Variables
MRAB
python at mrabarnett.plus.com
Fri Nov 1 13:07:23 EDT 2019
On 2019-11-01 12:36, Rhodri James wrote:
> On 31/10/2019 20:14, MRAB wrote:
>> On 2019-10-31 18:46, ferzan saglam wrote:
>>> The code below which I have written should print the result of 43.6
>>> with the given values I have included at the end of this question, but
>>> for some odd reason I get the result of 44.44.
>>>
>>>
>>> bill = (input("Enter the total cost of the meal: \n"))
>>> tip = (input("Enter how much the tip is: \n"))
>>> split = (input("Enter how many people there are: \n"))
>>
>> Why are there parentheses around the inputs? Have you omitted the
>> conversion to numbers?
>
> My guess is the OP is using Python2 rather than Python3. So my first
> piece of advice would be to switch to Python3 now so you don't have to
> re-learn oddities like input(), print() and string handling.
>
The OP says it prints 44.44.
In Python 2, / does integer division, so it would print 44.00.
More information about the Python-list
mailing list