Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions