Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help on python http://mcsp.wartburg.edu/zelle/python/graphics.py You need t

ID: 3912828 • Letter: N

Question

Need help on python

http://mcsp.wartburg.edu/zelle/python/graphics.py

You need this libary.

this is my code. I dont get the int value from entry

code:

from graphics import *
import math
# TODO #1:
def q3():
# Build the Dartboard
win = GraphWin("Chart",300,300)
xLine=Line(Point(50,250),Point(250,250))
xLine.draw(win)
yLine=Line(Point(50,250),Point(50,50))
yLine.draw(win)
message = Text(Point(30,200),"25")
message.setSize(10)
message.draw(win)
message = Text(Point(30,150),"50")
message.setSize(10)
message.draw(win)
message = Text(Point(30,100),"75")
message.setSize(10)
message.draw(win)
message = Text(Point(30,50),"100")
message.setSize(10)
message.draw(win)

student4 = Entry(Point(270,50),4)
student4.draw(win)
text1=student4.getText()
text2=int(text1)
message = Text(Point(270,27),"Student4")
message.setSize(10)
message.draw(win)

student3 = Entry(Point(270,100),4)
student3.draw(win)
message = Text(Point(270,77),"Student3")
message.setSize(10)
message.draw(win)

student2 = Entry(Point(270,150),4)
student2.draw(win)
message = Text(Point(270,127),"Student2")
message.setSize(10)
message.draw(win)

student1 = Entry(Point(270,200),4)
student1.draw(win )
message = Text(Point(270,177),"Student1")
message.setSize(10)
message.draw(win)

rect1= Rectangle(Point(55,250),Point(80,(text2)*2)-250)
rect1.draw(win)
rect1.setFill("black")
rect2= Rectangle(Point(85,250),Point(110,2))
rect2.draw(win)
rect3= Rectangle(Point(115,250),Point(140,*2))
rect3.draw(win)
rect4= Rectangle(Point(145,250),Point(170,*2))
rect4.draw(win)
q3()

315 uestion 3: Write a function named q30 that creates a 300 x 300 Graphics window, draws a line for the X axis and a line for the Y axis with Text labels identifying increments of 25, 50, 75 and 100 as seen below Char 100 Student4On the right side of the Graphics window the q30 function should draw four Entry boxes with default values of '0' and Text labels as shown in the image on the left. These will allow the user to input student scores. In the lower right hand corner, draw two color filled boxes that will function as 'buttons' with labels as shown. 75 Student3 50 25 Studentt Once values are entered, the user can click on either the "Graphlt" or the "Quit" buttons Quit If the user clicks on the "Graphlt!" button, the function Chart should create Rectangles with the fill colors of red, blue, green and purple. Their scale should be based on the values in the Entry boxes as shown here 100 74.3 75 When the user clicks on the "Quit" button, the function should close the Graphics window and end. 50 62.5 25 Student1 A mouse click anywhere else in the Graphics window would have no effect. Quit

Explanation / Answer

If i am correct you have an error saying

invalid literal for int() with base 10: ''

if means that u r converting an empty string to number which is not possible, since the error.

and the getText in graphics.py module is

def getText(self):
        return self.config["text"]

which immediately takes the input(which is null(by default) since we haven given any input yet) so set so default value then change the value .

since text2 is null and not a number

rect1= Rectangle(Point(55,250),Point(80,((text2*2)-250)))

this line will be in error since rectangle takes only numbers(points)

If you find yourself in another error just open graphics.py and check the fuction which is giving an error

by reviewing the modules you can improve your code readability and understanding.

Hope this helped !!!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote