Python Programming Questions

1. What is the output of the following code?

A. Hello, World!

B. Compilation error

C. Runtime error

D. No output

      A. Hello, World!

2. Which of the following is not a valid data type in Python?

A. int

B. float

C. string

D. char

      D. char

3. What is the output of the following code?

A. 10

B. 25

C. 5

D. Compilation error

      B. 25

4. What is the output of the following code?

 

A. A

B. B

C. Compilation error

D. Runtime error

      A. A

5. What is the output of the following code?

A. 1

B. 2

C. 3

D. 4

      C. 3

6. What is the output of the following code?

A. 2

B. 3

C. 5

D. Compilation error

      C. 5

7. What is the output of the following code?

A. 4

B. 5

C. 6

D. Compilation error

      B. 5

8. What is the output of the following code?

A. 1

B. 2

C. Compilation error

D. a

      A. 1

9. What is the output of the following code?

A. 1

B. 2

C. 3

D. Compilation error

      B. 2

10. What is the output of the following code?

 

A. 3

B. 4

C. Compilation error

D. 2

      A. 3

11. Which function is used to open a file in Python?

A. open()

B. read()

C. write()

D. close()

      A. open()

12. What is the output of the following code?

A. Error

B. No output

C. Compilation error

D. Runtime error

      A. Error

13. What is the output of the following code?

A. 5

B. 10

C. Compilation error

D. Runtime error

      B. 10

14. What is the output of the following code?

A. [0, 1, 4]

B. [1, 4, 9]

C. Compilation error

D. [0, 1, 2]

      A. [0, 1, 4]

15. Which module is used for mathematical operations in Python?

A. math

B. random

C. os

D. sys

      A. math

16. What is the output of the following code?

A. Constructor called

B. No output

C. Compilation error

D. Runtime error

      A. Constructor called

17. Which keyword is used to inherit a class in Python?

A. extends

B. implements

C. super

D. class

      D. class

18. What is the output of the following code?

A. 1

B. 2

C. Compilation error

D. Runtime error

      A. 1

19. What is the output of the following code?

A. Before Hello After

B. Hello

C. Compilation error

D. Runtime error

      A. Before Hello After

20. Which module is used for threading in Python?

A. threading

B. multiprocessing

C. os

D. sys

      A. threading

Scroll to Top