Tutorials › Python Tutorial › Python Quiz

Python Quiz

10 min read · Lesson 24 of 24

You have reached the end of the Python Tutorial. Hongera! Test what you have learned with the questions below. Each question has one correct answer.

If you get a question wrong, go back to the related lesson, run the examples again and then retry the quiz.

Quiz 15 questions
1. What does print(10 / 4) display?
2. Which of these is a valid Python variable name?
3. What is the result of 17 % 5?
4. What does "Kisumu"[-1] return?
5. Which method adds an item to the end of a list?
6. What is printed by print(len({"a", "b", "a"}))?
7. How do you create a tuple that contains only the string "Kenya"?
8. Which expression safely reads a missing dictionary key without raising an error?
9. What does list(range(2, 8, 2)) produce?
10. Which keyword exits a loop immediately?
11. What does a function return if it has no return statement?
12. What is the value of [n * 2 for n in [1, 2, 3] if n > 1]?
13. In a class, what is the name of the method that runs automatically when an object is created?
14. Which block in a try statement always runs, whether or not an error occurred?
15. Which file mode adds new text to the end of an existing file without erasing it?

What next?

Well done for completing the tutorial. Here are some ideas to keep improving:

  • Revisit the Built-in Functions Reference and try each function in the editor.
  • Build a small project: a shopping list manager, a school grade calculator or a budget tracker that saves to a CSV file (see File Handling).
  • Practise reading error messages and handling them with Try...Except.
  • Explore more of the standard library, such as json, statistics and collections.
Tip: The best way to learn programming is to build something you care about. Start small, finish it, then make it a little bigger.
Sign in or create a free account to track progress, earn XP, badges and a certificate.