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

This is an example given on pages 97-98 of Python Programming, 2nd edition by Jo

ID: 3909075 • Letter: T

Question

This is an example given on pages 97-98 of Python Programming, 2nd edition by John Zelle. I am attempting to make a bar chart that shows the growth over 10 years of an investment. For some reason I am getting a syntax error when I use "Text" the second time when attempting to create the labels on the left edge of the graph. I am not sure what is going on here. Even the solution given for excersise 6 (a more intensive version of the problem above) has the same exact code for creating the labels. Please help, thank you.

futval-graph.py - CAUsersADocuments PTY-ED futval-graph.py (3.6.5) File Edit Format Run Options Window Help from graphics import * def main ): # Introduction print ("This program plots the growth of a 10 year investment.") # Get principal and interest rate principaleval (input ("Enter the initial principal:)) apreval (input (Enter the annualized interest rate: ")) # Create a graphics window with labels on left edge win GraphWin("Investmant Growth Chart", 320, 240) win.setBackground ("white") Text (Point (20,230,0.0K') .draw (win) Text (Point (20,180, '2.5K').draw (win) Text (Point (20,130,5.0K') .draw (win) Text (Point (20,80, 7.5K).draw (win) Text (Point (20,30, 10.0K").draw (win) SyntaxError invalid syntax OK # Draw bar for initial principal height-principal 0.02 bar Rectangle (Point (40,230), Point (65, 230-height)) bar.setFill("green") bar.setWidth (2) bar.draw (win) # Draw bars for successive years for year in range (1,11): # Calculate value for the next year principal principal * (1 + apr) # Draw bar for this value x11 year * 25 + 40 height principal 0.02 bar Rectangle (Point (xll,230), Point (xll+25, 230-height)) bar.setFill("green") bar.setWidth (2) bar.draw (win) input ("Press to quit") win.close ) main ()

Explanation / Answer

There is a syntax error:

Text(Point(20, 230), '0.0K').draw(win)

Text(Point(20, 180), '2.5K').draw(win)

Text(Point(20, 130), '2.5K').draw(win)

Text(Point(20, 80), '2.5K').draw(win)

Text(Point(20, 30), '2.5K').draw(win)

check once, if you still getting error, please give me comment...

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