Uploaded by lizziehuynh16

MIS6382-HomeworkFive

advertisement
Hongchang Wang
JSOM, UTD
Spring 2023
MIS 6382
Due by 11:55 pm 05/10/2023
MIS 6382
Object Oriented Programming in Python
Spring 2023
Homework Five
The following guidelines should be followed and will be used to grade your homework:
• The code for each question should be implemented using Jupiter notebooks.
• All the code should be included in one single Jupyter Notebook file (.ipynb) and
•
•
submitted to eLearning. Use the code mode rather than the markdown mode so the
notebook can run directly (feel free to leave the results/outputs there). The file should be
named using your name and the chars “hw5”, e.g. firstname_lastname_hw5. You will be
penalized 15% of the grade if your submission does not follow these requirements.
This is an individual homework assignment; no group submissions will be accepted.
You will get zero points if your program has syntax errors.
Q1: The attached carprices.txt contains a single column of car prices in 1000’s. Read this data
into your program. The first line is the heading and should be ignored. For any line containing
non-numeric data, raise a ValueError exception and print a message saying ‘This data is invalid
and will be ignored’ together with the exception object. You should divide each number by 10
and round it down to the nearest integer. Then plot a histogram that looks like the one shown
below. The number of bins to use is 50.
1
Hongchang Wang
JSOM, UTD
Spring 2023
MIS 6382
Due by 11:55 pm 05/10/2023
Q2: The attached wildlife.txt contains data about the population of bears, dolphins and whales
over a number of years. Read this data into your program. The first line is the heading and
should be ignored. Then plot a line chart displaying the population trend for each animal. Your
graph should look like the one shown below.
2
Hongchang Wang
JSOM, UTD
Spring 2023
MIS 6382
Due by 11:55 pm 05/10/2023
Q3: The attached cartype.txt contains a single column listing the type of car (van, compact, etc).
Read this data into your program. The first line is the heading and should be ignored. Then plot
a piechart after computing the frequency for each car type. Your chart should look like the one
shown below (no need to match the exact color or position). Each slice should be separated
from the next as shown below.
3
Hongchang Wang
JSOM, UTD
Spring 2023
MIS 6382
Due by 11:55 pm 05/10/2023
Q4: Use the OOP style to replicate the figure in PlottingVI.ipynb file. You can refer to this link
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplots.html or search more broadly
on yourself. Here OOP style means “explicitly create figures and axes, and call methods on
them”. You are expected to include something like “fig, ax = plt.subplots()” or “fig, (ax1, ax2) =
plt.subplots(*,*)” in your program. Your graph should look like the one shown below.
4
Download