Question
In Python please - A. Create a script that uses the recursion function below (no loops or built-in Python functions) 1. def p(a, b): use
In Python please -
A. Create a script that uses the recursion function below (no loops or built-in Python functions)
1. def p(a, b): use this function to recursively find the power of a number (a will be the number, b will be the power, and assume b is always a positive integer). For example:
i. print(p(3, 2)) # 32 = 9
ii. print(p(-3, 3)) # -33 = -27
2. def ae(x): There are aliens in a line numbered starting from 1. The aliens who are numbered an odd number have 3 ears, and those who are numbered even have 2 ears. Use this function to print the total number of ears using (x). For example:
i. print(ae(1)) # 1 - alien 1 has 3 ears
ii. print(ae(2)) # 2 - alien 1 has 3 ears, alien 2 has 2 ears
iii. etc.
Note: every after # should be printed in the output.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started