How do I use % in my calculations eg meal + tax% + tip% = print
% is the modulo operator it gives you the remainder:
18 % 5 = 3
for division use
% 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.
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!