Conditional Statements & Loops: The Basics of for Loops in Python
Given the following code, what is the type of x which is printed out in each iteration? my_list = [['tiger', 'lion', 'leopard'], ['camel', 'llama', 'alpaca'], ['zebra', 'donkey', 'wildebeest']] for x in my_list: print(x)
A list of strings
What is the correct value of x given the assignment shown? x = list(range(-17, -7, 2))
[-17, -15, -13, -11, -9]
What is the maximum value in the sequence x? x = range(2, 14)
13
Given a variable my_dict which is a dictionary, consider you use it in a for loop in this manner: for x in my_dict: print (x) What are the contents printed out?
The keys in the dictionary
Which TWO of the following statements about for loops in Python are TRUE?
They may have an associated else block They can iterate over the elements in tuples, lists, and dictionaries
Which of these Python data types can NOT be iterated through using for loops?
int
Which of the following function calls will generate the list below?[10, 7, 4, 1, -2]
list(range(10, -3, -3))
