new HW4
Consider the following MySQL table in a database called `classes`
Table name: `grades`
+----------+--------+--------+--------+-------+
| Name | Test 1 | Test 2 | Test 3 | Final |
+----------+--------+--------+--------+-------+
| Gallant | 100 | 88 | 91 | 97 |
+----------+--------+--------+--------+-------+
| Goofus | 63 | 20 | 38 | 0 |
+----------+--------+--------+--------+-------+
| and so on |
| |
| . |
| . |
| . |
| |
+----------+--------+--------+--------+-------+
Write a function makeGraph() that takes no inputs in a file called hw4.py which will connect to this database and generate a bar graph representation of the grades.
Use the addText function to write the students names down the left side of the picture and addRectFilled function to create the bar graph with the length corresponding to that student's overall grade. To compute the final grade, each test is worth 20% and and the final is worth 40%.
The students must be sorted in some way, either by name or grade, increasing or decreasing.
To connect to the database, add the following function to your hw4.py
def con():
#it's all you, Blair!
To connect to the database use:
connection = con()
and to receive query results, use:
results = connection.query("put SQL query here") #need to double check this
Extra credit opportunities (3 points each):
- Make the bars of the graph color-coded corresponding to the studet's grade
- Compute the final grade for each student using SQL, rather than python code.
- Make the bars and the text vertical
Link to this Page
- asdf last edited on 21 June 2006 at 2:24 pm by mississippi-lnx.cc.gatech.edu