Python Basics
Python
Libraries & More
Code Tracing
More MCQs
100

For the declaration myString = 'Python is fun', what is myString[7]?

i

100

What will happen if we run this snippet of code?

Error - missing colon (:) at the end of if statement. 

100

From the following contingency table, what percent of people define the range of those who have a MS degree and make $50K?

9.7 %

100

Given the following code listing, what would be a possible output?


{False, True, 2, 'one'}

100

What is the shape of this matrix?

 

(3,2) 

3 rows and 2 columns 

200

What is output by len(myString) 

myString = 'Machine Learning' ?

16

200

If myList = [0,1,2,3,4,5,6], how many times does the code execute under the following statment:

for element in myList:

for loop runs once for each element of the list

200

Which of the following performs 'standard' matrix multiply?  Assume numpy has been imported as np.  Check all that apply...

a. '@'

b. 'np.multiply'

c. '*'

d. 'np.dot'

e. None of these 

a. '@'

d. 'np.dot' 

200

Given the following code, what would be printed by: print(myList2[1][3])?

5

200

Compute the mean and median of the following data set: 6, 5, 7, 2, 6, 5, 6, 8, 1 

Mean 5.11

Median 6

300


No Output 

(if = false --> Everything inside the if block is skipped) 

300

Given the following code dictionary assignment, how would you change the price of 'Windbreaker' to $50.99?

coatPrice['Windbreaker'] = 50.99

300

Which of the following is a function that can be used to find missing/empty data in a Pandas data frame?

a. isNone()

b. isNan()

c. is missing()

d. isNull()

d. isNull()

300

Given the following code what would be printed by: print(station_1(3,3)) ?

's' 

(12<10 ) --> False skip the return 

300

What is the shape and size of the resultant matrix if multiplying two matrices of shapes 

   (2, 3) and (3, 4)?

Shape: (2,4) Size: 8 

400

What does the following code print out?

0 thru 9 on successive lines

0 thru 9 one per line 

400

Given the following code listing, what does line 35 do?

Checks if the number in 2D list is even. 

400

What is the output from the following dot product operation?

[[5, 12], [-11, 7]]

400

What is printed in the last line of the output for the following code?

5,9 

400

Identify which are outliers in this set of data:  

 6, 5, 7, 2, 6, 5, 6, 8, 9, 12, 10, 20, 22, 35, 7, 2, 13, 15, 4, 10.

Range -4 thru 22.0 

35 is outside the range 

500

Given the following code listing, what is the output when line 11 is executed?

Print 3: deque(['hello', 'python'])

500

What is printed from the following code listing for line 6?

7, nine

500

What matplotlib pyplot function can be used to set the range of values on the x and y axes?

xlim(), ylim()

500

Given the following code listing, what is the output when line 43 is executed?

[[11, 0, 5, 0, 1], [15, 0, 0, 7, 3], [0, 0, 0, 5, 13], [0, 15, 0, 0, 0]]

500

Compute the standard deviation of the sample data set: 6, 5, 7, 2, 6, 8 (i.e. compute the sample standard deviation).

s=4.27≈2.07

M
e
n
u