Question

In: Computer Science

Top-Down Design of a Program in PYTHON Following the process described in the lecture, you should,...

Top-Down Design of a Program in PYTHON

Following the process described in the lecture, you should, as a team, perform a top-down design for a program. Then, construct code for the program.

Open the Excel file entitled “Lab8-data.xlsx”. This document lists thermodynamic properties of liquid water at varying temperatures and at two different pressures. The properties listed are as follows:

  • Specific volume (v ) in units of m3kg
  • Specific internal energy (u ) in units of kJ/kg
  • Specific enthalpy (h ) in units of kJ/kg
  • Specific entropy (s ) in units of kJ/(kg∙K)

It is common to use linear interpolation for temperature values not listed. So, for example, if you need the properties at T=25 ℃ , you could interpolate between the property values listed for T=20 ℃ and T=40 ℃ as a good estimate.

For your program, hard-code the temperature and property values for P = 5 MPa as lists for temperatures from T=0 ℃ to at least T=100 ℃ . Have the user enter a temperature in that range from the keyboard. Your program should find the two values of temperature that bracket the user’s value, then perform linear interpolation for all four properties. The results should be formatted and printed to the screen based on the example output shown below. Print the specific volume, specific internal energy, specific enthalpy, and specific entropy to 7, 2, 2, and 4 decimal places, respectively.

Example output (using input 50):

Enter a temperature between 0 and 260 C: 50

Properties at 50.0 deg C are:

Specific volume (m^3/kg): 0.0010103

Specific internal energy (kJ/kg): 208.60

Specific enthalpy (kJ/kg): 213.66

Specific entropy (kJ/kgK): 0.6996

Solutions

Expert Solution

def interpolate(temp2,temp1,val2,val1,temp_inp):
    return val1+ ((temp_inp-temp1)*(val2-val1)/(temp2-temp1))
Data = [[10,1,2,3,4],[20,3,5,7,0],[70,8,12,45,13],[100,34,67,92,12]] #You need to hardcode this from Lab8-data.xlsx in the format temperature,Specific volume, Specific internal energy, Specific enthalpy, Specific entropy
print("Enter temperature")
Data.sort(key = lambda x: x[1]) #sorting the list in ascending order of temperatute
inp = float(input())
for i,j in enumerate(Data):
    if j>Data[0]:
        c = i
        break
result = []
print("Properties at "+str(inp)+" C are:-")
for i in range(1,5):
    result.append(interpolate(Data[c][0],Data[c-1][0],Data[c][i],Data[c-1][i],inp))
print("Specific volume (m^3/kg): {0:.7f}".format(result[0]))
print("Specific internal energy (kJ/kg): {0:.2f}".format(result[1]))
print("Specific enthalpy (kJ/kg): {0:.2f}".format(result[2]))
print("Specific entropy (kJ/kgK): {0:.4f}".format(result[3]))
    
    

Let's take an example:-
Assume your Lab 8.xlsx looks like this
Temperate 10 20
specific internal energy 12 25
specific enthalpy 14 9
specific entropy 15 1

in the python code, you'll write

data = [[10,12,14,15,[20,25,9,1]]


Related Solutions

Top-down design: Design a program called TeamGame to simulate a simple game of drafting players to...
Top-down design: Design a program called TeamGame to simulate a simple game of drafting players to teams. Rules of the game: • There are two teams: Team A and Team B. • There are 50 players, with numbers from 1 to 50. • Each team will get 10 of the players. The program should randomly select 10 players for each team. To accomplish this, you may select each player randomly, or you may shuffle the list of players before making...
The coding for this program to run as described on Python: Your (turtle) program must include:...
The coding for this program to run as described on Python: Your (turtle) program must include: include import turtle on a line after the comments so you can use the various Turtle-related objects and methods. Create a turtle named after your favorite ice cream flavor. Make sure the name has no punctuation and consists only of letters, numbers and the underscore character. Write your python program so your turtle is constantly moving and can be turned left and right using...
In this python program , you are to build a trivia game. The game should present...
In this python program , you are to build a trivia game. The game should present each question – either in order or randomly – to the player, and display up to four possible answers. The player is to input what they believe to be the correct answer.   The game will tell the player if they got it right or wrong and will display their score. If they got it right, their score will go up. If they got it...
You should be aware of companies who operate a ‘top down’ approach to budgeting and companies...
You should be aware of companies who operate a ‘top down’ approach to budgeting and companies who involve members of staff at all levels in the budget preparation process. Discuss TWO advantages and TWO disadvantages to a company that adopts the latter process.
I need to write a program in python for a restaurant. The program should let the...
I need to write a program in python for a restaurant. The program should let the user enter a meal number, then it should display the meal name, meal price, and meal calories. Also, needs the appropriate output if the user enters an invalid meal number. I am supposed to use a dictionary, but my problem is it keeps giving me an error and telling me my menu is not defined. Not sure what I am doing wrong. print ("Welcome...
This is an exercise to design and write a Python program in good programming style for...
This is an exercise to design and write a Python program in good programming style for a simulation of stock price over a period of 100 days. In this exercise, you are asked to simulate the stock price starting at $100.00 for 100 days with a daily fluctuation based on the Normal Distribution with mean = 0.0 & sigma = 0.0125. The program will show the daily stock price, the 7-day minimum, the 7-day maximum, the 7-day average, and the...
In this assignment, you are going to write a Python program to demonstrate the IPO (Input-Process-Output)...
In this assignment, you are going to write a Python program to demonstrate the IPO (Input-Process-Output) cycle that is the heart of many imperative programs used for processing large amount of data. Daisy is recently hired by a warehouse. One of her job is to keep track the items ordered by all the branches of the company. The company wants to automate the task using a computer program. Being a friend of Daisy, she knows you are a Computer Science...
Design a PLC ladder logic program to implement an automatic Car-Wash process. The system should have...
Design a PLC ladder logic program to implement an automatic Car-Wash process. The system should have a start and stop pushbuttons. When a Car enters the washing skid, a load cell switch is activated and the following sequence is performed automatically: 1. Soaping for (20) sec through soap nozzles 2. Washing for (120) sec using big brushes 3. Rinsing for (60) sec using water nozzles 4. Drying for (40) sec using air nozzles After finishing this process, the washing skid...
This program should be done in python. This must use the principles of object oriented program....
This program should be done in python. This must use the principles of object oriented program. Create one or more classes to play Four-in-a-Row (also called Connect Four) with a user. It’s similar to tic-tac-toe but the board is of size 7×6 and discs fall straight through so the legal moves are more stringent than tic-tac-toe. The state of the board should be printed to the terminal after each legal move. You can represent the different colored discs as X’s...
Training Program: Design a full 12-week periodized training program for the client described in the Client...
Training Program: Design a full 12-week periodized training program for the client described in the Client Profile. Be very specific as you design the training program. This is an opportunity for you to demonstrate your full comprehension of the information and concepts discussed throughout the course. List the types of exercise, duration, sets, reps, rest intervals, and so on. Include the following in your case study submission: A description of your professional responsibilities as discussed in the stages of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT