Questions and Correct Answers | Graded A+ |
Verified Answers | Brand New Version!
Which of the following statements is false?
-You can delete a key-value pair from a dictionary with the del statement
-You can remove a key-value pair with the dictionary method pop, which returns
the value for the removed key.
-Method clean deletes the dictionary's key-value pairs:
-Operators in and not in can determine whether a dictionary contains a specified
key. ---------CORRECT ANSWER-----------------Method clean deletes the dictionary's
key-value pairs:
Which of the following statements is true with respect to displaying an array of
1000 items or more? ---------CORRECT ANSWER-----------------NumPy drops the
middle rows, middle columns or both from the output.
If numbers is a five-element integer array, numbers * 2 is equivalent to:
numbers * [2, 2, 2, 2, 2] ---------CORRECT ANSWER-----------------True
Element-wise operations are applied to every array element, so given an integer
array named numbers, the expression
numbers * 2
,multiplies every element by 2, and the expression
numbers ** 3
cubes every element. ---------CORRECT ANSWER-----------------True
For a two-dimensional array grades in which each row represents one student's
grades on several exams, we can calculate each student's average grade with:
grades.mean(axis=1) ---------CORRECT ANSWER-----------------True
The array methods sum, min, max, mean, std (standard deviation) and var
(variance) are each functional-style programming reductions. ---------CORRECT
ANSWER-----------------True
Assuming the following array grades:
grades = np.array([[87, 96, 70], [100, 87, 90], [94, 77, 90], [100, 81, 82]])
To select multiple sequential rows, use slice notation, as in
grades[0:2]
and to select multiple non-sequential rows, use a list of row indices, as in
grades[[1, 3]] ---------CORRECT ANSWER-----------------True
We use array method ________ to produce two-dimensional arrays from one-
dimensional ranges. ---------CORRECT ANSWER-----------------reshape
,The following creates an array from a _________-row-by-_________-column list:
np.array([[1, 2, 3], [4, 5, 6]]) ---------CORRECT ANSWER-----------------two three
Assume the following array definitions:
import numpy as npintegers = np.array([[1, 2, 3], [4, 5, 6]])floats = np.array([0.0,
0.1, 0.2, 0.3, 0.4])
The attribute contains an array's number of dimensions and the attribute contains
a specifying an array's dimensions: ---------CORRECT ANSWER-----------------ndim,
shape, tuple
Which of the following statements is false?
-You can create an array from a range of elements, then use array method
reshape to transform the one-dimensional array into a multidimensional array.
-The following code creates an array containing the values from 1 through 20,
then reshapes it into four rows by five columns:
np.arange(1, 21).reshape(4, 5)
-A 24-element one-dimensional array can be reshaped into a 2-by-12, 8-by-3 or 4-
by-8 array, and vice versa.
-All of the above are true. ---------CORRECT ANSWER-----------------All of the above
are true.
, The following session calls the string object s's object's lower and upper methods,
which produce new strings containing all-lowercase and all-uppercase versions of
the original string, leaving s unchanged:
In [1]: s = 'Hello'In [2]: s.lower() # call lower method on string object sOut[2]:
'hello'In [3]: s.upper()Out[3]: 'HELLO'
After the preceding session, s contains 'HELLO'. ---------CORRECT ANSWER-----------
------False
The following code produces different values are likely to be displayed each time
you run the code:
import randomfor roll in range(10):print(random.randrange(1, 6), end=' ') ---------
CORRECT ANSWER-----------------True
Based on the following function definition that can receive an arbitrary number of
arguments:
In [1]: def average(*args):...: return sum(args) / len(args)...:
which of the following statements is false? ---------CORRECT ANSWER-----------------
All of the above are true.
The value of the expression of:
In [1]: floor(-3.14159) ---------CORRECT ANSWER------------------4.0
Which of the following statements is false?