Question: Use Python 3 or above Question 4: Define a function named q40 that accepts a string as a parameter. After verifying that the string includes

 Use Python 3 or above Question 4: Define a function named

Use Python 3 or above

Question 4: Define a function named q40 that accepts a string as a parameter. After verifying that the string includes only includes numeric digits, count the number of even (E) and odd (O) digits. Finally, create a new string made up of these values and their sum. Repeat this process until your end result is a string containing '123 For example, 15327" contains 1 even digit (E-1), 4 odd digits(O-4) and the sum of these is 5 (E+O). The new string would be '145'. Repeating the process (E-1, O-2, E+O-3) gives me '123'. The function q40 should return the number of repetitions it takes to create the string 123 Example output of function q40 at the interactive Python prompt: Already 123' so takes zero repetitions >q4 (5) 4'471') >>>q4 ('1234567890 >>>q4'0 NOTE: Your q40 function should return only the number of repetitions; it should not print anything

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!