FBISE, NCP & NBF-aligned resources for Classes 9–12

Computer 11th

Computer 11th Chap 3 : Topic 5.3

/17

Report a question

You cannot submit an empty report. Please add some details.

Computer Chapter 3 : Topic 5.3

Populating Lists Using Loops

1 / 17

A Python program initializes an empty list and executes the following code:
$\mathbf{numbers = \lbrack\rbrack}$
$\mathbf{for\ i\ in\ range(4):}$
$\mathbf{numbers.append(i)}$
What will be stored in numbers after execution?

2 / 17

Why is repetition preferred over writing multiple assignment statements when populating large lists in Python programs?

3 / 17

Which variable changes its value during each iteration of the following loop and controls the sequence of stored values?
$\mathbf{for\ i\ in\ range(5):}$
$\mathbf{values.append(i + 2)}$

4 / 17

A Python program should store the even numbers less than $\mathbf{10}$ in a list. Which code correctly performs this task?

5 / 17

A programmer accidentally writes the following code:
$\mathbf{numbers = \lbrack\rbrack}$
$\mathbf{for\ i\ in\ range(5):}$
$\mathbf{print(i)}$
Why will this program fail?

6 / 17

Which sequence of operations correctly translates an algorithm that stores five user-entered values into a list?

7 / 17

Consider the following code:
$\mathbf{data = \lbrack\rbrack}$
$\mathbf{for\ i\ in\ range(3):}$
$\mathbf{data.append(i + 1)}$
$\mathbf{print(data)}$
What is the output?

8 / 17

Which statement best describes the purpose of the $\mathbf{append()}$ method while translating algorithms into Python?

9 / 17

A programmer wants to generate multiples of $\mathbf{3}$ up to $\mathbf{15}$ using repetition. Which expression should be appended?

10 / 17

After executing the following program, what is stored in the list?
$\mathbf{items = \lbrack\rbrack}$
$\mathbf{for\ i\ in\ range(1,5):}$
$\mathbf{items.append(i*2)}$

11 / 17

Which Python construct is primarily responsible for implementing repetition while translating an algorithm into code?

12 / 17

A student forgets to initialize an empty list before using append(). What is the most likely result?

13 / 17

A loop executes six times, appending the values of $\mathbf{i}$. How many elements will be present in the list after completion?

14 / 17

Which code correctly stores the numbers from $\mathbf{10}$ to $\mathbf{14}$ in a list?

15 / 17

Why is a variable commonly used inside a repetition structure when populating a list?

16 / 17

Which algorithm is best represented by the following Python code?
$\mathbf{numbers = \lbrack\rbrack}$
$\mathbf{for\ i\ in\ range(5):}$
$\mathbf{numbers.append(i*i)}$

17 / 17

A programmer needs to store the first ten positive integers in a list. Which loop is most appropriate?

Your score is

0%