Questions: String Operations and Methods

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

What does the following code print? s = "hello" s.upper() print(s)

A"HELLO"
B"hello"
CAn error, because upper() is not a valid string method
DNothing — print() requires an argument
Question 2 Multiple Choice

What does s[1:4] return when s = "python"?

A"yth"
B"pyt"
C"ytho"
D"ython"
Question 3 True / False

The expression s[::-1] reverses the string s.

TTrue
FFalse
Question 4 True / False

Calling s.strip() on a string removes its leading and trailing whitespace by modifying the original string in place.

TTrue
FFalse
Question 5 Short Answer

Why must you write s = s.upper() rather than just s.upper() if you want s to hold the uppercased version of the string?

Think about your answer, then reveal below.