Question: Can someone please help with problem 1? I have to write a code that follows the step-by-step instructions seen in red in the Linux Mint
Can someone please help with problem 1? I have to write a code that follows the step-by-step instructions seen in red in the Linux Mint software.
Problem 1. (Min Max) Write a program min_max.py that reads in floats (as many as the user enters) from standard input and writes out the minimum and maximum values along with their ranks, ie, their positions (starting at 1) in the input s python3 min_max.py 3,0 1.0 5.0 4.0 2.0 ctrl -d min val = 1.000000, min rank = 2 max val = 5.000000, max rank = 3 Linux Mint [Runningl min_max.py(/coursework/homework5) File Edit View Search Tools Documents Help min-max.py: reads in floats (as many as the user enters) from standard # input and writes out the minimum and maximum values along with their ranks, # ie, their positions (starting at 1) in the input. import stdio # Smallest and largest floats. NEG INFINITY float ('inf.) POSINFINITY = float ('inf') - # Read floats from standard input into a list a. # Define variables to keep track of the mininum value and its rank and # the maximum value and its rank. min valPOS INFINITY min rank max valNEG INFINITY max rank - # Iterate the list a to identify the minimum value and its rank and the # maximum value and its rank. If v is smaller than min-val, update min-val # to v and min-rank to 1 + 1; similarly, update max-val and max-rank. for i, v in enumerate(a) # Write the results (min-val, min-rank, max-val, max-rank). stdio.writef ('nin va! = %f , min rank = %d ., , ) stdio. writef ( ' max val = %f, max rank = %d . , . . . , . . . )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
