Conditional Statements & Loops: The Basics of for Loops in Python

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

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))


Ensembles d'études connexes

Personal finance part two study guide

View Set

World History Chapter 13 Section 2 (1.2)

View Set

Mechanics and Materials Quiz 3 Concepts

View Set

Biology 1002 (CH.18,20,31,37,38,19)

View Set

UNIT 11: BUYER RELATIONSHIPS AND COUNSELING UNIT QUIZ

View Set