# How do I use %

#1

How do I use % in my calculations eg meal + tax% + tip% = print

#2

in python `%` is the modulo operator it gives you the remainder:

``18 % 5 = 3``

for division use `/`.

#3

For performing division in the Tip Calculator exercises, use the `/` division operator, as @stetim94 has advised.

The `%` character performs several different roles in Python, even within this set of exercises, and it is important to be aware of differences in the meaning of its various occurrences.

• In the instructions, `%` is used to describe the tip and the tax in terms of percentages.

• In some of the Python code, it is used for string formatting. It appears twice in the following line ...

``print("%.2f" % meal)``

Its first occurrence on that line identifies `"%.2f"` as a format string. In its second occurrence on that same line, it serves as a string interpolation operator, which applies the preceding format string to the value of `meal`, so that the value is displayed with a precision of two decimal places.

As @stetim94 mentioned, `%` also serves as a modulo, or remainder, operator in other contexts. The modulo operator is used quite often in programming, and will play a role in later exercises within the Python track.

#4

Thank very much, your posts were really helpful, I'm not sure I'm formatting the % correctly in my calculations, as it runs an error message! Everything runs correctly until I introduce %

Thanks again for taking the time to respond!

#5

Post your code, if it is still not working. Be sure to format the code when you post it.