Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Python)You will write a calculator program in Python. The operations your program must compute include, addition (+), subtraction(-), multiplication(*), division(/), integer division (//) and power(**)

(Python)You will write a calculator program in Python. The operations your program must compute include, addition (+), subtraction(-), multiplication(*), division(/), integer division (//) and power(**) operation. Given two numbers and the desired operation symbol shown in the previous sentence. Your program must match the output exactly to get full points. See the examples below. The program must exit right away if the operation is not valid. You do not need to check if the numbers entered are valid. You program will ask whether to stop and if the user enters y the program will exit, otherwise if the user enters n the program will continue.

Steps

  1. Create a file named calculator.py
  2. Inside the file create a Python 3 function called calculator
  3. The function should take three parameters in this order: number1, number2, operator
  4. The calculator function should print the result of the operation but if the operation was invalid return false
  5. Create another function called input_output, which will take input from the user and call the calculator function.
    • The function should also ask if the user wishes to continue

Example

Enter the first number: 10 Enter the second number: 2 Enter the operation: + 12.0

Do you wish to exit? n Enter the first number: 12 Enter the second number: 4.2 Enter the operation: * 50.400000000000006

Do you wish to exit? n Enter the first number: 10 Enter the second number: 2 Enter the operation: ** 100.0

Do you wish to exit? y >>>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions