Question: 1. Copy the countdown function def countdown(n): if n >> countup(-3) -3 -2 -1 Blastoff! Write a Python program that gets a number using keyboard
1. Copy the countdown function
def countdown(n):
if n <= 0:
print('Blastoff!')
else:
print(n)
countdown(n-1)
Write a new recursive function countup that expects a negative argument and counts “up” from that number. Output from running the function should look something like this:
>>> countup(-3)
-3
-2
-1
Blastoff!
Write a Python program that gets a number using keyboard input . (Remember to use input for Python 3 but raw_input for Python 2.)
If the number is positive, the program should call countdown. If the number is negative, the program should call countup. Choose for yourself which function to call for input of zero.
Provide the following.
- The code of your program.
- Output for the following input: a positive number, a negative number, and zero.
- An explanation of your choice for what to call for input of zero.
2. Write your own unique Python program that has a runtime error .
- The code of your program.
- Output demonstrating the runtime error, including the error message.
- An explanation of the error message.
- An explanation of how to fix the error.
Step by Step Solution
3.40 Rating (159 Votes )
There are 3 Steps involved in it
This is a complete question Heres how you can approach and solve it Problem 1 Countdown and Countup Program Step 1 Develop the countup function The co... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (2 attachments)
606ad5685c62a_47931.pdf
180 KBs PDF File
606ad5685c62a_47931.docx
120 KBs Word File
