python f string or python Formatted string literals

python f string is a new string formatting method in python, f string is much simpler and readable way of formatting strings in Python.The f-strings start with f prefix and use {} symbol to evaluate values.The python f-strings stands for python Formatted string literals.

Syntax

print(f"{var} constant.") 
# Python f string 
link = 'percentagetool.com'
print(f"{link } is a simple online website for percentage calculations.") 

Out Put 
percentagetool.com is a simple online website for percentage calculations

# Python f-string 

link = 'tutorialshore.com'
alexa=14999
print(f"{link} is a website with alexa rank {alexa}") 

Out Put 
tutorialshore.com is a website with alexa rank 14999
#using function in python f string 

def sum(x, y):

    return x + y

p = 8
q = 4

print(f'sum  of {p} and {q} is {sum(p, q)}')


Out put

sum  of 8 and 4 is 12

My Thought

Your email address will not be published. Required fields are marked *

Our Tool : hike percentage calculator