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

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 Databases Questions!