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
2
Q
What happens when an operation cannot be completed due to a lack of memory?
A
Python raises a Memory error
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
4
Q
What is another name for a function that uses yield instead of return?
A
A generator function