Worksheets1.2.1 - 1.2.2 Test
Total questions: 22
Worksheet time: 26mins
Name
Class
Date
1.
What is the primary purpose of modular programming?
a)
To make code more complex
b)
To slow down program execution
c)
To increase code readability and maintainability
d)
To reduce the number of functions
2.
What does procedural abstraction allow a programmer to do?
a)
Know exactly how a procedure works internally
b)
Use a procedure by knowing what it does, not how it does it
c)
Eliminate the need for functions
d)
Write longer code
3.
In event-driven programming, what triggers program execution?
a)
Random number generation
b)
Predefined time intervals
c)
Specific events or user actions
d)
Sequential code flow
4.
What does the global keyword do in Python?
a)
Defines a variable's scope across the entire program
b)
Creates a new variable
c)
Limits a variable's accessibility
d)
Deletes a variable
5.
What is the primary benefit of using the random module?
a)
To make code more predictable
b)
To slow down program execution
c)
To increase code complexity
d)
To generate random numbers or select random items
6.
What does the append() method do in a list?
a)
Adds an element to the end of the list
b)
Sorts the list
c)
Removes an element
d)
Adds an element to the beginning of the list
7.
What is the purpose of the len() function with lists?
a)
To create a new list
b)
To sort list elements
c)
To determine the number of elements in a list
d)
To remove elements from a list
8.
What does the break statement do in a loop?
a)
Continues the loop
b)
Skips one iteration
c)
Repeats the loop
d)
Stops the loop's execution
9.
What is an event in programming?
a)
A type of function
b)
A programming error
c)
A time-based occurrence
d)
A trigger that causes a specific part of the program to execute
10.
What does the 'or' boolean operator do?
a)
Always returns False
b)
Returns True only if both expressions are True
c)
Reverses the boolean value
d)
Returns True if either expression is True
11.
What is the primary goal of program decomposition?
a)
To make code more complicated
b)
To break down code into smaller, manageable parts
c)
To eliminate functions
d)
To reduce code readability
12.
What does data abstraction help manage in a program?
a)
Program complexity
b)
User interfaces
c)
Network connections
d)
Hardware resources
13.
How do you access a specific element in a list?
a)
Using curly braces {}
b)
Using parentheses ()
c)
Using square brackets []
d)
Using angle brackets <>
14.
What does the insert() method do in a list?
a)
Removes an element
b)
Adds an element at a specific index
c)
Reverses the list
d)
Sorts the list
15.
What is a function in Python?
a)
A type of variable
b)
A mathematical equation
c)
A set of code that performs a specific action
d)
A programming error
16.
What does the 'not' boolean operator do?
a)
Reverses the boolean value
b)
Divides boolean values
c)
Multiplies boolean values
d)
Adds two boolean values
17.
What does randint() do in the random module?
a)
Removes random elements
b)
Generates a random string
c)
Generates a random integer within a specified range
d)
Creates a random list
18.
What is the scope of a variable?
a)
The physical size of the variable
b)
The portion of a program that can access the variable
c)
The data type of the variable
d)
The memory location of the variable
19.
What does the remove() method do in a list?
a)
Duplicates the list
b)
Sorts the list
c)
Adds an element
d)
Removes a specific element from the list
20.
Explain how modular programming contributes to code maintainability and why breaking down complex programs into smaller modules is beneficial for software development.
4 lines
21.
Describe the concept of event-driven programming and provide a real-world example of how event handling might be implemented in a software application.
4 lines
22.
Compare and contrast global and local variable scopes in Python. Why is understanding variable scope important in programming?
4 lines
100 %
