str.format()
"{} and {}".format("A", "B")
'A and B'
"{1} and {0}".format("A", "B")
'B and A'
"{n1}+{n2}={n3}".format(n1=1, n2=3, n3=4)
'1+3=4'
f-string
a=1
b=2
print(f"{a}+{b}")
1+2
print(f"{a+b}")
3
float {var: int_len . precision type }
type: 'f' fixed-point; 'e' scientific; '%' percentage
n = 123.456789
print(f"{n:.2f}")
123.46
print(f"{n:.4f}")
123.4568
print(f"{n:.2%}")
12345.68%
print(f"{n:.2e}")
1.23e+02
Alignment (< left-aligned; > right-aligned; ^ centered)
n1 = 123.456789
n2 = 987.654321
print(f"{n1:.2f}|{n2:.2f}")
123.46|987.65
print(f"{n1:<10.2f}|{n2:.2f}")
123.46 |987.65
print(f"{n1:>10.2f}|{n2:.2f}")
123.46|987.65
print(f"{n1:^10.2f}|{n2:.2f}")
123.46 |987.65