Python Quiz Questions and Answers

What is called when a function is defined inside a class?

Answer :
  • Method

Is it possible to link a Python program to code written in C?

Answer :
  • Yes; the C code can be in a form of a dynamically or a statically linked library.

What is a correct syntax to output "Hello World" in Python?

Answer :
  • print("Hello World")

What is used to define a block of code (body of loop, function etc.) in Python?

Answer :
  • Indentation

What is the correct file extension for Python files?

Answer :
  • .py

To run a python script file named test.py, use the command _____.

Answer :
  • python test.py

_____is interpreted.

Answer :
  • python

In Python, 'Hello', is the same as "Hello".

Answer :
  • TRUE

Which of the following is an invalid statement?

Answer :
  • x y z = 1 2 3

Which of the following cannot be a variable ?

Answer :
  • def