Using fstrings Python3

Examples of using fstrings in Python3 as opposed to use %s or .format()

ip = '10.10.10.15'
example = f'The IP Address is {ip}'
The Ip Address is 10.10.10.15

# Calculations
print(f'The result of 4 times 10 is {4 * 10}')
40

# Formatting
pi = 3.14159265359
print(f'Pi is {pi:.2f}')
3.14

Last updated