Robin Nxumalo
Robin Nxumalo

Reputation: 1

MySQL-python-Calculator Tips

I’m unable to get the output I want. This is how far I was able to get:

bill = int(input())
print (125 /100 *20)

I’m still learning how to do this.

enter image description here

Upvotes: 0

Views: 61

Answers (1)

Anshumaan Mishra
Anshumaan Mishra

Reputation: 1362

The question is pretty straightforward. Everything is mentioned. To calculate 20% of an amount multiply it by 20 and divide it by 100.
Your input method is right but since bill can also be a float, using the float data type would be better. The error is in the print statement as you are, for some reason, dividing 125 rather than the bill you input.
Correct Code:

bill = float(input()) # taking a float input is a better option as the bill might be a float
print(bill*20/100) # tip = bill * 20 / 100

Upvotes: 1

Related Questions