Question: 1 . Write a phyton script that emulates a simple small calculator Ask the user for 2 numbers and the operation to perform The operations

1. Write a phyton script that emulates a simple small calculator
Ask the user for 2 numbers and the operation to perform
The operations needed are addition, subtraction, multiplication, division
How the user is to input these is up to you.
Show the user the result of the operation
2. Whats Recursion? Whats the base case?
3. Here is a minimal program with a recursion:
def recurse():
recurse()
What happens if you call this function in the console? And Explain
4. Consider the following example:
def countdown(n):
if n <=0:
print ('Blastoff!)
else:
print (n)
countdown(n-1)
a. Is this a recursion? explain
b. Whats the base case in this function?
c. Is this infinite recursion? And why?
d. Step-by-Step explanation for countdown(3).
5. The factorial operation consists of the following equation:
n!=n*(n-1)*(n-2)*...3*2*1
It can also be expressed as:
n!=n*(n-1)!,0!=1
Write a function that uses recursion to calculate the factorial of a given number n
What is the factorial of 9?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!