I have an assignment that I'm working on and am having trouble. Not too familiar with graphics. Any help/guidance would be much appreciated to see if what I have so far is okay and what I should do for the loop part. I will post assignment details and what i have so far.

You are given a dictionary named Stats, which is part of the template provided for this assignment. The template can be found at

http://dbis.ucdavis.edu/courses/ECS10-WQ08/Python/hw6-template.py

The dictionary manages information about the number of students of a particular major enrolled in a class. The dictionary looks as follows:

Stats = { "ECSE":8, "LCSI":6, "ECOM":13, "ABIT":4, "ACSM":3, "AEXH":2, \

"AEXP":9, "BULS":6, "APME":8, "BBMB":3, "EBCL":2, \

"EEEL":9, "LDES":4, "LMAT":3, "LPHY":3, "LPSC":4, "LUHU":4, \

"LUPS":5, "LUSS":2 }

Each pair consists of a string (major code) and a number, which tells you how many students of that major are enrolled in the class. For example, there are 8 students with the major ECSE and 4 students with the major LPSC.

Write a Python program that displays the information contained in the dictionary in the form of a chart analog to the one produced by the program graph01.py presented in class on 3/4/08. Your program should construct a chart like a bar graph, with major name above each bar on the graph.

Approach: Download the following two files in your ECS 10 folder: graphics22.py and hw6-template.py. Both files can be obtained from the assignment Web page. The template provides you with some kind of structure for the program. Take a look at the template! Next, you have to determine an appropriate size and coordinates for your window. For this, you can use the information about how many entries the dictionary has. Once this is in place, you have to

retrieve pairs from the dictionary, pair-by-pair. Note that you can’t do this directly on the dictionary, but you have to convert it to a list of pairs. Then, for each pair, you get the major code and count, print the major code (as string) and the count is used to determine the height of the line.

```
from random import shuffle
from graphics22 import *
def main(n):
win = GraphWin("This is a 600 x 400 graph window",600,400)
win.setBackground('white')
# Let's define lower left and upper right for the coord.system
x_min = -1.0 # make sure (0,0) is on the screen
y_min = -1.0 # make sure (0,0) is on the screen
x_max = n + 1.0 # give a little extra horizontal space
y_max = n * 1.1 # give 10% extra vertical space
# after setCoords all coordinates will be transformed!
win.setCoords(x_min, y_min, x_max, y_max)
swapDictionary = {}
for key, val in Stats.items():
swapDictionary[val] = key
for i in range(n):
x = i
y = [i]
t = Text(Point(x,y+1), str(y))
t.draw(win)
line = Line(Point(x,0), Point(x,y))
line.setFill("blue")
line.draw(win)
# wait for final mouse click!
win.getMouse()
win.close()
print "Done"
main(20)
```