menu

Python Control Structures


1. Which of the following statements is used to check if a value is in a list in Python?

value in list

list.contains(value)

list.include(value)

value.exists(list)


2. Which keyword is used to define a block of code in Python?

block

segment

suite

module


3. Which of the following statements is used to import a module in Python?

module.import(module_name)

import module_name

from module_name import *

All of the above


4. Which statement is used to create a dictionary in Python?

[ ]

( )

{ }

| |


5. Which of the following statements is used to create a function in Python?

def function_name(arguments):

function function_name(arguments):

function_name(arguments) def:

function_name def(arguments):


6. Which statement is used to define a function in Python?

def

function

define

func


7. Which of the following statements is used to remove an element from a list in Python?

list.remove(element)

list.pop(index)

list.delete(element)

list.splice(index, 1)


8. Which of the following statements is used to break out of nested loops in Python?

continue

pass

break

exit


9. Which statement is used to exit a loop prematurely in Python?

break

continue

pass

exit


10. Which of the following statements is used to check if a number is odd in Python?

num % 2 == 0

num % 2 == 1

num.is_odd()

num.odd()