
In this assignment you will write a computer program from scratch using the Python
Objectives
- Write a simple Python program that performs arithmetic operations based on the user input
Stage 1: A simple calculator
Your calculator should provide the following arithmetic and control operations.
- Arithmetic Operations
- Addition (+) add(a,b)
- Subtraction (-) subtract(a,b)
- Multiplication (*) multiply(a,b)
- Division (/) divide(a,b)
- Power (^) power(a,b)
- Remainder (%) remainder(a,b)
- Control Operations
- Terminate (#)
- Reset ($)
Write a function select_op(choice) to select the appropriate mathematics function based on the users selection.
The behavior of the program should be as follows:
- The program should ask the user to specify the desired operation (addition/subtraction/multiplication/division/power/remainder/terminate/reset). You can start with the code already given in the answer box. Also, check the example test cases given below.
- Once the user inputs/selects an arithmetic operation, the program should ask the user to enter the two operands one by one, separated by Enter key. If the user made a mistake while entering the parameters, he can return to main menu by pressing ‘$’ key at the end of the input string, followed by the Enter key
- Calculate the result and display the result. Inputs need to be processed as floating point values, even thought the values entered are integers. Example: 2.0 + 4.0 = 6.0
- Return to main menu after displaying the calculation result
- All possible errors (at input or at generation of result) should be handled by the program
-
Examples:
- Anything other than a number as operand input
- Anything other than +, -, *, /, ^ and % as arithmetic operators
- Anything other than # and $ as control operators
- Division by zero
-
The program should keep running until it is stopped by the user (using the terminate command #)
Task 1: Get user input
-
Section 1:
- Input Arithmetic operation
- Reset or Termination
-
Section 2:
- Input first operand
- Input second operand
- Reset or Termination
Task 2: Implement functions that performs given arithmetic operation on the given operands and produces the result
- Arithmetic operation and the two operands as parameters
- Return the result of the arithmetic operation
Task 3: Call the calculation function by passing user input to select_op(choice) and display the result from within the select_op(choice) function
Here are some of the messages you might want to display to the users at certain occasions. Copy and paste them as necessary in your code in appropriate situations to help with auto-grading. If there is any differences between the output of your code and the expected output, it will be displayed once you click the "Check" button. You can click on "Show differences" button to highlight the difference between outputs. This will be helpful for you to change your code to match the expected output.
"Enter first number: "
"Enter second number: "
"Not a valid number,please enter again"
"Unrecognized operation"
"Something Went Wrong"
Answer should be according to the below template


Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- python multiple choice Code Example 4-1 def get_username(first, last): s = first + "." + last return s.lower() def main(): first_name = input("Enter your first name: ") last_name = input("Enter your last name: ") username = get_username(first_name, last_name) print("Your username is: " + username) main() 5. Refer to Code Example 4-1: What is the scope of the variable named s ?a. globalb. localc. global in main() but local in get_username()d. local in main() but global in get_username()arrow_forwardDon't give me AI generated answer or plagiarised answer.arrow_forwardWrite a python code that does the following: - Asks student to enter his name - Ask them to enter their marks for 4 different modules. (Note: these marks should be out of 100 for each module) - Based on the average of the 4 different modules, the student should get the grade that they have achieved at that level. - The grades should follow the following trend - greater than or equal to 90 = A - from 80 to 89 inclusive = B - from 70 to 79 inclusive = C - from 60 to 69 inclusive = D - from 50 to 59 inclusive = E - below 50 = Farrow_forward
- program must include a processing loop that allows multiple sets of data to be processed and the program should be terminated when there is no more data to process Develop a program in python that allows the user to enter a start value of 1 to 4, a stop value of 5 to 12 and a multiplier of 2 to 8. The program must display a multiplication table with results using these values. For example, if the user enters a start value of 3, a stop value of 7 and a multiplier value of 3, the table should be displayed as follows: Multiplication Table 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 Run the program with the following values: Start Stop Multiplier 2 10 4 4 12 6arrow_forwardNote: Please do this in Python 3arrow_forwardCan you use Python programming language to to this question? Thanksarrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





