In this assignment you will create a program that graphs mathematical functions entered by the user. Your program will prompt the user for the right side of an expression and then graph the function.

computer science

Description

Description 

In this assignment you will create a program that graphs mathematical functions entered by the user. Your program will prompt the user for the right side of an expression and then graph the function. For example, if the user enters sin(x) as input then your program will graph y = sin(x). Your program should include a loop that allows the user to graph several curves in a single run. The user will enter a blank line to indicate that no more curves will be drawn. Call the close() function from the Simple Graphics library after a blank line is entered so that the graphics window closes automatically and your program completes after the blank line is entered. Completing this assignment will require the use of loops and if statements. You do not need to write your own Python functions to complete this assignment, though you may if you would like to. If you choose to write your own functions you must use them properly, including thorough documentation. The following sections provide additional requirements and suggestions for implementing your program.


Drawing the Axes 

Your program should begin by drawing the axes. When you draw the axes, they must be oriented so that the centre of the Cartesian coordinate system (0, 0) is at the center of the screen (400, 300). Each unit in the Cartesian coordinate system must be represented by 30 pixels. As such, the visible portion of the x-axis will be from approximately -13 to +13, and the visible portion of the y-axis will be from approximately -10 to +10. Your set of axes should include a tick mark and a label for each unit (you can optionally omit the 0s at the origin for a cleaner look). While it is possible to create the axes using a (long) sequence of function calls alone, you must use loops appropriately to keep the total number of lines of code to a more reasonable amount.


Related Questions in computer science category