The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Write a program (Python script) named mycalc.py, which implements a simple calculator using python. As you approach this assignment try to visualize how you would use a calculator. Typically you would enter a number into the calculator, next you would select an operation to perform (add, subtract, multiply, divide), next you would enter a second number, finally you would press the equals sign to begin the calculation. The following examples illustrate both a flowchart and the pseudo code that outlines how to solve the calculator problem. They provide a conceptual model (a conceptual model is something that attempts to describe how something works) of the calculator, define how the program must flow from one task or statement to the next, and describes the functionality that the program will provide.
Â
You should submit a script file (.py or .txt) and an output file (.doc or .pdf). Don’t forget to use comments and readable variable names.
Â
Pseudo Code for Python Calculator
Â
Prompt for first number
Read first number and store in variable
Display operations (1-add, 2-subtract, 3-multiply, 4-divide)
Prompt for operation
Read operation and store in variable
Prompt for second number
Read second number and store in variable
If operation is equal to 1 (add)
  Then
      Add first number to second number and store result in variable
Otherwise if operation is equal to 2 (subtract)
  Then
      Subtract second number from first number and store result in a variable
Otherwise if operation is equal to 3 (multiply)
  Then
     Multiply first number with second number and store result in a variable Other wise if operation is equal to 4 (divide)
  Then
     Divide first number by the second number and store result in a variable
Otherwise exit program
  Display the result stored in the variable
Exit the program
Â
Flowchart for Python Calculator
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly