33. Formatted Strings Flashcards
How to insert types of dif names in a string with f
1
Q
what is formatted strings?
A
add f in a braket
-saying to make the variables available like strings
2
Q
How does
name = ‘Sofia’
age = 55
print(f’hi {name}. You are {age} years old’)
prints like?
A
hi Johnny you are 55 years old
3
Q
How do you use a .format?
A
supposed to be in the string, and the variables beside it go in the {} brackets
ex:
name = ‘Sofia’
age = 55
print(‘hi {}. You are {} years old’.format(‘Sofia’, ‘55’))