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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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’))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly