
Python
Quiz by Amy Sam
Feel free to use or edit a copy
includes Teacher and Student dashboards
Measure skillsfrom any curriculum
Measure skills
from any curriculum
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
With a free account, teachers can
- edit the questions
- save a copy for later
- start a class game
- automatically assign follow-up activities based on students’ scores
- assign as homework
- share a link with colleagues
- print as a bubble sheet
26 questions
Show answers
- Q1Which 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
- Q2What is the output of the following code? print(3 * 2 ** 3)244181230s
- Q3What is the output of the following code? print(len('python'))python56730s
- Q4What keyword is used to define a function in Python?fundefdefinefunction30s
- Q5What is the result of the following code snippet?numbers = [1, 2, 3, 4, 5]print(numbers[-2])124330s
- Q6What 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
- Q7What is the output of the following code snippet?name = 'Python'print(name[1:4])'thon''Pyt''yth''y'30s
- Q8Which 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
- Q9Which 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
- Q10What is the correct syntax to define a class in Python?class MyClass:class = MyClass:function MyClass:def MyClass:30s
- Q11Which of the following is used to repeat a block of code in Python?ClassLoopVariableFunction30s
- Q12What is the syntax for defining a function in Python?def function_name():def function_name:function_name():30s
- Q13What is the output of the following print statement: print(3 + 5 * 2)1011161330s
- Q14What is the file extension for a Python script file?.txt.pyc.java.py30s
- Q15Which of the following is used to check if a condition is true or false in Python?if statementwhile loopfor loopswitch statement30s