It's called string formatting.
The evolution of string formatting.
f-string can take expressions here calculate and upper():
The evolution of string formatting.
>>> M = 100 >>> # old don't use >>> print('M = %d' % M) M = 100 >>> >>> # Python 2.6 we get format() >>> print('M = {}'.format(M)) M = 100 >>> >>> # Python 3.6 we get f-string >>> print(f'M = {M}') M = 100f-string is the future,but format() will be used for a long time.
f-string can take expressions here calculate and upper():
>>> a = 10 >>> b = 20 >>> s = 'correct' >>> print(f'The sum of a {a} and b {b} is {a+b} {s.upper()}') The sum of a 10 and b 20 is 30 CORRECTMore about format() PyForamt.