String Formats

# Using Curly braces  
print("{} and {} both are the best friend".format("Devansh","Abhishek"))  
  
#Positional Argument  
print("{1} and {0} best players ".format("Virat","Rohit"))  
  
#Keyword Argument  
print("{a},{b},{c}".format(a = "James", b = "Peter", c = "Ricky"))  


OUTPUT:

Devansh and Abhishek both are the best friend
Rohit and Virat best players 
James,Peter,Ricky


=====================================================================


#example0
print("------------------->>>> example0 <<<-------------------------")
age = 36
print("age is:", age)
print("              ")

txt = ("My name is John, I am:",+ age)
print(txt)

print("              ")
print("              ")
print("              ")
print("              ")


#example3
print("------------------->>>> example3 <<<-------------------------")
age = 36
print("age is:", age)
print("              ")
      
txt = "My name is John, and I am {}"
print(txt.format(age))

print("              ")
print("              ")
print("              ")

      
#example1
print("------------------->>>> example1 <<<-------------------------")
quantity = 3
itemno = 567
price = 49.95
myorder = "I want {} pieces of item {} for {} dollars."
print(myorder.format(quantity, itemno, price))

print("              ")
print("              ")
print("              ")

      
#example2
print("------------------->>>> example2 <<<-------------------------")
quantity = 3
itemno = 567
price = 49.95
myorder = "I want to pay {2} dollars for {0} pieces of item {1}."
print(myorder.format(quantity, itemno, price))

print("              ")
print("              ")
print("              ")


output:


------------------->>>> example0 <<<-------------------------
age is: 36
            
('My name is John, I am:', 36)
              
              
              
              
------------------->>>> example3 <<<-------------------------
age is: 36
              
My name is John, and I am 36
              
              
              
------------------->>>> example1 <<<-------------------------
I want 3 pieces of item 567 for 49.95 dollars.
              
              
              
------------------->>>> example2 <<<-------------------------
I want to pay 49.95 dollars for 3 pieces of item 567.