Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 anythingStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started