Python
Quiz by Hardik Vedikin
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
60 questions
Show answers
- Q1Which of the following is a built-in data type in Python?dictionarylistarraytuple30s
- Q2What does the 'len()' function do in Python?returns the sum of all elements in a listreturns the length of a string, list, or tuplechecks if a value exists in a dictionaryconverts a string to lowercase30s
- Q3What is the output of the following code snippet?x = 5y = 2result = x // yprint(result)52.02.5230s
- Q4What is the result of the following expression?7 + 3 * 2 - 4168101230s
- Q5What is the correct way to open a file named 'data.txt' in read mode in Python?open('data.txt', 'r')open(file='data.txt', mode='r')open(file='data.txt', mode='read')open('data.txt')30s
- Q6What is the output of the following code snippet?x = [1, 2, 3]print(x[-1])132IndexError: list index out of range30s
- Q7Which of the following is the correct way to comment a single line of code in Python?// This is a comment/* This is a comment */# This is a comment<!-- This is a comment -->30s
- Q8What is the correct syntax for defining a function in Python?function my_function():def my_function():def my_function():def my_function::30s
- Q9Which of the following is a valid way to check if two variables refer to the same object in Python?variable1 == variable2variable1 is not variable2variable1 is variable2variable1 != variable230s
- Q10What is the correct way to check if a key exists in a dictionary in Python?key not in my_dictkey in my_dictmy_dict[key]my_dict.get(key)30s
- Q11Which of the following is a built-in function in Python?print()System.out.println()document.write()console.log()30s
- Q12What is the correct syntax for declaring a variable in Python?5 = xx = 5x := 5variable x = 530s
- Q13What does the 'len()' function do in Python?Return the length of a sequenceSort a dictionaryGenerate a random numberAppend elements to a list30s
- Q14What is the output of the following code?x = (1, 2, 3)print(x[1])2TypeError1330s
- Q15What is the correct way to write a comment in Python?/* This is a comment */<!-- This is a comment -->// This is a comment# This is a comment30s