Question: Write a program in Python with the following: a) Function isPrime : - description: verifies if a whole number is prime. - input parameter: whole
Write a program in Python with the following:
a) Function isPrime:
- description: verifies if a whole number is prime.
- input parameter: whole number.
- return: True or False.
Remark: a prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
b) Function isOdd:
- description: verifies if a whole number is odd.
- input parameter: whole number.
- return: True of False
c) Function power:
- description: calculates the exponentiation of a whole number.
- input parameters: whole number, exponent
- return: number to the power of exponent.
c) Function main:
- description: using functions isPrime, isOdd and power, show the odd prime numbers between the numbers from 1 to 100 (inclusive), and the corresponding exponentiation values: n0, n1, n2 and n3, in a table like the following:
------------------------------------------------------------------
Odd Prime Power of Power of Power of Power of
Number 0 1 2 3
------------------------------------------------------------------
3 1 3 9 27
5 1 5 25 125
11 1 11 121 1331
79 1 79 6241 493039
83 1 83 6889 571787
89 1 89 7921 704969
97 1 97 9409 912673
------------------------------------------------------------------
Show the results on the screen.
For the coding, use:
- camel or Hungarian notation
- in-program comments
- logic
- accuracy
- efficiency
Remark: you can't use any Math built-in function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
