Which of the following code snippets describe an ordered collection of data in Python?
Which of the following words is used to describe a collection?
Which code snipped can be used to access the letter s
from a variable named level
referencing the string basic
?
What is the value of the variable output
after running this code
output = '1,2,3'.split(',')
?
If you have a tupple named colors
which contains ('white','red','green')
, how do you access the color red
from the tupple?
The following code describes the assignment of a dictionary to a variable: my_dict = {'day':'Tuesday','weather':'snow','temp':'32F'}
. Which of the code snippets below can be used to convert the dictionary into 3 string variables: day_of_week,precipitation,temperature
?
After opening a CSV file with read mode, you read the data one row
at time with for row in file.readlines():
. You want to convert each row
from a csv string terminated by a newline into a list of strings. Which code snippet can you use to convert the row
from a string with a newline into a list of data strings.
If you want raise an exception when a user has chosen option 5, but you only support options 1-4, how will you code this?
When will the code following except FileNotFoundError as e:
be executed?
What is the purpose of finally
in Python exception handling?