Module 4 Flashcards

1
Q

Which part of your code lets you place pieces of code that might result in exceptions?

A

The try: branch of a try-except Block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What happens when an operation cannot be completed due to a lack of memory?

A

Python raises a Memory error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does yield do?

A

It’s used like return but it released a series of return values over time

So:

def simpleYield():
yield 1
yield 2
yield 3

for val in simpleYield():
print(val)

Output:
1
2
3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is another name for a function that uses yield instead of return?

A

A generator function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly