Examplary
Start for free
Oak ComputingTest · Computing

Substrings

The starter and exit quiz of the lesson “Substrings”, from the unit “Programming: strings and lists” (Year 10 Computing) by Oak National Academy.

Free to use. Edit it, share it and hand it out to your students.

Oak National Academy

12 questions

  1. What is a string in programming?
  2. How do you determine the length of a string in Python?
  3. What will this program output?word = "Python"print(word[3])
  4. What will happen if you try to access an index that is greater than or equal to the string length?
  5. What does the following code print?word = "hello"print(word[-1])
  6. What does the following code output?word = "hello"for letter in word: print(letter)
  7. What is a substring?
  8. What will the following Python code output?word = "HELLO"print(word[1:4])
  9. What is the correct syntax to extract the substring "pin" from "pineapple", which is stored in the variable fruit?
  10. Which of the following statements about slicing in Python is true?
  11. How do you check if the substring "apple" is in the string "pineapple"?
  12. What does the following Python program do?char = input("Enter a character: ")print(ord(char))

License: OGL

Substrings · Examplary