Question

Saved BlockPy: #33.8) Maximum Odd Use the Min/Max pattern to write a function maximum_odd that finds the highest odd value in the list (consumes a list of numbers and returns a number). Use the provided helper function is_odd (that consumes a single number and returns a boolean indicating whether it is true or false). Do not change the helper function is_odd. Call your maximum_odd function on your favorite list of numbers. Server Execution: Idle Feedback: Ready Console Run Blocks 艹Split Text Reset 0 Upload History 1 def is odd (a number): 2 return a number % 2 -- I

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the complete required Python script. The script contains a driver program that calls the maximum_odd function with a sample input list. This list can be modified as per the user requirement.

#==================================================================

# Given helper function

def is_odd(a_number):

return a_number % 2 == 1;

# Function to find the maximum odd number in the list

def maximum_odd(mylist):

max = 1; # Initialization

for i in range(len(mylist)):

if is_odd(mylist[i]):

if mylist[i]>max:

max=mylist[i];

return max;

# Main driver program

mylist = [1,2,33,47,25,6,7,76]; # Sample input

max_odd = maximum_odd(mylist);

print('The maximum odd number in the list is: ',max_odd);

#==================================================================

Sample output:

The maximum odd number in the list is:  47

Hope this helps! PLEASE THUMSB UP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Add a comment
Know the answer?
Add Answer to:
Saved BlockPy: #33.8) Maximum Odd Use the Min/Max pattern to write a function maximum_odd that finds...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • BlockPy: #33.8) Maximum Odd Use the Min/Max pattern to write a function maximum_odd that finds the...

    BlockPy: #33.8) Maximum Odd Use the Min/Max pattern to write a function maximum_odd that finds the highest odd value in the list (consumes a list of numbers and returns a number). Use the provided helper function is_odd (that consumes a single number and returns a boolean indicating whether it is true or false). Do not change the helper function is odd. Call your maximum_odd function on your favorite list of numbers Console Feedback: Instructor Feedback You cannot use the builtin...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT