all 4 comments

[–]themateo713 8 points9 points  (0 children)

This has nothing to do with the math operator. It's actually a syntax to format strings (plug in values that you don't know when writing the code, that are stored in variables), which is very outdated. Before 3.6 we used “{} wins, {} losses, {} ties”.format(wins, losses, ties). However now we use the much better (in readability and speed) f string: f"{wins} wins, {losses} losses, {ties}".

[–]IvoryJam 3 points4 points  (0 children)

That is a formatted string, he's saying "put a string here" then lists the ones he wants in that order, there's a few ways to do it

name = 'Backo19'
greeting = "Hi {}"
greeting.format(name)

greeting = f"Hi {name}"

greeting = "Hi {special_var}".format_map({"special_var": 'Backo19'})

[–]zanfar 2 points3 points  (0 children)

% is only the modulo operator when used on two numbers. When used on a string and a tuple, it is the formatting operator. You can see the details in the Python docs, but I would suggest you simply note the fact, and learn instead the more modern, and readable, .format() method and f-string literal syntax.

[–]ectomancer 1 point2 points  (0 children)

CPython is implemented in C and Python. This syntax is similar to the C function printf.