USING PYTHON Complete the countdown generator function named countdown(n). Given
ID: 3676488 • Letter: U
Question
USING PYTHON
Complete the countdown generator function named countdown(n). Given the positive integer n, the generator yields n, n-1, n-2 and so on down to 0. The last number must be 0. After 0 is reached, the generator must stop. # 1. Return the remaining time n, but don't use return! This is a generator function # 2. Stop if the remaining time becomes negative, # OK, now use your generator function to help launch your Delta IV Heavy rocket! # 3. Construct a generator (iterator) which will start counting down from 10. # 4. Complete the header for a for loop, which will countdown from 10 to 0 using gen. Your answer must work with the body that is given. # 5. Wait one second before the next number is yielded. The time module has already been imported.Explanation / Answer
Answer for Question 1:
Step 1: if n>0:
Step 2: else if n<0 :
Step 3: gen = countdown(n)
Step 4: countdown(n)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.