Various methods of String Formatting in Python



name = "Abdur"
age = 35
print("Hello %s!" % name) #  %s used for strings
print("Age is %d" % age)  #  %d used for numbers
print("%s is %d years old." %(name, age))
print("Hello {}!".format(name))
print(f"Hello {name}!")

 

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes