String Quiz doubt

Q44. What is the f-string used for? Can you give an example?
Q45. What are the benefits of using the f-string instead of string concatenation?

Q47. How do you check if two strings have the same value?
I can’t understand this qns

We have written the answers to these question below but i would suggest you to look at the f-string part of our lecture on strings chapter from the lecture video.

Plus this is the place in content notebook where we have learnt f-string and comparing strings - Google Colab

You can look at more example here - f-strings in Python - GeeksforGeeks

The answers to each of the above questions are written below
Q44
f-string is used for printing variables within strings. It is also called formatted string.

str_1 = 'bread'
str_2 = 'butter'
 
str_line = f'I eat {str_1} and {str_2} in morning'
print(str_line)

The above code will print this -
I eat bread and butter in morning

Q45. (this is also covered in lecture video in f-string part - please look at that)
Readability is easier in case of f-string than concatenation. For eg. In case of f-string spaces can be easily handled while In case of concatenation we need to place spaces carefully wherever we are doing concatenation.

Q47.
Using ‘==’ comparison operator

1 Like