Question
Python programmin question In the previous problem, you added if statements that would determine the smallest of three values from a file. Now you want
Python programmin question
In the previous problem, you added if statements that would determine the smallest of three values from a file. Now you want the code to return the median value--in this case the middle value of the three instead. Furthermore, you decide you want to put these if statements in a function min so that you can call the function instead. So, for this question, do two things:
1. write the definition for the function median, that takes three numbers as parameters and returns the middle one.
2. show how the median function would be called if you replaced the if statements in your answer to the previous question with the function call.
Do not rewrite the entire program from the previous question. Just write the code that is asked for.
This is the previous problem which I completed
Consider the following program. Rewrite it to make the changes indicated in the comments. Assume the user will enter valid file names and valid values, so no error-checking is needed.
print("Enter three integer values - each on a separate line.", end =" ") #TODO: change the code below for user input so that the user enters a file name from which to read the three values # instead of typing in the three values from the console, then reads the 3 values from the file a = int(input()) b = int(input()) c = int(input()) #TODO: add code here to use if statements to determine the smallest value of the three #TODO: change the code below to write output to a text file called out.txt instead of # printing to the console print("The smallest value entered was {0}".format(min), end = " ") input("Press any key to exit...")
Step 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