Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def countdown(n): if n >> countup(-3) -3 -2 -1 Blastoff! Write a Python program that gets a number using keyboard input . (Remember to useinputfor

def countdown(n):

if n <= 0:

print('Blastoff!')

else:

print(n)

countdown(n-1)

Write a new recursive functioncountupthat 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 usingkeyboard input. (Remember to useinputfor Python 3 butraw_inputfor Python 2.)

If the number is positive, the program should callcountdown. If the number is negative, the program should callcountup. Choose for yourself which function to call (countdownorcountup) 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.

Important: Please make sure you provide the output for a positive number, a negative number, and zero.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Define the three forms of market efficiency.

Answered: 1 week ago