Question

I cannot upload the needed text files to this question for your benefit of double checking...

I cannot upload the needed text files to this question for your benefit of double checking your solution, but I need help on this multi part question. Thanks!

Write a Python program that will open the ‘steam.csv’ file. Your program should load the data as col- umns corresponding to the variable names located in the first row (You can hard code this – i.e open the file and use the names in the first row as variable names). You should neglect the second row since these are reserved for units. Load each column of numerical data into a tuple corresponding the variable name. Name your file Lab9a.py.

Write a new program that will prompt the user for a file name. If the file exists, the program should open the file and load the data (you can use your code from above). Prompt the user if they would like to print the data to the screen or if they would like to print a particular column of data (as defined by the varia- ble) to the screen. The prompt should look like a menu below. Name your file Lab9b.py.

What would you like to do?

  1. 1) Print all data to Screen

  2. 2) Print a particular variable

if menu item 2 is chosen, display the following:

  1. a) Temperature

  2. b) Pressure

  3. c) Specific Volume – liquid (vf)

  4. d) Specific Volume – vapor (vg)

  5. e) Internal Energy – liquid (uf)

  6. f) Internal Energy – vapor (ug)

  7. g) Enthalpy – liquid (hf)

  8. h) Latent Heat of Vaporization (hfg)

  9. i) Enthalpy – vapor (hg)

  10. j) Entropy – liquid (sf)

  1. k) Change in Entropy (sfg)

  2. l) Entropy – vapor (sg)

Homework Answers

Answer #1

Code Lab9a.py

import csv
lis=[]
#Hard coding from csv file
Temperature=[]
Pressure=[]
vf=[]
vg=[]
uf=[]
ug=[]
hf=[]
hfg=[]
hg=[]
sf=[]
sfg=[]
sg=[]

with open('steam.csv', 'r') as file:
    reader = csv.reader(file)
    for i in reader:
        lis.append(i)
row=len(lis)
col=len(lis[0])
for i in range(row-2):
    #hardcoding
    Temperature.append(int(lis[i+2][0]))
    Pressure.append(int(lis[i+2][1]))
    vf.append(int(lis[i+2][2]))
    vg.append(int(lis[i+2][3]))
    uf.append(int(lis[i+2][4]))
    ug.append(int(lis[i+2][5]))
    hf.append(int(lis[i+2][6]))
    hfg.append(int(lis[i+2][7]))
    hg.append(int(lis[i+2][8]))
    sf.append(int(lis[i+2][9]))
    sfg.append(int(lis[i+2][10]))
    sg.append(int(lis[i+2][11]))

TemperatureT=tuple(Temperature)
PressureT=tuple(Pressure)
vfT=tuple(vf)
vgT=tuple(vg)
ufT=tuple(uf)
ugT=tuple(ug)
hfT=tuple(hf)
hfgT=tuple(hfg)
hgT=tuple(hg)
sfT=tuple(sf)
sfgT=tuple(sfg)
sgT=tuple(sg)

Code Lab9b.py

import csv
lis=[]
#Hard coding from csv file
Temperature=[]
Pressure=[]
vf=[]
vg=[]
uf=[]
ug=[]
hf=[]
hfg=[]
hg=[]
sf=[]
sfg=[]
sg=[]
try:
    filename=input("Please enter a file name ")
    with open(filename, 'r') as file:
        reader = csv.reader(file)
        for i in reader:
            lis.append(i)
except:
    print("Error while opening file check your file name if it exists")
    exit();
row=len(lis)
col=len(lis[0])
for i in range(row-2):
    #hardcoding
    Temperature.append(int(lis[i+2][0]))
    Pressure.append(int(lis[i+2][1]))
    vf.append(int(lis[i+2][2]))
    vg.append(int(lis[i+2][3]))
    uf.append(int(lis[i+2][4]))
    ug.append(int(lis[i+2][5]))
    hf.append(int(lis[i+2][6]))
    hfg.append(int(lis[i+2][7]))
    hg.append(int(lis[i+2][8]))
    sf.append(int(lis[i+2][9]))
    sfg.append(int(lis[i+2][10]))
    sg.append(int(lis[i+2][11]))

TemperatureT=tuple(Temperature)
PressureT=tuple(Pressure)
vfT=tuple(vf)
vgT=tuple(vg)
ufT=tuple(uf)
ugT=tuple(ug)
hfT=tuple(hf)
hfgT=tuple(hfg)
hgT=tuple(hg)
sfT=tuple(sf)
sfgT=tuple(sfg)
sgT=tuple(sg)

print("What would you like to do?")
print("1) Print all data to Screen")
print("2) Print a particular variable")
inp=int(input())
if(inp==2):
    print('''a) Temperature
b) Pressure
c) Specific Volume – liquid (vf)
d) Specific Volume – vapor (vg)
e) Internal Energy – liquid (uf)
f) Internal Energy – vapor (ug)
g) Enthalpy – liquid (hf)
h) Latent Heat of Vaporization (hfg)
i) Enthalpy – vapor (hg)
j) Entropy – liquid (sf)
k) Change in Entropy (sfg)
l) Entropy – vapor (sg)''')
    print("Enter your choice a-l")
    inp2=input()
    if(inp2=="a"):
        print("Temperature ",TemperatureT)
    elif(inp2=="b"):
        print("Pressure ",PressureT)
    elif(inp2=="c"):
        print("Specific Volume – liquid ",vfT)
    elif(inp2=="d"):
        print("Specific Volume – vapor ",vgT)
    elif(inp2=="e"):
        print("Internal Energy – liquid  ",ufT)
    elif(inp2=="f"):
        print("Internal Energy – vapor ",ugT)
    elif(inp2=="g"):
        print("Enthalpy – liquid ",hfT)
    elif(inp2=="h"):
        print("Latent Heat of Vaporization ",hfgT)
    elif(inp2=="i"):
        print("Enthalpy – vapor ",hgT)
    elif(inp2=="j"):
        print("Entropy – liquid ",sfT)
    elif(inp2=="k"):
        print("Change in Entropy ",sfgT)
    elif(inp2=="l"):
        print("Entropy – vapor ",sgT)
    else:
        print("Invalid Input")
elif(inp==1):
    for i in lis:
        for j in i:
            print(j,end=" ")
        print()
else:
    print("Invalid Input")

Dummy Output Lab9b.py:

Please enter a file name steam.csv
What would you like to do?
1) Print all data to Screen
2) Print a particular variable
2
a) Temperature
b) Pressure
c) Specific Volume – liquid (vf)
d) Specific Volume – vapor (vg)
e) Internal Energy – liquid (uf)
f) Internal Energy – vapor (ug)
g) Enthalpy – liquid (hf)
h) Latent Heat of Vaporization (hfg)
i) Enthalpy – vapor (hg)
j) Entropy – liquid (sf)
k) Change in Entropy (sfg)
l) Entropy – vapor (sg)
Enter your choice a-l
f
Internal Energy – vapor (30, 30, 30)


Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I am looking for PYTHON code that will display the following: Code a menu-driven application that...
I am looking for PYTHON code that will display the following: Code a menu-driven application that does the following: The user can enter data for a product name, product code, and unit price. An example might be 'Breaburn Apples', 'BAP'. 1.99. After entering the data, it is appended (note I said 'appended') as a single line of text to a text file. Each line of text in the file should represent a single product. There is an option to display...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
Programming Language is Java In class you learned how to work with collections and streams. This...
Programming Language is Java In class you learned how to work with collections and streams. This lab allows you to apply the skills you learned to a list of riders. With your first two assignment complete, the coordinator at the Car Safety Academy decided to begin collecting names for a monthly mailing list. You've been asked to collect the names and perform some processing. First you will create a Riders class. Then you will create an array of riders with...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):         self.name = name         self.pop = pop         self.area = area         self.continent = continent     def getName(self):         return self.name     def getPopulation(self):         return self.pop     def getArea(self):         return self.area     def getContinent(self):         return self.continent     def setPopulation(self, pop):         self.pop = pop     def setArea(self, area):         self.area = area     def setContinent(self, continent):         self.continent = continent     def __repr__(self):         return (f'{self.name} (pop:{self.pop}, size: {self.area}) in {self.continent} ') TASK 2 Python Program: File: catalogue.py from Country...
Description: The purpose of this assignment is to practice writing code that calls functions, and contains...
Description: The purpose of this assignment is to practice writing code that calls functions, and contains loops and branches. You will create a C program that prints a menu and takes user choices as input. The user will make choices regarding different "geometric shapes" that will be printed to the screen. General Comments: Your code must contain at least one of all of the following control types: nested for() loops a while() or a do-while() loop a switch() statement an...
Data Encryption (Strings and Bitwise Operators) Write a C program that uses bitwise operators (e.g. bitwise...
Data Encryption (Strings and Bitwise Operators) Write a C program that uses bitwise operators (e.g. bitwise XOR) to encrypt/decrypt a message. The program will prompt the user to select one of the following menu options: 1. Enter and encrypt a message 2. View encrypted message 3. Decrypt and view the message (NOTE: password protected) 4. Exit If the user selects option 1, he/she will be prompted to enter a message (a string up to 50 characters long). The program will...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
n this lab, you use what you have learned about parallel arrays to complete a partially...
n this lab, you use what you have learned about parallel arrays to complete a partially completed C++ program. The program should: Either print the name and price for a coffee add-in from the Jumpin’ Jive Coffee Shop Or it should print the message Sorry, we do not carry that. Read the problem description carefully before you begin. The file provided for this lab includes the necessary variable declarations and input statements. You need to write the part of the...