answers5
When a program needs to save data for later use, it writes the data in a(n) _______________. -
ANSWERS-file
A(n) _______________ is an object that holds multiple unique items of data in an unordered
manner. - ANSWERS-set
The built-in function _______________ returns the length of a sequence. - ANSWERS-len()
A(n) _______________ is a span of items that are taken from a sequence. - ANSWERS-slice
The third number in string slicing brackets or in the range() function represents the
_______________ value. - ANSWERS-step or increment
Assume namesList contains a list of names (as strings). Write a for-loop that walks over the list
and prints out all the names. - ANSWERS-for n in namesList:
print(n)
What are the valid indexes for the string 'New York'?
a. 0 through 7
b. 0 through 8
c. -1 through -8
d. -1 through 6 - ANSWERS-0 through 7
, What statement can be used to handle some of the run-time errors in a program?
a. exception statement
b. try statement
c. try/except statement
d. exception handler statement - ANSWERS-try/except statement
Which method would you use to returns all the elements in the dictionary as a list of tuples?
a. list
b. items
c. pop
d. keys - ANSWERS-items
Which step creates a connection between a file and a program?
a. Open the file.
b. Read the file.
c. Process the file.
d. Close the file. - ANSWERS-open the file
What will be assigned to s_string after the execution of the following code?
special = '1337 Country Ln.'
s_string = special[ :4]
a. '1357'
b. 'Country Ln.'
c. ' Country Ln.'
d. Invalid code - ANSWERS-'1357'