Code Monkey home page Code Monkey logo

calculator's Introduction

Fork & Clone

Repeat the same steps in the previous task to fork and clone this repository into your python directory: this repository.


Task

In this task you'll be creating a calculator. You'll ask the user for 3 inputs: two numbers, and a mathematical operation. Then you will print the result of the operation to the user.

Example:

Enter the first number: 4
Enter the second number: 6
Choose the operation (+, -, /, *): *
The answer is 24

In this example, the user inputs the first number 4, the second number 6, and the operation *.

Steps:

  1. Ask the user for 3 inputs: two numbers and an operation.
  2. Validate user input.
    • If the user's inputs were not numbers, print to the user that the numbers were invalid. For example if the user enters letters instead of numbers. (Hint: String methods can help.)
    • If the operation the user entered was not any of the options (+, -, *, or /), print to the user that the operation is not valid.
  3. If the user entered valid numbers and a valid operation, perform the calculation and print it to the user.
  4. Run the tests and make sure they pass by running the following command on macOS python3 test.py (python test.py on Windows)
  5. Add and commit calculator.py, then push to Github.

calculator's People

Contributors

abdullah-alkhareji avatar anonymouszma avatar lailalelouch avatar malthunayan avatar smokeme avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.