# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [default]
#     language: python
#     name: python3
# ---

# + [markdown] nbgrader={"grade": false, "grade_id": "q7_prompt", "locked": true, "solution": false}
# # Q7
#
# More written answers!

# + [markdown] nbgrader={"grade": false, "grade_id": "q7a_prompt", "locked": true, "solution": false}
# ### A
#
# How are generators and lists similar? How are they different?

# + [markdown] nbgrader={"grade": true, "grade_id": "q7a", "locked": false, "points": 3, "solution": true}
#

# + [markdown] nbgrader={"grade": false, "grade_id": "q7b_prompt", "locked": true, "solution": false}
# ---
# ### B
#
# Let's say I'm inside a `for` loop, iterating through a large generator object (e.g. `range`). I come across a sequence of values I want to skip, moving several iterations ahead, but for whatever reason I don't know about `continue`. I decide to simply increment my loop variable by 5 inside the loop body after checking if it meets a certain condition. Will this work? Why or why not?

# + [markdown] nbgrader={"grade": true, "grade_id": "q7b", "locked": false, "points": 3, "solution": true}
#

# + [markdown] nbgrader={"grade": false, "grade_id": "q7c_prompt", "locked": true, "solution": false}
# ---
# ### C
#
# If I want to check if two lists contain identical elements *irrespective of ordering*, how could I do that?

# + [markdown] nbgrader={"grade": true, "grade_id": "q7c", "locked": false, "points": 3, "solution": true}
#

# + [markdown] nbgrader={"grade": false, "grade_id": "q7d_prompt", "locked": true, "solution": false}
# ---
# ### D
#
# I have four lists, each with `N` elements. I want to loop through them all simultaneously, so I `zip()` them together. How many elements will now be in my `zip()` generator?

# + [markdown] nbgrader={"grade": true, "grade_id": "q7d", "locked": false, "points": 3, "solution": true}
#

# + [markdown] nbgrader={"grade": false, "grade_id": "q7e_prompt", "locked": true, "solution": false}
# ---
# ### E
#
# I have a matrix, and to iterate through it I use nested `for` loops. In doing so, I check the value at each matrix element, looking for a specific match. If the match is found, I execute a `break` statement:
#
# ```
# matrix = [ ... ]
# for i in range(len(matrix)):
#     for j in range(len(matrix[i])):
#         if matrix[i][j] == some_value:
#             break
# ```
#
# What happens?

# + [markdown] nbgrader={"grade": true, "grade_id": "q7e", "locked": false, "points": 3, "solution": true}
#

StarcoderdataJupyterScriptsDedupFiltered