#The {} are replaced by the vairables after .format
new_string = "{} is string 1 and {} is string 2".format("fish", "pigs")
# String Formatting
name1 = 'Andrei'
name2 = 'Sunny'
print(f'Hello there {name1} and {name2}') # Hello there Andrei and Sunny - Newer way to do things as of python 3.6
print('Hello there {} and {}'.format(name1, name2))# Hello there Andrei and Sunny
print('Hello there %s and %s' %(name1, name2)) # Hello there Andrei and Sunny --> you can also use %d, %f, %r for integers, floats, string representations of objects respectively
print('The {2} {1} {0}'.format('fox', 'brown', 'quick'))
result = 100/777
print('{newvar}'.format(newvar = result))
print('the result was {r:0.3f}'.format(r = result))
age = 36
txt = "his age is {}"
print(txt.format(age))
# use {}, where u want to place integer, or any other datatype.
# Use .formate at the end of string,
# and finally place data variable in parentheses
a = 123.1133
b = "Username"
c = True
print("a = {}".format(a))
print("b = {}".format(b))
print("c = {}".format(c))
>>> print("He said, "What's there?"")
...
SyntaxError: invalid syntax
>>> print('He said, "What's there?"')
...
SyntaxError: invalid syntax
name = 'marcog'
number = 42
print('%s %d' % (name, number))
age = 11
my_self = "My name is Vishnu, I am " + str(age)
print(my_self)