Draw the actual expression that the user inputted

Assignment Help Python Programming
Reference no: EM133013879

CPSC 231: Introduction to Computer Science

Assignment: Graphing Calculator

Collaboration

Discussing the assignment requirements with others is a reasonable thing to do, and an excellent way to learn. However, the work you hand-in must ultimately be your work. This is essential for you to benefit from the learning experience, and for the instructors and TAs to grade you fairly. Handing in work that is not your original work, but is represented as such, is plagiarism and academic misconduct. Penalties for academic misconduct are outlined in the university calendar.

Here are some tips to avoid plagiarism in your programming assignments.
1. Cite all sources of code that you hand-in that are not your original work. You can put the citation into comments in your program. For example, if you find and use code found on a web site, include a comment that says, for example:
# the following code .
Use the complete URL so that the marker can check the source.
2. Citing sources avoids accusations of plagiarism and penalties for academic misconduct. However, you may still get a low grade if you submit code that is not primarily developed by yourself. Cited material should never be used to complete core assignment specifications. You can and should verify and code you are concerned with your instructor/TA before submit.
3. Discuss and share ideas with other programmers as much as you like, but make sure that when you write your code that it is your own. A good rule of thumb is to wait 20 minutes after talking with somebody before writing your code. If you exchange code with another student, write code while discussing it with a fellow student, or copy code from another person's screen, then this code is not yours.
4. Collaborative coding is strictly prohibited. Your assignment submission must be strictly your code. Discussing anything beyond assignment requirements and ideas is a strictly forbidden form of collaboration. This includes sharing code, discussing code itself, or modelling code after another student's algorithm. You can not use (even with citation) another student's code.
5. Making your code available, even passively, for others to copy, or potentially copy, is also plagiarism.
6. We will be looking for plagiarism in all code submissions, possibly using automated software designed for the task.

Part 1: get_color:
First, complete the colour-determination function get_color. This function takes the counter tracked in the expression input loop and returns one of three different colours: red, green, or blue. You should find the remainder division operator (also called modulus) helpful here because it allows you to change an infinitely increasing integer sequence into a range of integers.

There are 3 sub-functions to this part. Each does not take a lot of code, but needs to be mathematically sound.
First, complete the coordinate conversion function calc_to_screen_coord. This function uses the parameters that the main function obtains user defined pixel coordinate system (x_origin, y_origin, ratio), along with a calculator coordinate system (????, ????) to perform the conversion. The (x_origin, y_origin) is the pixel coordinates of where (0, 0) in the calculator should be located on screen, and ratio is how many pixels are equal to 1 in the calculator coordinate system. calc_to_screen_coord returns the (x, y) coordinate as a pixel screen coordinate (screen_x, screen_y) following the math described previously in the example. Use this function in your code any time you want to convert and draw a calculator location. You will lose marks if you duplicate the math/code functionality of this function somewhere else instead of using this function designed for that purpose.

Part 4: draw_expression

Finally, you will draw the actual expression that the user inputted. Python can evaluate a string using its eval function. Your code does not need to be capable of anything more than the eval function can do. For example, the following 3-line program is a simple calculator that works for input like "1+1":
expression = input("Enter an arithmetic expression: ") result = eval(expression)
print("The result of that expression is", result)

Python is also able to evaluate expressions which include a single variable x. The implementation of this function can be surprising at first. When the eval function is called, it uses whatever value is stored in the variable called x to evaluate the given expression.
To make things easier a calc function has already been completed that will take an expression and an x and return the y value. (Ex. y = calc(expression, x)). You will use the eval() method to do all of your math for you for the calculator. You will notice that we have the import at the top from math import * which allows eval() to use things like cos/sin.
As a result, your program will need to include a variable named x, which represents the x coordinate in the calculator coordinate system. The value of x will change in a loop. Call calc inside of the loop so that you can compute the value of y for many different x values. For example, the following program evaluates an expression that includes the variable x for each integer value of x from 0 up to and including 5:
expr = input("Enter an arithmetic expression: ") for x in range(0, 6):
y = calc(expr, x)
print("When x is", x, "the value of the expression is", y)

You can use a similar technique to compute the y position of the curve for many different values of x. Those x and y values are what you need to draw short lines with turtle that will visually emulate the expression's lines and possible curvature.

You cannot complete this function correctly unless the previous functions are operational. In particular, it will be useful to use calc_minmax_x to determine which values of x you want to draw a line between. You will need to pick a delta that makes the curve smooth. A delta of 0.1 or 0.2 should provide sufficient smoothness. Note that, once you are using floating point values for your steps size, you will be unable to use a for-range() loop to loop through them but instead should use a while loop.

Attachment:- Graphing Calculator.rar

Reference no: EM133013879

Questions Cloud

Discuss the disadvantages of chosen strategies : Besides downsizing, discuss three other strategies local retailers could implement to address labour surplus in light of a temporary decline of sales at their m
What became the affordable care act : What was the basis or model for what became the Affordable Care Act?
Determine the value of ending inventory : Determine the value of ending inventory and materials used under the following methods: Sept. 1 Beginning balance 300 P12 P3,600
Write an essay on business strategies and hrm : Write an essay on business strategies and HRM
Draw the actual expression that the user inputted : Draw the actual expression that the user inputted. Python can evaluate a string using its eval function. Your code does not need to be capable of anything more
How many tubs should EBP produce : The glass and ceramic sinks and tubs require the use of specialized molding equipment. How many tubs should EBP produce
Split between the eastern and western churcches : What caused the split between the Eastern and Western Churcches?
Common employment visas for non-immigrant workers : The global economy necessitates the need for work visas in the United States. What are the most common employment visas for non-immigrant workers?
Calculate the estimated total cash receipts : ABC Ltd is a retailer of ladies' fashion and has the following historical collection pattern for its credit sales: Calculate the estimated total cash receipts

Reviews

Write a Review

Python Programming Questions & Answers

  Creation of a program that will assemble dna chains

The aim of this assignment is the creation of a program that will assemble DNA chains, using the fragments given

  Make a gui program that calculates the hypotenuse

Make a GUI program that calculates the hypotenuse of a right triangle after the user enters the lengths of the two short sides and clicks the Calculate button.

  Identify best practices in data collection

Identify best practices in data collection and storage, including data security and privacy principles; and Effectively report and communicate findings

  Implementing a join function for two linked list

Implementing a join function for two linked list. You are required to use python - Write a code to test your implementation for various P and q

  Plot the optimal solution on the x-axis

CSE 410 - AI: Homework - Plot the optimal solution on the X-axis and the two heuristics on the Y axis. Describe two heuristics for the slide problem

  Write a program that calculates the occupancy rate for hotel

Write a program that calculates the occupancy rate for a hotel. The program should start by asking the user how many floors the hotel has.

  Asks the user to enter a stores sales for each day of week

Write a program that asks the user to enter a store's sales for each day of the week. The amounts should be stored in a list.

  Most popular name would be the one with the biggest number

the program will ask you to insert the year that the user is interested in, then ask the gender that the user is interested in, and print out the most popular names corresponding to the year and gender. FYI, the number on the right represents how man..

  ITS320 Basic Programming Question - Create a program

ITS320 Basic Programming assignment help and assessment help, Colorado State University - Create a program that will calculate the weekly average tax.

  Create functions and call those functions to display outputs

Create additional functions and call those functions to display outputs. Write code for each function calling functions from step one above to display outputs.

  Describe the original data for the city you are observing

Describe the original data for the city you are observing. Regression Analysis Hypothesis testing. Explain the hypothesis and the result by graph.

  Write a simple pyhone program to encrypt and decrypt

Write a simple pyhone program to encrypt and decrypt a file using AES algorithm (key value: " security").

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd