Page 1 of 1

In python

Posted: Sun Jul 10, 2022 11:25 am
by answerhappygod
In python
In Python 1
In Python 1 (218.22 KiB) Viewed 44 times
Exercise 1: Recursive Power Function Create a program that takes in a base and exponent for the user. If the input is valid, it prints the answer of the base taken to the power given. You must require the user to give ints for both the base and the exponent. Also, the exponent must be zero or larger. Sample runs: Enter a base: 2 Enter a power: 3 Answer: 8 Enter a base: 256 Enter a power: 1 Answer: 256 Enter a base: 256 Enter a power: 0 Answer: 1 Enter a base: -1 Enter a power: 3 Answer: -1 Enter a base: 2 Enter a power: -1 Sorry, your exponent must be zero or larger. Enter a power: -1 Sorry, your exponent must be zero or larger. Enter a power: -1 Sorry, your exponent must be zero or larger. Enter a power: -1 Sorry, your exponent must be zero or larger. Enter a power: -1 Sorry, your exponent must be zero or larger. Enter a power: 10 Answer: 1024