Calculations and Variables
MRAB
python at mrabarnett.plus.com
Thu Oct 31 16:14:16 EDT 2019
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?
> total = bill + (bill / tip)
That adds a 1/9 of the bill. It should add 9% of the bill.
> eachPay = total / split
> print("Each person will have to pay %.2f" % eachPay)
>
>
>
> I am aiming for the result of 43.6, but somehow get the result of 44.44.
> (meal cost: 200) (Tip: 9) (people: 5)
>
> I seem to do the calculation below, but get different results each time.
> Total * Percentage Amount / 100
>
More information about the Python-list
mailing list