Solo Learn (Python for Beginners): Tip Calculator


When you go out to eat, you always tip 20% of the bill amount. But who’s got the time to calculate the right tip amount every time? Not you that’s for sure! You’re making a program to calculate tips and save some time.

Your program needs to take the bill amount as input and output the tip as a float.

Sample Input

Sample Output

I will do the same what my Professors in College does.

1. This is assign a value and data type to variable “bill” to let the computer know that bill will be and int (integer) variable to be inputted by the user.

3. Variable “x” = 20 because it was given in the problem above that 20% is the tip being given so we know that the tip should be 20.

4. Variable “y” = 100 everyone knows that there should be 100% in all of the calculations.

7. This line will be the actual computation to let the machine know that tip equals to the amount inputted by the user multiplied by the percentage of 20/100 which is equals to 0.2 which is also equals to 20%.

8. This line will produce an output of type float “tip” since the product of the computation will have decimal values.

P.S. We really discourage copy pasting solutions, what we encourage is the understanding of why the code works instead of memorizing it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s