Question: Create a graphics window program that shows off a student's scores. Import the 5 scores from a file. The file will have exactly 5 test

Create a graphics window program that shows off a student's scores. Import the 5 scores from a file. The file will have exactly 5 test scores (from 0-100). Those scores will appear in a window as a series of bars. You will call a function to draw the bars in the window. Each bar will be a different color, the score will appear inside at the end of the bar. There will a scale at the bottom of 0-100.

I'm having a hard time defining two functions, creating a color for each bar, integrating loops, and keeping the names and grades inside bars right and left side. This code is a mess!!

What I have so far...

from graphics import*

# main function

def main(): #Locate file. examFile = ('ExamGrades.txt')

file = open(examFile, 'r')

grade = file.readlines()

#Finds the starting and ending value of pupils. pupil = int(data[0]) #Create graphics window. win = GraphWin("5 Test Scores Growth Chart",450,350) #Set background. win.setBackground("Khaki") #Each pupil has its own start value. pup1 = ('red') pup2 = ('blue') pup3 = ('purple') pup4 = ('green') pup5 = ('yellow')

#Loop starts. for x in grade: pup1 += [int(x.split()[4])] pup2 += [int(x.split()[3])] pup3 += [int(x.split()[2])] pup4 += [int(x.split()[1])] pup5 += [(x.split()[0])]

#Have each color represent pup1-5. rect = Rectangle(Point(, ), Point(150 + 3 * m[0], 350/(pupil))) rect.setFill(pup1,pup2,pup3,pup4,pup5) rect.draw(win) title = Text(Point(70, 230/pupil + 10), pup1[4]) title.setSize(20) title.draw(win)

for i in range(pupil-1): rect = Rectangle(Point(140, rect.getP1().getY() + 460/st), Point(150 + 3 * pup1[i + 1], rect.getP2().getY() + 350/pupil)) rect.setFill(pup1,pup2,pup3,pup4,pup5) rect.draw(wnbr) name = Text(Point(70, (rect.getP1().getY() + rect.getP2().getY())/2) , pup2[i + 1]) name.setStyle('bold') name.setSize(10) name.draw(win)

win.getMouse() win.close()

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!