Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1word = 'cat' word[3] | AOk: Returns last char 'o' | |
| 2word = 'hello' word[1] = 'a' | BValid: Returns 'p' | |
| 3'python'[0] | COutput: P | |
| 4'hello'[-1] | DOutput: n | |
| 5w = 'Python' print(w[0]) | EError: Index 3 out of range | |
| 6w = 'Python' print(w[-1]) | FError: Strings are immutable |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Index — The position number of a character in a string, starting at 0.~~string[0]name = 'Python'
print(name[0])word = 'hello'
print(word[-1])name = 'Alice'
print(len('Alice'))text = 'code'
print(text[2])word = 'Python'
print(word[5])