Search the courses, subjects, tracks, games and features, or jump straight to a page.
5 cards from this section. Quick, good the night before a test.
Create three string variables: name holding Alice in double quotes, greeting holding Hello in single quotes, and city holding Paris in triple quotes. Print all three.
Close each string with the same kind of quote that opened it.
Which of these values are strings: "42", 42, 'True', True and "3.5"? Check your answer with type().
Look for the quotes. Anything inside quotes is text, even when it looks like a number or a boolean.
Which of these values is NOT a string?
Look for the value without any quotes.
Which kind of quotes lets one string span several lines?
The multi-line example in this lesson starts with three quote characters.
Print a welcome card for a fruit shop. Use a triple-quoted string for a three-line banner, a double-quoted string for the shop's motto Pune's freshest fruit, and a single-quoted string for a customer review that reads A customer said "Best mangoes in town". Print each string, then print the type of all three.
Choose the quotes by looking at what is inside the text: an apostrophe needs double quotes, quotation marks need single quotes, and several lines need triple quotes.
Each of these three strings has a quoting mistake: message = 'Don't panic', title = "The "Best" Day", and a shopping note that someone tried to write over two lines inside ordinary double quotes. Rewrite all three so that they work, and print them.
Match the quotes to the text: double quotes around an apostrophe, single quotes around double quotes, and triple quotes for more than one line.
6 more questions in this section. Enroll free to practise them all.
Enroll free