Provide the followingfor Makeup Lab 4.5:
1. Create a function called isOdd() that determines ifa whole number input is even or odd.
2. Create a separate error-trapping function to ensurethe user enters only valid input.
3. Create a main function that calls the above functions asnecessary.
• The function has thefollowing requirements:
1. It should be named isOdd( ).
2. The function requires oneparameter called num. This is the numberthat is being checked.
3. Use of the Python modulus operator - % - totest the number.
4. The function is required to returna boolean value: true if odd,or false if even.
5. The function should not display any output. Itshould only return the appropriate boolean value asspecified above.
The following is required within the isOdd() function to test the value:
1. An if/else statement.
2. Additional local variables as necessary. Any additional variables used should bedescriptive. You will lose points for non-descriptiveidentifiers. i.e., No single letter variable names.
3. Use of the Python modulusoperator - %.
e.g.,
Use modulus division with a number à 2% 2 will result in a zero remainder, 3 % 2 willresult in a remainder of 1. A number evenly divided by two(i.e., remainder 0) is even, otherwise it isodd (remainder 1).
The main function must also calla separate function called validateInput( ) that errorchecks the input from the user. Only non-negativewhole numbers are permitted. The function returns thevalidated value after resoliciting the input from the user ifinvalid data are entered. Finally, the mainfunction displays whether the value entered is odd oreven.
The main function also asks the user if they desire to runagain. If so, the program repeats until the user enters “n”or “N”. User responses for this prompt must be errortrapped.
Please do in python
Provide the following for Makeup Lab 4.5: 1. Create a function called isOdd( ) that determines if a whole number input i
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am