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 | |
|---|---|---|
| 1'hello'[1,4] | AOk: Reverses the string | |
| 2'hello'[10:20] | BValid: Returns 'hel' | |
| 3'hello'[:3] | CError: Use colon not comma | |
| 4'hello'[::-1] | DInvalid: But returns '' not error | |
| 5print('hello'[1:4]) | EOutput: ell | |
| 6print('python'[2:]) | FOutput: thon |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Slice — Extract a portion of a string using [start:stop].~~[start:stop]word = 'Python'
print(word[0:3])word = 'hello'
print(word[:3])word = 'hello'
print(word[2:])word = 'hello'
print(word[::-1])text = 'abcdef'
print(text[1:5])