Define the max_x function

Assignment Help Python Programming
Reference no: EM132357066

Question

Define the max_x function, which takes two arguments: (1) a function -call it f- (of one parameter)and (2) any iterable that produces values that can be passed as arguments to f.

When max_x is called, itreturns the value in the iterable for which f returns the maximum (if multiple values in the iterable havethe same maximum when f is called on them, you may return any of these values).

For example: if we callmax_x( cos, frange(-1.5,1.5,.1) ), it should return 0.0, because cos(0.0) is 1.0 and the cos of anyother value in this range is less than 1.0. If the iterable produces no values, then max_x should raise theValueError exception.

(a) Write the max_x function using looping/ifs, creating no lists (or any other data structure).

modify this function that is given:

def max_x(f: callable, values: Iterable) -> object:

pass

Reference no: EM132357066

Questions Cloud

Integrate some of the concepts from essentialism : Integrate some of the concepts from Essentialism with some of the ideas put forth in Thinking in Bets. How do these ideas support the same view of work life?
Count orlok and other mother from coraline scary monsters : What makes Count Orlok and Other Mother From Coraline scary monsters? You might consider what kind of threat they represent and how both drain lives of victims.
Inherent weakness of extrapolation-forecasting technique : 1. What is the inherent weakness of extrapolation as a forecasting technique? 2. Why should environmental scanning be a process and not an event?
Identify the genre or nature of the reading : Briefly introduce the writer and the situation that this reading is about. Identify the genre or nature of the reading. (Who is the author; why did he or she.
Define the max_x function : Define the max_x function, which takes two arguments: a function -call it f- of one parameter and any iterable that produces values.
Identify and outline three different sustainability practice : Identify and outline three different sustainability practices common in Australian workplaces.
Give an example of supply and demand market price : Give an example of supply and demand market price changes that you or a family member have experienced or that you have learned
Create a pseuodcode to design a do-while loop : Create a pseuodcode to design a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed.
Discuss the four alternative ways : Discuss the four alternative ways, in addition to fines, to punish white-collar criminals discussed in the text. Discuss the pros and cons of each.

Reviews

Write a Review

Python Programming Questions & Answers

  Write the output that would be printed to the python console

Why is it a potentially bad design choice to simply have the statement except: as one of the clauses of the function? rite the output that would be printed.

  Write a program that prompts for the day and month of user

CPSC 1301L COMPUTER SCIENCE-Write a program that prompts for the day and month of the user's birthday and then prints a horoscope. Make up technology.

  Write a test program that creates two rectangle objects

A constructor that creates a rectangle with the specified width and height. The default values are 1 and 2 for the width and height, respectively.

  The function should return the day name (''su'',''mo''..etc)

Write the function day(d,m) where m is an integer from 1 through 12 expressing a month, and d is an integer from 1 through 31 expressing the day part of a date in 2014.

  Create a dictionary containing the us states as keys

Prepare a Program that creates a dictionary containing the U.S. states as keys and their capitals as values. You need to store the capitals and states.

  Invent your own function that does some useful computation

Invent your own function that does some useful computation of your choosing. Use incremental development, and record each stage of the development.

  Write program that allows teacher to read in student names

Write program that allows teacher to read in student names. The program must be written in accordance with the following specs.

  Write one Python notebook to create required outputs

In this assignment, you will write one Python notebook to create required outputs. Sample outputs are attached. In all your programs, use markdown cells

  Write the boolean expression that will state grater number

If x and y are both numbers: write the Boolean expression that will state that (x - 2y) is greater than 0 and less than 12. write the Boolean expression.

  Calculate the metrics from the array

Devise a way to keep track of which month names go to which rainfall values. You may not hard code the month names into the print statements for the last two

  Write a function called make payment

Write a function called "make payment(P)" that takes as an argument the total payment on the credit card ($P) and prints "Success" or "Retry."

  Write a program that will open a blastn

Write a program that will open a BLASTN (nucleotide to nucleotide search) output file, parse out specific information, and produce formatted output that will be written to STDOUT

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd