In python

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

In python

Post by answerhappygod »

In python
In Python 1
In Python 1 (218.22 KiB) Viewed 43 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply