First page Back Continue Last page Overview Image

Schlüsselwort-Parameter und f-Strings

prices = [11.98, 9.56, 189.78, 0.75, 1267.645]

for price in prices:

print("price: {swiss:8.2f} ({swiss:10.4f})".format(swiss=0.86*price))

print("and now with f-strings:")

for price in prices:

print(f"price: {0.86*price:8.2f} ({0.86*price:10.4f})")

price: 10.30 ( 10.3028)

price: 8.22 ( 8.2216)

price: 163.21 ( 163.2108)

price: 0.65 ( 0.6450)

price: 1090.17 ( 1090.1747)

and now with f-strings:

price: 10.30 ( 10.3028)

price: 8.22 ( 8.2216)

price: 163.21 ( 163.2108)

price: 0.65 ( 0.6450)

price: 1090.17 ( 1090.1747)