Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

=+ (d) When is there convergence is the sense of (4.6)?

Answered: 1 week ago