Python is a powerful and versatile programming language that has become a favorite among developers for its simplicity and readability. Whether you’re interested in web development, data analysis, or automation, Python has something to offer. This quiz will challenge your understanding of Python’s core concepts and help you gauge your proficiency. Get ready to put your Python skills to the test and see how much you really know!
We recommend that you do not leave the page that you are taking this quiz in. Stay honest 🙂
Python Quiz Questions Overview
1. What is the correct file extension for Python files?
.py
.python
.pt
.pyt
2. Which keyword is used to define a function in Python?
func
def
function
define
3. How do you insert comments in Python code?
// This is a comment
# This is a comment
/* This is a comment */
— This is a comment
4. Which of the following is not a valid variable name in Python?
my_var
2ndVar
_var
var2
5. What is the output of the following code: print(2 ** 3)?
5
6
8
9
6. Which of the following data types is immutable in Python?
List
Dictionary
Tuple
Set
7. How do you create a dictionary in Python?
my_dict = {}
my_dict = []
my_dict = ()
my_dict = <>
8. What is the output of the following code: print(‘Hello’ + ‘World’)?
Hello World
HelloWorld
Hello+World
Hello World
9. Which of the following is a valid way to import a module in Python?
import module
include module
using module
require module
10. What is the output of the following code: print(type(3.14))?
11. Which of the following methods can be used to add an element to a list in Python?
append()
add()
insert()
push()
12. What is the correct syntax for a for loop in Python?
for i in range(5):
for (i=0; i<5; i++):
for i to 5:
for i from 0 to 5:
13. How do you create a set in Python?
my_set = {}
my_set = []
my_set = set()
my_set = ()
14. Which of the following is used to handle exceptions in Python?
try/except
catch/except
try/catch
handle/except
15. What is the output of the following code: print(bool(0))?
True
False
0
None
16. Which of the following is a mutable data type in Python?
String
Tuple
List
Integer
17. Which of the following is the correct way to create a class in Python?
class MyClass:
MyClass class:
def MyClass:
create MyClass:
We recommend that you do not leave the page that you are taking this quiz in. Stay honest 🙂