omid
0
Q:

formatter in python

# Newer f-string format
name = "Foo"
age = 12
print(f"Hello, My name is {name} and I'm {age} years old.")
# output :
# Hello, my name is Foo and I'm 12 years old.
26
# Python3 program to demonstarte 
# the str.format() method 
  
# using format option in a simple string 
print ("{}, A computer science portal for geeks."
                        .format("GeeksforGeeks")) 
  
# using format option for a 
# value stored in a variable 
str = "This article is written in {}"
print (str.format("Python")) 
  
# formatting a string using a numeric constant 
print ("Hello, I am {} years old !".format(18))  
13
#TO  know this execute  and check
username,password = "GOOGLE","google"
#a. %  first type
print("User name=%s User password=%s"%(username,password))
#b. {}  second type
print("User name={} User password={}".format(username,password
#c. f  third type
print(f"User name={username} User password={password}")
print(f"User name={username} \nUser password={password}"
0

New to Communities?

Join the community