placeholder image to represent content

Python

Quiz by Amy Sam

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
26 questions
Show answers
  • Q1
    Which of the following is the correct way to comment a single line in Python?
    # Single Line Comment
    // Single Line Comment
    /* Single Line Comment */
    /* Multi-Line Comment */
    30s
  • Q2
    What is the output of the following code? print(3 * 2 ** 3)
    24
    4
    18
    12
    30s
  • Q3
    What is the output of the following code? print(len('python'))
    python
    5
    6
    7
    30s
  • Q4
    What keyword is used to define a function in Python?
    fun
    def
    define
    function
    30s
  • Q5
    What is the result of the following code snippet?numbers = [1, 2, 3, 4, 5]print(numbers[-2])
    1
    2
    4
    3
    30s
  • Q6
    What is the correct syntax to open a file for writing in Python?
    file = open('filename.txt', 'a')
    file = open('filename.txt', 'x')
    file = open('filename.txt', 'r')
    file = open('filename.txt', 'w')
    30s
  • Q7
    What is the output of the following code snippet?name = 'Python'print(name[1:4])
    'thon'
    'Pyt'
    'yth'
    'y'
    30s
  • Q8
    Which of the following is a correct way to define a dictionary in Python?
    my_dict = ('key1': 'value1', 'key2': 'value2')
    my_dict = {'key1': 'value1', 'key2': 'value2'}
    my_dict = ['key1': 'value1', 'key2': 'value2']
    30s
  • Q9
    Which of the following is true about Python?
    Python can only run on Windows operating system.
    Python does not support object-oriented programming.
    Python is a high-level language.
    Python is a compiled language.
    Python is an interpreted language.
    30s
  • Q10
    What is the correct syntax to define a class in Python?
    class MyClass:
    class = MyClass:
    function MyClass:
    def MyClass:
    30s
  • Q11
    Which of the following is used to repeat a block of code in Python?
    Class
    Loop
    Variable
    Function
    30s
  • Q12
    What is the syntax for defining a function in Python?
    def function_name():
    def function_name:
    function_name():
    30s
  • Q13
    What is the output of the following print statement: print(3 + 5 * 2)
    10
    11
    16
    13
    30s
  • Q14
    What is the file extension for a Python script file?
    .txt
    .pyc
    .java
    .py
    30s
  • Q15
    Which of the following is used to check if a condition is true or false in Python?
    if statement
    while loop
    for loop
    switch statement
    30s

Teachers give this quiz to your class