-
Notifications
You must be signed in to change notification settings - Fork 266
Countdown
Sar Champagne Bielert edited this page Apr 8, 2024
·
5 revisions
Unit 1 Session 1 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
- Will
mandnalways be positive integers?- Yes.
- Will
never be larger thanm?- No.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Create a function that takes parameters n and m and counts down the numbers from m down to n.
1) Loop through the numbers starting at `m`, ending at `n`, and stepping -1 each time
2) Print each number- Make sure your loop includes the first number and the final number!
- How can you tell
range()to step -1 each time?
def countdown(m, n):
for num in range (m, n-1, -1):
print(num)