menu

Python Control Structures


1. Which statement is used to create a list in Python?

[ ]

( )

{ }

| |


2. 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):


3. Which of the following statements is used to check if a key is in a dictionary in Python?

key in dictionary

dictionary.contains(key)

dictionary.include(key)

key.exists(dictionary)


4.

Which of the following is a control structure in Python?

Functions

Variables

Loops

Strings


5. Which of the following statements is used to add an element to the end of a list in Python?

list.add(element)

list.insert(index, element)

list.append(element)

list.push(element)


6. Which operator is used to check if two values are equal in Python?

=

==

===

!=


7. Which statement is used to skip the current iteration of a loop in Python?

break

continue

pass

skip


8. Which of the following is not a type of loop in Python?

for loop

while loop

do-while loop

nested loop


9. Which of the following statements is used to concatenate two strings in Python?

string1.add(string2)

string1.concat(string2)

string1 + string2

string1.join(string2)


10. Which statement is used to call a function in Python?

call

invoke

run

None of the above