\documentclass[12pt,reqno,twoside,usenames,dvipsnames]{amsart}

\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{verbatim}
\hypersetup{breaklinks=true,
pagecolor=white,
colorlinks=true,
linkcolor= blue,
hyperfootnotes= true,
urlcolor=blue
}
\urlstyle{rm}

 

\newcommand{\margincomment}[1]
  {\mbox{}\marginpar{\tiny\hspace{0pt}#1}}

\newcommand{\comments}[1]{}
\renewcommand{\baselinestretch}{1.2}
 \parindent 24pt
 \parskip 10pt
\reversemarginpar
\topmargin -1in \oddsidemargin -.5in \evensidemargin -.5in
\textheight 10in \textwidth 7in


\begin{document}

\noindent
 Your name:
 

\vspace*{12pt}

\begin{center}

{\large {\bf   Homework 8, September 9, 2021 (Graphics)  
}}
\end{center}
 

 
Log onto the Internet from a computer (not a telephone, unless you {\it really} have to) and go to the site \href{https://www.codabrainy.com/en/python-compiler/}.  This is the Python compiler site we used in class. You will do the homework with it. 

\noindent
1. First, try out  two simple, short,  programs. Use CTRL-C and CTRL-V to copy a program into the code box of the compiler, which says ``main.py"" at the top. Then use your mouse to click the triangle button and see what output comes out in the other big box. 

\begin{verbatim}
print ("Hello World")
\end{verbatim}

 and 
\begin{verbatim}
y = 2+2
print(y)
\end{verbatim}

If you see Hello World and 4 as output, it worked. 

 \bigskip
\noindent
2.  Go to T \& T autos via the course webpage.
 Make a bar graph of something interesting. You can do types of cars if you want, or color, or something else.  Write down 4 or more categories (blue, red, etc.) and the number of cars in each category (1,5, etc.).

Cut and paste the code below (which is the same as we used in class) into the Code box. Then change the objects and numbers to match your T\&T data.  Click on the Triangle ``run"  button, and a bar chart will appear in the output box. 

\begin{verbatim}
import matplotlib.pyplot as plt; 
 
objects = ("Python", "C++", "Java", "Perl", "Scala", "Lisp")
y_pos =  range(6)
performance = [10,8,6,4,2,1]

plt.bar(y_pos, performance  )
plt.xticks(y_pos, objects)
plt.ylabel("Number")
plt.xlabel("Type of Car")
plt.title("Different Kinds of Cars")

plt.show()
\end{verbatim}

At the bottom of the output box, below the bar graph, will appear the name ``trinket\_plot.png"" with a blue box containing a white arrow next to it. Click on the blue box, and a big version of the graph will show up in your internet browser. ``Right-click"  on your mouse on that graph, and you will see a menu with ``Save Image As"" as one of the options. Left-click on that option, and save the image to a place on the computer where you can find it later (the Downloads folder is the default in Windows, I think). Then go to the folder where the file trinket\_plot.png is, click on it to open it, and print it out. If you don"t have a printer, send the file as an email attachment to me at erasmuse61@gmail.com. 

  If this last paragraph doesn"t work, you can use a telephone to take a picture of your bar graph and email me that picture. 

 
\bigskip
\noindent
3. Now graph the price of cars versus the year they were made. Pick six cars from six different years, including at least one car from after 2015, but no cars from 2015.  Write down the year and the price. Then graph price versus year.    If a car is from earlier than 2000, treat it as a 2000 car. 
 

Cut and paste the code below (which is the same as we used in class) into the Code box. Then change the years and prices to match your T\&T data. Do not put any commas in the numbers--- computers do not like commas. 


What would your estimate be for the price of a 2015 car  based on your graph? 

Print out your line chart the same way you did with the bar chart. 

\begin{verbatim}
import matplotlib.pyplot as plt; 
 
Years = [2001,2002,2333,2114]
Prices = [100,8000,4000,80000]

plt.plot(Years, Prices,  linestyle="solid",  marker= "o")
 
plt.ylabel("Price")
plt.xlabel("Year")
plt.title("How Car Prices Change with the  Years They Were Made")
    # Set x, y  limits for the points covered by the diagram:
plt.xlim(2000, 2022) 
plt.ylim(0, 40000) 

plt.show()
  \end{verbatim}
  
  
\end{document}
 