final exam

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which XXX would generate the following plot? import matplotlib.pyplot as plt xx = [1,2,3,4] yy = [5,1,4,2] XXX

a. plt.plot(xx, yy, 'r-')

85) What is the output for the following code? import numpy as np arr = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]]) print(arr.shape)

a. (3,4)

How many times is the recursive function find() called when searching for the missing letter 'A' in the below code? def find(lst, item, low, high): range_size = (high-low) + 1 mid = (high + low) // 2 if item == lst[mid]: pos = mid elif range_size == 1: pos =- 1 else: if item < lst[mid]: pos = find(lst, item, low, mid) else: pos = find(lst, item, mid+1, high) return pos listOfLetters = ['B', 'C', 'D', 'E', 'F', 'G', 'H'] print(find(listOfLetters, 'A', 0, 6))

a. 4

92) Which best describes the package pandas?

a. Allows the creation of data visualizations

68) What does np.ones((3, 2))create?

c. [[1. 1.] [1. 1.] [1. 1.]]

66) Which package provides tools for scientific and mathematical computations in Python?

b. numpy

What is the output for the following code? import numpy as np A = np.array([[1,2,3],[4,5,6],[7,8,9]]) B = np.array([[4,5,6],[3,2,1],[1,0,0]]) print(A*B)

c. [[ 4 10 18] [12 10 6] [ 7 0 0]]

70) Identify the code used for matrix multiplication of two arrays.

c. np.malmul(array1, array2)

113) The graph below shows a scatter plot with 5 clusters for mall customers based on income and spending score. What is the most likely centroid for the gold-colored cluster?

c. (55.3, 49.5)

If k= 4, how would k-nearest neighbors classify point A?

c. The classes are tied

84)The DataFrame dat is defined as:

d. dat[dat['Age']<=22][['Name','State']]

109) The following dataset is called sample_cars. What Python code could be used to create a dataset of the same name that only includes the features that are numerical?

d. sample_cars = sample_cars.drop(['Name', 'Drive','Class'],axis=1)

A derived class may define a method having the same name as the base class means that:

a derived class method overrides the method of the base class.

If k= 4, how would k-nearest neighbors classify point A?

a. Blue diamond

87) What is the output for the following code? import numpy as np arr = np.array([[1,2,3],[4,5,6],[7,8,9]]) print(np.ravel(arr))

a. [1 2 3 4 5 6 7 8 9]

Which XXX would generate the following plot? import matplotlib.py plot as plt xx = [1,2,3,4] yy = [5,1,4,2] XXX plt.scatter(x = xx, y = yy)

a. plt.figure(figsize=[2,4])

Which XXX would generate the following plot? import matplotlib.pyplot as plt XXX

a. plt.grid(color='b', linestyle='--')

82) The DataFrame dat is defined as:

b. dat.iloc[1:3,0:2]

83) The DataFrame dat is defined as:

b. dat[dat['Age']<21]

Which code would create the following dataframe?

b. import pandas as pd pd.DataFrame(data = [['Riley', 19, 'Dubuque', 'IA'], ['Lex', 25, 'Riverside', 'CA'], ['Mel', 20, 'Hoboken', 'NJ'], ['Lynn', 22, 'Austin', 'TX']], labels = ['Name', 'Age', 'City', 'State'], index = 0:3 )

Complete the code to generate the following output. Inside the child class class ParentClass: def action(self): print('Method is not overridden') class ChildClass(ParentClass): def action(self): print('Inside the child class') if __name__ == '__main__': XXX

b. r = ChildClass() r.action()

102) Which of the following is a classification model?

d. Predict the type of drink a shopper prefers based on their shopping history.

91) Which code loads the function read_csv from the package pandas?

from pandas import read_csv

Which code would create the following dataframe?

import pandas as pd pd.DataFrame(data = [['Riley', 19, 'Dubuque', 'IA'], ['Lex', 25, 'Riverside', 'CA'], ['Mel', 20, 'Hoboken', 'NJ'], ['Lynn', 22, 'Austin', 'TX']], columns = ['Name', 'Age', 'City', 'State'], index = None )

114) What code initializes a k-means clustering model with 4 clusters?

kModel = KMeans(n_clusters=4)


Kaugnay na mga set ng pag-aaral

CompTIA A+ Troubleshooting Methodology and Resolving Core Hardware Problems II

View Set

Chapter 19---The menstrual cycle

View Set

Unit 6: Palliative Online Courses

View Set

B.2.1 CompTIA A+ 220-1101 (Core 1) Domain 1: Mobile Devices

View Set