Python Quiz
Check your Python knowledge with this quiz covering the whole tutorial.
How the Quiz Works
There are ten questions. Choose an answer for each one to see if it is correct, along with a short explanation. If you get one wrong, go back to that lesson and read it again.
| Questions | Topics |
|---|---|
| 1 to 3 | Syntax, variables and data types |
| 4 to 6 | Strings, operators and collections |
| 7 to 10 | Loops, functions, classes and errors |
Questions
Exercise
1. What will print(type(10 / 2)) show?
Exercise
2. Which of these creates a valid variable?
Exercise
3. What is the result of int("45") + 5?
Exercise
4. name = "Workownix". What is name[-3:]?
Exercise
5. Which collection does NOT allow duplicate values?
Exercise
6. prices = {"tea": 60}. How do you add a new item "coffee" with the value 150?
Exercise
7. What does list(range(1, 10, 3)) give?
Exercise
8. Which keyword sends a value back from a function?
Exercise
9. Inside a class, what does self refer to?
Exercise
10. Which exception does int("hello") raise?
