How can we filter out numbers less than 2 in a number sequence to find prime numbers?(1 point)

Responses

Our code needs to throw an error if numbers less than 2 are given.
Our code needs to throw an error if numbers less than 2 are given.

We can have a conditional check to filter out numbers less than 2.
We can have a conditional check to filter out numbers less than 2.

We can have a predefined list of all prime numbers and check if the given number is inside that list.
We can have a predefined list of all prime numbers and check if the given number is inside that list.

We can test numbers less than 2 by checking if it is divisible by 2.

7 answers

To filter out numbers less than 2 in a number sequence to find prime numbers, the best approach is:

We can have a conditional check to filter out numbers less than 2.

Numbers less than 2 (i.e., 0 and 1) are not prime, so a simple conditional check will allow us to exclude them from our sequence when determining prime numbers.

Consider a list [a, b, c, d]. Which element exists at index 4?(1 point)
Responses

the element a
the element a

the element d
the element d

the element b
the element b

There exists no element at index 4

The correct response is:

There exists no element at index 4.

In a list with 4 elements, the indices are 0, 1, 2, and 3. Therefore, index 4 is out of bounds for this list.

Which of the following is the method of list traversal?(1 point)
Responses

if-else condition
if-else condition

if condition
if condition

for loop
for loop

if-else if-else condition

The correct response is:

for loop

A "for loop" is commonly used for list traversal, allowing you to iterate through each element of the list.

Which of the following data structures consists of a root node from which all the other elements can be accessed?(1 point)
Responses

tree
tree

stack
stack

map
map

queue

The correct response is:

tree

A tree data structure consists of a root node, from which all other nodes (elements) can be accessed.