Python Quiz

python

1 / 20

print("Hello, World!")

 

2 / 20

Which of the following is a valid variable name in Python?

3 / 20

What is the correct file extension for Python files?

4 / 20

How do you insert COMMENTS in Python code?

5 / 20

Which keyword is used to create a function in Python?

6 / 20

What is the correct syntax to define a class in Python?

7 / 20

How do you start a for loop in Python?

8 / 20

list = [1, 2, 3, 4, 5] print(list[2])

 

9 / 20

How do you create a list in Python?

10 / 20

What is the output of the following code?

x = 5y = 10print(x + y)

 

11 / 20

Which of the following is a mutable data type in Python?

12 / 20

How do you import a module in Python?

13 / 20

What is the output of the following code?

x = [1, 2, 3]y = xy.append(4)print(x)

 

14 / 20

Which of the following is used to handle exceptions in Python?

15 / 20

What will be the output of the following code?

def func(a, b=2, c=3):    return a + b + cprint(func(1, c=4))

 

16 / 20

Which of the following is the correct way to create a set in Python?

17 / 20

How do you create a dictionary in Python?

18 / 20

What is the output of the following code?

def add(x, y):    return x + yprint(add("Hello", "World"))

 

19 / 20

Which of the following methods would you use to find the index of an element in a list?

20 / 20

What will be the output of the following code?

a = {1, 2, 3}b = {3, 4, 5}print(a & b)

 

Your score is

The average score is 36%

0%

Scroll to Top