Python Week 7

¡Supera tus tareas y exámenes ahora con Quizwiz!

What list of prime values is produced if the prime_sieve program is executed with an input value of 20?

2 3 5 7 11 13 17 19

How many comparisons are necessary to find the value 43 in the following list using a binary search? 13 25 28 30 39 43 44 58 66 70 78 81 86 88 95

3

How many comparisons are necessary to find the value 86 in the following list using a binary search? 13 25 28 30 39 43 44 58 66 70 78 81 86 88 95

4

How many elements can be stored in a two-dimensional list with 5 rows and 10 columns?

50

Why is the input data for the standard_deviation program stored in a list?

Because the data needs to be processed more than once.

Which of the following operations cannot be performed on tuples?

Element removal

A binary search only works if the number of elements to search is odd.

False

A binary search works best on an unsorted list of values.

False

Functions of the math module are used to compute the mean of the data values in the standard_deviation program.

False

If a == b is true, then a is b will also be true.

False

The maximum number of dimensions a Python list can have is 3.

False

The primary difference between lists and tuples is that lists are immutable and tuples are not.

False

The prime_sieve program uses a list of integers and sets the value to 0 when a number is determined not to be prime.

False

The results computed by the standard_deviation program are written out to text data file.

False

The smallest index of any dimension of a two-dimensional list is 1.

False

The standard_deviation program would not work if there were twice as many values in the data file.

False

To be sure it has found all possible prime numbers up to a certain number N, the prime_sieve program repeats the sieve algorithm for all values up to N.

False

A example of a ragged list is a two-dimensional list where each row has a different number of columns.

True

A two-dimensional list is really a one-dimensional list of one-dimensional lists.

True

A two-dimensional list is suitable for storing tabular data.

True

If a is b is true, then a == b will also be true.

True

The Greek mathematician Eratosthenes came up with the idea of using a sieve algorithm to find prime numbers.

True

The in and is operators both produce boolean results.

True

The in operator can be used to check the contents of a character string or a list.

True

The maximum indexes of a two-dimensional list with 6 rows and 10 columns are 5 and 9, respectively.

True

The valid indexes of a tuple run from 0 through one less than the length of the tuple.

True

You can use the is operator to check if a variable contains a certain type of data. True

True

Which of the following is NOT a good reason to use a tuple rather than a list?

Tuples can hold more elements than lists.

Which of the following methods can be called on a tuple?

index

When performing a binary search, how many comparisons are required to find a value in a list of N values, in the worst case?

log2N + 1


Conjuntos de estudio relacionados

The Princess Bride Memorable Quotes

View Set

ap bio quiz 5.3 mendelian genetics

View Set

Part 4- Client Investment Recommendations and Strategies

View Set

Econ 331: Money and Banking Test 2 (Chapters 9,12,14,15,16)

View Set

Domestic and Intl. Banking Chp 11

View Set