Python Code: Write a function that takes a single number as an argument: 1) This function should then check whether a number is an even number (2,4,6,8) and raise an exception if otherwise 2) Call this function with an uneven number first without catching the exception and then with catching the exception and printing a warning to the user afterwards Bonus: Do the same as the above but instead implement your solution for prime numbers and call the function with a non-prime number

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter14: Exception Handling
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Python Code:

  • Write a function that takes a single number as an argument:

1) This function should then check whether a number is an even number (2,4,6,8) and raise an exception if otherwise

2) Call this function with an uneven number first without catching the exception and then with catching the exception and printing a warning to the user afterwards

Bonus: Do the same as the above but instead implement your solution for prime numbers and call the function with a non-prime number

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Header Files
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning