Exercise
Function To Find Maximum Value In An Array
Objective
Develop a Python program containing a function that accepts a list of floating-point numbers as input and returns the maximum value within the list: data = [1.5, 0.7, 8.0] max_value = maximum(data)
Example Python Exercise
Show Python Code
# Function to find the maximum value in a list of floating-point numbers
def maximum(data):
# Return the maximum value from the list
return max(data)
# Main function to demonstrate the maximum function
def main():
# Input list of floating-point numbers
data = [1.5, 0.7, 8.0]
# Call the maximum function and store the result
max_value = maximum(data)
# Print the result
print(f"The maximum value in the list is {max_value}")
# Run the main function
if __name__ == "__main__":
main()
Output
The maximum value in the list is 8.0
Share this Python Exercise