Knowledge Management Final

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

What should the question mark (?) in the following for statement be replaced with, so that the statements will calculate 5!: In [1]: factorial = 1 In [2]: for number in range(5, 0, ?): ...: factorial *= number ...: In [3]: factorial Out[3]: 120 1 0 -1 None of the above

-1

Which of the following would be accepted by a program strictly looking for four integers of data in CSV format? 100, 85 77,9 100,85,,77,9 '100,85,77,9'=' 100,85, 77,9

100,85, 77,9

The following creates an array from a _________-row-by-_________-column list: np.array([[1, 2, 3], [4, 5, 6]])

2, 3

By default, the re module's sub function replaces only the first occurrence of a pattern with the replacement text you specify. The statement re.sub(r'\t', ', ', '1\t2\t3\t4') True False

False

By default, the re module's sub function replaces only the first occurrence of a pattern with the replacement text you specify. The statement re.sub(r'\t', ', ', '1\t2\t3\t4') returns '1, 2\t3\t4' True False

False

The following code creates a Series of student grades from a list of integers: import pandas as pdgrades = pd.Series([87, 100, 94]) By default, a Series has integer indexes numbered sequentially from 1, and the Series argument may be a tuple, a dictionary, an array, another Series or a single value. True False

False

The following code creates a dictionary with the country-name keys 'Finland', 'South Africa' and 'Nepal' and their corresponding Internet country code values 'fi', 'za' and 'np': country_codes = {'Finland', 'fi', 'South Africa', 'za', 'Nepal', 'np'} True False

False

The following code creates a list, then uses del to remove its first element: numbers = list(range(0, 10))del numbers[1] True False

False

The following code formats the float value 17.489 rounded to the hundredths position: '{:.3f}'.format(17.489) True False

False

The following code replaces tab characters with commas: values = '1\t2\t3\t4\t5'values.replace('\t', ', ') True False

False

What is the output of the following code: In[1]: {1, 2, 4, 8, 16} <= {1, 4, 16, 64, 256}

False

Two sets are disjoint if they do not have any common elements. You can determine this with the set type's isdisjoint method. What values are actually displayed for ??? in Out[1] and Out[2]: In [1]: {1, 3, 5}.isdisjoint({4, 6, 1})Out[1]: ??? In [2]: {1, 3, 5}.isdisjoint({2, 4, 6})Out[2]: ??? False, False False, True True, False True, True

False, True

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.

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? NumPy always drops the middle rows and middle columns from the output. NumPy always drops the middle rows from the output. NumPy always drops the middle columns from the output. NumPy drops the middle rows, middle columns or both from the output

NumPy drops the middle rows, middle columns or both from the output.

In the following interactive session that compares the strings 'Orange' and 'orange': In [1]: 'Orange' == 'orange' Out[1]: False In [2]: 'Orange' != 'orange' Out[2]: ??? In [3]: 'Orange' < 'orange' Out[3]: True In [4]: 'Orange' <= 'orange' Out[4]: True In [5]: 'Orange' > 'orange' Out[5]: False In [6]: 'Orange' >= 'orange' Out[6]: ??? The outputs of snippets [2] and [6] (marked as ???) respectively are:

True, False

Two sets are disjoint if they do not have any common elements. You can determine this with the set type's isdisjoint method. What values are actually displayed for ??? in Out[1] and Out[2]: In [1]: {1, 3, 5}.isdisjoint({2, 4, 6}) Out[1]: ??? In [2]: {1, 3, 5}.isdisjoint({4, 6, 1}) Out[2]: ??? False, False False, True True, False True, True

True, False

Which of the following statements is false? Tuples are immutable. Tuples must store heterogeneous data. A tuple's length is its number of elements. A tuple's length cannot change during program execution.

Tuples must store heterogeneous data.

Consider a Series of hardware-related strings: hardware = pd.Series(['Hammer', 'Saw', 'Wrench']) To determine whether the value of each element contains a lowercase 'a' and returns a Series containing bool values indicating the true/false result for each element, replace the ??? with: hardware.str.???

contains('a')

The following lists contain names and the grade point average of that name respectively: names = ['Bob', 'Sue', 'Amanda'] grade_point_averages = [3.5, 4.0, 3.75] Write the zip call statement that produces the tuples ('Bob', 3.5), ('Sue', 4.0) and ('Amanda', 3.75)

for name, gpa in zip(names, grade_point_averages): print('({names},{gpa}')

Assuming the following array grades: grades = np.array([[87, 96, 70], [100, 87, 90], [94, 77, 90], [100, 81, 82]]) To select and return the second and fourth rows of the grades array, replace ??? with: In[1]: ???

grades [1 , 3]

Assuming the following array grades: grades = np.array([[87, 96, 70], [100, 87, 90], [94, 77, 90], [100, 81, 82]]) To select and see sequential first two rows of the grades array, replace ??? with: In[1]: ???

grades[0:2]

Lists may store ________ data, that is, data of many different types. parallel heterogeneous homogeneous None of the above.

heterogeneous

Lists may store ________ data, that is, data of many different types. parallel heterogeneous homogeneous None of the above.

heterogeneous

The following code implements a simple linear search. In [1]: def linear_search(data, search_key): ...: for index, value in enumerate(data):: ...: if value == search_key: ...: return ? ...: return -1 ...: ...: In the statement return ?, what should the ? be? data search_key index None of the above

index

List comprehensions can replace many for statements that iterate over existing sequences and create new lists, such as: list1 = [] for item in range(1, 6): Write the statement that can accomplish the same task in a single line of code with a list comprehension:

item for item in range(1, 6)

List comprehensions can replace many for statements that iterate over existing sequences and create new lists, such as: list1 = [] for item in range(1, 6): Write the statement that can accomplish the same task in a single line of code with a list comprehension:

list1 = [item for item in range(1, 6)]

The json _____ module's function reads the entire JSON contents of its file object argument and converts the JSON into a Python object. This is known as ____ the data. read, serializing load, serializing load, deserializing read, deserializing

load, deserializing

The json module's ______ function reads the entire JSON contents of its file object argument and converts the JSON into a Python object. This is known as _______ the data. read, serializing load, serializing load, deserializing read, deserializing

load, deserializing

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: dim, size, list ndim, shape, tuple dim, size, tuple ndim, shape, list

ndim, shape, tuple

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: dim, size, list ndim, shape, tuple dim, size, tuple ndim, shape, list

ndim, shape, tuple

Write the statement that creates a slice consisting of the elements at indices 2 through 6 of a numbers: numbers = [2, 3, 5, 7, 11, 13, 17, 19]

numbers[2:6]

If the contents of a file should not be modified, open the file for X—another example of the principle of least privilege. This prevents the program from accidentally modifying the file. writing only reading only reading and writing none of the above

reading only

If the contents of a file should not be modified, open the file for —another example of the principle of least privilege. This prevents the program from accidentally modifying the file. writing only reading only reading and writing none of the above

reading only

We use array method ________ to produce two-dimensional arrays from one-dimensional ranges. shape rectangularize reshape None of the above.

reshape

If numbers is a five-element integer array, numbers * 2 is equivalent to: numbers * [2, 2, 2, 2, 2] True False

True

Replace the ??? in the following comprehension statement to include in list4 only the even values produced by the for clause: list4 = [item for item in range(1, 11) if item ???]

% 2 == 0

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.

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.

Sets may contain only immutable objects, like strings, ints, floats and tuples that contain only immutable elements. True False

True

Assuming the following DataFrame grades: Wally Eva Sam Katie Bob Test1 87 100 94 100 83 Test2 96 87 77 81 65 Test3 70 90 90 82 85 Which of the following statements is false? One benefit of pandas is that you can quickly and conveniently look at your data in many different ways, including selecting portions of the data. The following expression selects 'Eva' column and returns it as a Series: grades['Eva'] If a DataFrame's column-name strings are valid Python identifiers, you can use them as attributes. The following code selects the 'Sam' column using the Sam attribute: grades.Sam All of the above statements are true.

All of the above statements are true.

Which of the following statement(s) will reverse the order of the below items list numbers: numbers = [2, 3, 4, 6, 7, 13, 17, 19] reversed_numbers = [item for item in reversed(numbers)] The following code concisely creates a new list in reverse order: numbers[::-1] To sort a list in descending order, call list method sort with the optional keyword argument reverse=True. numbers.sort(reverse=True) All of the above statements are true.

All of the above statements are true.

Which of the following statements about sorting unique items is false? Sorting data (i.e., placing the data in a particular order—ascending or descending—is one of the most important types of computing applications. An important item to understand about sorting unique values is that the end result—the sorted array—will be the same no matter which algorithm you use to sort the array. The choice of algorithm affects only the run time of the program. Selection sort and insertion sort—are relatively simple to program but inefficient. Merge sort—is much faster than selection sort and insertion sort but harder to program. All of the above statements are true.

An important item to understand about sorting unique values is that the end result—the sorted array—will be the same no matter which algorithm you use to sort the array. The choice of algorithm affects only the run time of the program.

Preparing data for analysis is called ____ or _____. data wrangling data munging Both (a) and (b). Neither (a) nor (b).

Both (a) and (b).

Consider the following code: In [1]: s1 = 'happy' In [2]: s2 = 'birthday' In [3]: s1 += ' ' + s2 In [4]: s1 Out[4]: 'happy birthday' In [5]: symbol = '>' In [6]: symbol *= 5 In [7]: symbol Out[7]: '>>>>>' Which snippet(s) in this interactive session appear to modify existing strings, but actually create new string objects? Only snippet [3]. Only snippet [5]. Both snippets [5] and [6]. Both snippets [3] and [6].

Both snippets [3] and [6].

Consider the following code: In [1]: s1 = 'happy' In [2]: s2 = 'birthday' In [3]: s1 += ' ' + s2 In [4]: s1 Out[4]: 'happy birthday' In [5]: symbol = '>' In [6]: symbol *= 5 In [7]: symbolOut[7]: '>>>>>' Which snippet(s) in this interactive session appear to modify existing strings, but actually create new string objects? Only snippet [3]. Only snippet [5]. Both snippets [5] and [6]. Both snippets [3] and [6].

Both snippets [3] and [6].

Which of the following statements is false? DataFrames have a describe method that calculates basic descriptive statistics for the data and returns them as two-dimensional array. In a DataFrame, the statistics are calculated by column. Method describe nicely demonstrates the power of array-oriented programming with a functional-style call—Pandas handles internally all the details of calculating these statistics for each column. You can control the precision of floating-point values and other default settings with pandas' set_option function.

DataFrames have a describe method that calculates basic descriptive statistics for the data and returns them as two-dimensional array.

Which of the following statements is false? For big data applications, you'll also want to choose algorithms that are easy to sequentialize—that will enable you to put lots of processors to work simultaneously. The simplest and most apparent algorithms often perform poorly—developing more sophisticated algorithms can lead to superior performance. All of the above statements are true. None of the above statements are true.

For big data applications, you'll also want to choose algorithms that are easy to sequentialize—that will enable you to put lots of processors to work simultaneously.

Which of the following statements is false? String method split with no arguments tokenizes a string by breaking it into substrings at each whitespace character, then returns a list of tokens. To tokenize a string at a custom delimiter (such as each comma-and-space pair), specify the delimiter string (such as, ', ') that split uses to tokenize the string, as in: letters = 'A, B, C, D'letters.split(', ') If you provide an integer as split's second argument, it specifies the maximum number of splits. The last token is the remainder of the string after the maximum number of splits. Assuming the string in Part (b), the code letters.split(', ', 1) returns ['A', 'B', 'C, D']

If you provide an integer as split's second argument, it specifies the maximum number of splits. The last token is the remainder of the string after the maximum number of splits. Assuming the string in Part (b), the code letters.split(', ', 1) returns ['A', 'B', 'C, D']

Which of the following statements is false? String method split with no arguments tokenizes a string by breaking it into substrings at each whitespace character, then returns a list of tokens. To tokenize a string at a custom delimiter (such as each comma-and-space pair), specify the delimiter string (such as, ', ') that split uses to tokenize the string, as in: letters = 'A, B, C, D'letters.split(', ') If you provide an integer as split's second argument, it specifies the maximum number of splits. The last token is the remainder of the string after the maximum number of splits. Assuming the string in Part (b), the code letters.split(', ', 1) returns ['A', 'B', 'C, D'] There is also an rsplit method that performs the same task as split but processes the maximum number of splits from the end of the string toward the beginning.

If you provide an integer as split's second argument, it specifies the maximum number of splits. The last token is the remainder of the string after the maximum number of splits. Assuming the string in Part (b), the code letters.split(', ', 1) returns ['A', 'B', 'C, D']

Which of the following statements are false? JSON (JavaScript Object Notation) is a data-interchange format readable only by computers and used to represent objects (such as dictionaries, lists and more) as collections of name-value pairs. Many libraries you'll use to interact with cloud-based services such as Twitter, IBM Watson and others communicate with your applications via JSON objects. JSON can represent objects of custom classes. JSON has become the preferred data format for transmitting objects across platforms. This is especially true for invoking cloud-based web services, which are functions and methods that you call over the Internet.

JSON (JavaScript Object Notation) is a data-interchange format readable only by computers and used to represent objects (such as dictionaries, lists and more) as collections of name-value pairs.

Which of the following statements is false? NumPy arrays use only zero-based integer indexes. Like arrays, Series use only zero-based integer indexes. Series may have missing data, and many Series operations ignore missing data by default. All of the above statements are true.

Like arrays, Series use only zero-based integer indexes.

Which of the following statements is false? Pandas is the most popular library for dealing with mixed data types, customized indexing, missing data, and data that needs to be manipulated into forms appropriate for the databases and data analysis packages. Data science presents unique demands for which more customized data structures are required. NumPy's array is optimized for heterogeneous numeric data that's accessed via integer indices. Pandas provides two key collections—Series for one-dimensional collections and DataFrames for two-dimensional collections.

NumPy's array is optimized for heterogeneous numeric data that's accessed via integer indices.

The following statements replaced the results of the four list comparisons below with blank. What are those output values for Out [4], Out [5], Out[6] and Out[7]. Type your answers for each output respectively. In [1]: a = [1, 2, 3] In [2]: b = [1, 2, 3] In [3]: c = [1, 2, 3, 4] In [4]: a == b Out[4]: In [5]: a == c Out[5]: In [6]: a < c Out[6]: In [7]: c >= b Out[7]:

Out[4]: True Out[5]: False Out[6]: True Out[7]: True

Which of the following statements is false? As in lists and arrays, the first character in a text file and byte in a binary file is located at position 0, so in a file of n characters or bytes, the highest position number is n - 1. Python views text files and binary files (for images, videos and more) as sequences of bytes. For each file you open, Python creates a file object that you'll use to interact with the file. All of the above statements are true.

Python views text files and binary files (for images, videos and more) as sequences of bytes.

The array methods sum, min, max, mean, std (standard deviation) and var (variance) are each functional-style programming reductions. True False

True

Which of the following statements is false? You can determine the number of items in a set with the built-in len function. Sets are not iterable, so you cannot process each set element with a for loop. You can check whether a set contains a particular value using the in and not in operators. Sets are unordered, so there's no significance to the iteration order.

Sets are not iterable, so you cannot process each set element with a for loop.

Consider this text from Shakespeare: soliloquy = 'To be or not to be, that is the question' Which of the following statements is false? String method index searches for a substring within a string and returns the first index at which the substring is found; otherwise, a ValueError occurs. The following code returns 3: soliloquy.index('be') String method rindex performs the same operation as index, but searches from the end of the string and returns the last index at which the substring is found; otherwise, a Value-Error occurs. The following code returns 3: soliloquy.rindex('be') String methods find and rfind perform the same tasks as index and rindex but, if the substring is not found, return -1 rather than causing a Value-Error. All of the above statements are true.

String method rindex performs the same operation as index, but searches from the end of the string and returns the last index at which the substring is found; otherwise, a Value-Error occurs. The following code returns 3: soliloquy.rindex('be')

Which of the following statements is false? The d presentation type in the following f-string formats strings as integer values: f'{10:d}' The integer presentation types b, o and x or X format integers using the binary, octal or hexadecimal number systems, respectively. The c presentation type in the following f-string formats an integer character code as the corresponding character: f'{65:c} {97:c}' If you do not specify a presentation type, as in the second placeholder below, non-string values like the integer 7 are converted to strings: f'{"hello":s} {7}'

The d presentation type in the following f-string formats strings as integer values: f'{10:d}'

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: True False

True

Which of the following statements about DataFrames is false? The index can be a slice. In the following slice containing, the range specified includes the high index ('Test3'): grades.loc['Test1':'Test3'] When using slices containing integer indices with iloc, the range you specify excludes the high index (2): grades.iloc[0:2] To select specific rows, use a tuple rather than slice notation with loc or iloc. All of the above statements are true.

To select specific rows, use a tuple rather than slice notation with loc or iloc.

A dictionary is an unordered collection which stores key-value pairs that map immutable keys to values, just as a conventional dictionary maps words to definitions. True False

True

Assuming the following DataFrame grades: Wally Eva Sam Katie Bob Test1 87 100 94 100 83 Test2 96 87 77 81 65 Test3 70 90 90 82 85 To see the average of all the students' grades on each test, call mean on the T attribute: grades.T.mean() True False

True

Assuming the following DataFrame grades: Wally Eva Sam Katie Bob Test1 87 100 94 100 83 Test2 96 87 77 81 65 Test3 70 90 90 82 85 rather than getting the summary statistics by student, you can get them by test. Simply call describe on grades.T, as in: grades.T.describe()

True

Assuming the following DataFrame grades: Wally Eva Sam Katie Bob Test1 87 100 94 100 83 Test2 96 87 77 81 65 Test3 70 90 90 82 85 rather than getting the summary statistics by student, you can get them by test. Simply call describe on grades.T, as in: grades.T.describe() True False

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]] True False

True

Based on the string sentence = '\t \n This is a test string. \t\t \n' The following code snippets first use method lstrip to remove only leading whitespace from sentence: sentence.lstrip() then use method rstrip to remove only trailing whitespace: sentence.rstrip() True False

True

Consider a Series of hardware-related strings: hardware = pd.Series(['Hammer', 'Saw', 'Wrench']) The following code calls string method contains on each element to determine whether the value of each element contains a lowercase 'a': hardware.str.contains('a') and returns a Series containing bool values indicating the contains method's result for each element. True False

True

Consider a Series of hardware-related strings: hardware = pd.Series(['Hammer', 'Saw', 'Wrench']) The following code uses the Series str attribute to invoke string method upper on every Series element, producing a new Series containing the uppercase versions of each element in hardware: hardware.str.upper() True False

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 True False

True

The following IPython session loads and displays the CSV file accounts.csv: In [1]: import pandas as pd In [2]: df = pd.read_csv('accounts.csv', ...: names=['account', 'name', 'balance'])...: In [3]: df Out[3]: account name balance 0 100 Jones 24.98 1 200 Doe 345.67 2 300 White 0.00 3 400 Stone -42.16 4 500 Rich 224.62 The names keyword argument specifies the DataFrame's column names. If you do not supply the names keyword argument, read_csv assumes that the CSV file's first row is a comma-delimited list of column names. True False

True

The following IPython session loads and displays the CSV file accounts.csv: In [1]: import pandas as pd In [2]: df = pd.read_csv('accounts.csv', ...: names=['account', 'name', 'balance'])...: In [3]: df Out[3]: account name balance 0 100 Jones 24.98 1 200 Doe 345.67 2 300 White 0.00 3 400 Stone -42.16 4 500 Rich 224.62 The names keyword argument specifies the DataFrame's column names. If you do not supply the names keyword argument, read_csv assumes that the CSV file's first row is a comma-delimited list of column names. True False

True

The following code creates a list, then uses del to remove its first element: numbers = list(range(0, 10))del numbers[0] True False

True

The following code creates an accounts.txt file and write five client records to the file. Generally, records in text files are stored one per line, so we end each record with a newline character: with open('accounts.txt', mode='w') as accounts: accounts.write('100 Jones 24.98\n') accounts.write('200 Doe 345.67\n') accounts.write('300 White 0.00\n') accounts.write('400 Stone -42.16\n') accounts.write('500 Rich 224.62\n') You can also write to a file with print (which automatically outputs a \n), as in print('100 Jones 24.98', file=accounts) True False

True

The following code creates the dictionary roman_numerals, which maps roman numerals to their integer equivalents (the value for 'X' is intentionally wrong): roman_numerals = {'I': 1, 'II': 2, 'III': 3, 'V': 5, 'X': 100} Replacing the value associated with the key 'X' with a new value 10, can be done by the following statement: In [1]: roman_numerals['X'] = 10 True False

True

The following code, which has a dictionary with unique values, reverses the key-value pairs: months = {'January': 1, 'February': 2, 'March': 3} months2 = {number: name for name, number in months.items()} True False

True

The following code, which has a dictionary with unique values, reverses the key-value pairs: months = {'January': 1, 'February': 2, 'March': 3}months2 = {number: name for name, number in months.items()} True False

True

The following update call receives a dictionary key-value pair to insert or update: country_codes.update({'Australia': 'ar'}) Provided an incorrect country code for Australia. The following code corrects this by using a keyword argument to update the value associated with 'Australia': country_codes.update(Australia='au') True False

True

The names keyword argument specifies the DataFrame's column names. If you do not supply the names keyword argument, read_csv assumes that the CSV file's first row is a comma-delimited list of column names. True False

True

When you call describe on a DataFrame containing both numeric and non-numeric columns, describe calculates the statistics below only for the numeric columns. True False

True

ssuming the following DataFrame grades: To see the average of all the students' grades on each test, call mean on the T attribute: grades.T.mean() True False

True

Which of the following statements is false? Searching data involves determining whether a value (referred to as the search key) is present in the data and, if so, finding its location. Two popular search algorithms are the simple binary search and the faster but more complex linear search. Sorting places data in ascending or descending order, based on one or more sort keys. Each of the above statements is true.

Two popular search algorithms are the simple binary search and the faster but more complex linear search.

Which of the following statements is false? Variables, lists, tuples, dictionaries, sets, arrays, pandas Series and pandas DataFrames offer long-term data storage. Computers store files on secondary storage devices, including solid-state drives, hard disks and more. Some popular text file formats are plain text, JSON (JavaScript Object Notation) and CSV (comma-separated values). All of the above statements are true.

Variables, lists, tuples, dictionaries, sets, arrays, pandas Series and pandas DataFrames offer long-term data storage.

Assuming the following DataFrame grades: Wally Eva Sam Katie Bob Test1 87 100 94 100 83 Test2 96 87 77 81 65 Test3 70 90 90 82 85 To slice DataFrame grades to include the range 'Test1' and 'Test2', replace the ??? with: In [1]: grades.iloc ???

[0:2]

Assuming the following DataFrame grades: Wally Eva Sam Katie Bob Test1 87 100 94 100 83 Test2 96 87 77 81 65 Test3 70 90 90 82 85 To slice DataFrame grades to include the range 'Test2' and 'Test3', replace the ??? with: In [1]: grades.loc ???

[['Test2', 'Test3']]

Consider the list color_names: color_names = ['orange', 'yellow', 'green'] Write the statement that uses the insert method to insert 'red' at index 0.

color_names.insert(0, 'red')

hich of the following would be displayed for ??? by Out[3]? In [1]: numbers = list(range(10)) + list(range(5)) In [2]: numbers Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4] In [3]: set(numbers) Out[3]: ??? [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}

{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

Which of the following would be displayed where we wrote ??? by Out[3]? In [1]: numbers = list(range(3)) + list(range(5)) In [2]: numbers Out[2]: [0, 1, 2, 0, 1, 2, 3, 4] In [3]: set(numbers) Out[3]: ???

{0, 1, 2, 3, 4}

What is the output of the following: In[1]: {1, 2, 4, 8, 16} & {1, 4, 16, 64, 256}

{1, 4, 16}

What is the output of the following code: In[1]: {1, 2, 4, 8, 16} - {1, 4, 16, 64, 256}

{2, 8}


Conjuntos de estudio relacionados

FIN 357 Chapter 8: Stock Valuation

View Set

Psych Chap 8: States of Consciousness

View Set