Chapter 8: Python
A. Multiple choice questions.
1. Which of the following is the syntax of for loop in Python?
a. for counter in range(number): c. for in counter range(number):
b. for in range(number) counter: d. for range counter(number):
2. Which of the following function return the length of a list?
a. Length() c. Len_list()
b. Len() d. List_length()
3. What does the statement”del NumberList[1]” does in Python list?
a. Deletes the data having 1 in the list named NumberList
b. Deletes the first item of the list named NumberList
c. Deletes the second item in the list named NumberList
d. Deletes the last item in the list named NumberList
4. Which of the following is not a logical operator?
a. And c. Not
b. Or d. Xor
5. Which of the following is the file extension of a file created in Python?
a. .py c. .pyh
b. .pyt d. .pyn
B. Fill in the blanks.
1. A function is used by calling its name with_________________.
2. A _______________ is used to store values.
3. The ___________________ function is used to define how many times the
user want the loop to be repeated.
4. The ___________________ method is used to delete the last item of the list.
5. The ____________________ statement creates a variable named counter
and store 0 in it.
C. State True or False.
1. Python does not run in a web browser. __
2. It is very difficult to create functions in Python. __
3. The body of a Python function is enclosed within curly brackets. __
4. All the output in Python is displayed in terminal window. __
5. All the code that is part of the function must start on a new line & indented. __
D. Match the columns.
Column A Column B
1. Local scope of a variable: a. It is executed only when if condition is false
2. Global scope of variable: b. Used to exit a loop
3. Else part c. It can be used only within that function
4. == d. An arithmetic operator called equal to
5. Break statement e. It can be accessed by all the functions
E. Answer in one word.
1. A lightweight but powerful source code editor which runs on desktop.
______________________________________________________________
2. A keyword used to define a Python function.
______________________________________________________________
3. The type of loop used when the user do not know how many times a loop
needs to be repeated.
______________________________________________________________
4. It is a set of data separated by commas and enclosed within a pair of square
brackets.
______________________________________________________________
5. Syntax to insert the data 100 at position 1 in the list named NumberList.
______________________________________________________________