1#Use f-string
2#Example:
3
4x = 2
5y = f'This is a string using variable x: {x}'
6print(y)
7
8#Output:
9#This is a string using variable x: 2
1# Python string variable
2
3mystring = 'This is a string!'
4
5print(mystring)
1>>> shepherd = "Mary"
2>>> age = 32
3>>> stuff_in_string = "Shepherd {} is {} years old.".format(shepherd, age)
4>>> print(stuff_in_string)
5Shepherd Mary is 32 years old.
6
1#Pre 3.6
2print('Hi, my name is {name} and my age is {age}'.format(**locals()))
3
4#After 3.6
5print('Hi, my name is {name} and my age is {age}')
1>>> x = None
2>>> print type(x)
3<type 'NoneType'>
4>>> x = "text"
5>>> print type(x)
6<type 'str'>
7>>> x = 42
8>>> print type(x)
9<type 'int'>