This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by mom12
over 9 years

% Operator ?

Throughout the course i have seen different letters used with the % operator. Example- (“%.2f” % total), or “this is %s or %s.” % ( x, y,) or in the classes course %d was used. Do the letters have some significance. Is ‘s’ used for strings? Also can you decode the ‘%.2f” in the first example above. Why the % operator then a dot before 2f? And what does 2f refer to? This is from tip calculator, lesson 5/5 Thank you.

Answer 54319e48282ae3b576005ca0

1 vote

Permalink

You aren’t supposed to know that yet, that is for later on. (:

points
over 9 years

5 comments

mom12 over 9 years

Wait a minute, I asked after I finished the course. It’s not fair to keep secrets.

mom12 over 9 years

I got that %d is numbers and %s is strings, is f function related?

Stha_M over 9 years

the ‘2’ in 2f refers to the padding around the number,you have the correct basic idea just relax.

Saved, thanks!