22
QuizMultiple Choice

Resources for Programmers — Unit test

Question 22 • Introduction to Information Technology - EL3701

A sequence index uses a built-in function called length or len() to provide a total number of elements in an ordered list. With which iteration does this function work?

Answer
A
a for loop
B
a while loop
C
an infinite loop
D
a single statement loop

Explanation

The len() function returns the number of elements in a sequence, which can be used to determine how many times to repeat an iteration. A for loop can iterate over the sequence or use its length to set the number of repetitions. The correct choice is “a for loop.”

AI-written and checked against the verified answer.

Previous
Next