Final Exam CIS 315
True
A dictionary is an unordered collection which stores key-values pairs that map immutable keys to values, just as a conventional dictionary maps words to definitions.
False
A dictionary's keys must be mutable(such as strings,numbers or tuples) and unique (that is, no duplicates).
False
Arithmetic between arrays of integers and floating-point numbers results in an array of integers.
The following code uses teh multiply universal function to multiply every element of numbers by the scalar value: np.multiply(numbers, 5)
Assume the array numbers contain the values 10, 20, 30, 40, 50, 60. Which of the following statements is false?
All of these statements are true.
Assuming the following grades: Grades = np.array([[87, 96, 70], [100,87,90], [94,77,90], [100,81,82]]) Which of the following statements is false?
True
Characters (digits,letters and symbols such as $,@,% and *) are the fundamental building blocks of programs. Every program is composed of characters that, when grouped meaningfully, represent instructions and data that the interpreter uses to perform tasks.
Both snippets [3] and [6]
Conisder the following code: Which snippet(s) in this interactive session appear to modify existing strings, but actually create new string objects?
True
For the e presentation type in [3] of part(c), the formatted value 1.000e+25 is equivalent to 1.0000 x 1025. If you prefer a capital E for the exponent, use the E presentation type rather than e.
False
Formatting is type dependent-if you try to use .2f to format a string like 'hello', a NameError occurs.
Numbers * [2, 2, 2, 2, 2]
If numbers is a five-element integer array, numbers * 2 is equivalent to:
True
If you wish to include a backslash in a string, you ordinarily must use two back-slash characters //.
True
Interpreters like IPython tokenize statements, breaking them into individual components such as keywords, identifiers, operators and other elements of a programming language.
True
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.
False
JSON objects are similar to Python lists. Each JSON object contains a comma-separated list of property names and values, in curly braces. For example, the following JSON object might represent a lenient record: {"account":100, "name":"Jones","balance":24.98}
False
Method clean deltes the dictionary's key-value pairs:
True
Method update can covert keyword arguments into key-value pairs to insert-the following call converts the parameter name 'Australia' and associates the incorrect value 'ar' with that key: country_codes.update(Australia='ar')
view
Objects that "see" the data in other objects, rather than having their own copies of the data are called ____ objects.
False
Python has separate string and character types.
False
Python views text files and binary files (for images, videos and more) as a sequences of bytes.
False
Sets are iterable, so theu are sequences and they support indexing and slicing with square brackets, [].
True
Some popular text file formats are plain text, JSON (JavaScript Object Notation) and CSV (comma-separated values).
True
Sometimes you'll need to recongnize patterns in text, like phone numbers, e-mail addresses, ZIP Codes, web page addresses, Social Security numbers and more. A regular expression string describes a searhc pattern for matching characters in other strings.
False
String keys are case insensitive
True
String methods lower and upper can convert strings to all lowercase or all uppercase letters, respectively.
True
Strings support many of the same sequence operations as sets, lists and tuples.
True
The Numpy (Numerical Python) library is the preferred Python array implementation-it offers a high-performance, rrichly functional n-dimensional array type called ndarray, which you can refer to by its synonym, array
Ndim, shape, tuple
The attribute ____ contains an array's number of dimensions and the attribute ____ contains a ____ specifying an array's dimensions:
True
The file open modes for writing and appending raise a FileNotFoundError if the file does not exist.
True
The file open modes for writing and appening raise a FileNotFoundError if the file does not exist.
True
The finally clause is guaranteed to execute, regardless of whether its try suite executes successfully or an exception occurs.
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:
True
The following code creates the dictionary roamn_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}
True
The following code uses the random module's randrange function with a list comprehension to create a list of six million die rolls and time the operation using %timeit: Import random %timeit rolls_lsit = / [random.randrange(1,7) for i in range(0,600_000)]
Serializing
The json module enables you to convert objects o JSON (avaScript Object Notation) text format. This is known as ____ the data.
False
The python standard Library puckle module can serialize objects into the data formats of many popular programming languages.
False
Variables, lists, tuples, dictionaries, sets, arrays, pandas Series and pandas DataFrames offer long-term data storage.
Shallow
Views are also known as _____ copies.
reshape
We use array method _____ to produce two-dimensional arrays from one-dimensional ranges.
The expression word_counts[word] += 1 inserts a newkey-value pair in the dictionary.
Which of the following statements about the following code is false word_counts= {} For word in text.split(): If word in word_counts: Word_counts[word] += 1 Else: Word_counts[word] =1
All of these statements are true (fromat stringsm and reference keywords)
Which of the following statements is false?
Multiple keys in a dictionary can have the same value.
Which of the following statements is false?
NumPy drops the middle rows,middle columns or both from the output
Which of the following statements is true with respect to displaying an array of 1000 items or more?
{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(range10)) +list(range(5)) In[2]: numbers Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 1, 2, 3, 4] In [3]: set(numbers) Out[3]: ???
True
You should not modify a dictionary while iterating through a view. According to the Python Standard Library documentation, either you'll get a RuntimeError or the loop might not process all of the view's values.