Git Product home page Git Product logo

itp-simple-calculator's Introduction

Simple Calculator

Welcome to your first big project! The goal is to make a simple calculator using everything you've learned up to this point!

Your job is to implement the code under calculator.py; note that we've left only placeholders for the functions. Your job is to write the body of those functions.

Step 1:

  • Add
  • Subtract
  • Multiply

We've set up 3 functions here that you need to finish. These are fairly straight-forward and shouldn't give you too much trouble, think back to your lesson on operators!

To run tests, use these commands in the command line:
# For the add() function
$ py.test test_add.py

# For the subtract() function
$ py.test test_subtract.py

# For the mulitply() function
$ py.test test_multiply.py

Step 2

  • Divide

You'll notice here that divide is the only function that has two tests for it - that's because you'll need to program some exceptional behavior in case the user tries to divide by 0!

If 0 is passed as a denominator when using this function, instead of an integer, return a string warning the user not to divide by 0. You can chose any message you want, for example return "Invalid value for denominator, cant't divide by 0!"

$ py.test test_divide.py

Step 3

  • Square
  • Power
  • Square Root

Rounding out the last three tests are functions dealing with powers. They can be kind of tricky (especially finding the square root!) but you shouldn't have any problem if you review your lesson on operators.

$ py.test test_square.py
$ py.test test_power.py
$ py.test test_sqrt.py

itp-simple-calculator's People

Contributors

santiagobasulto avatar matiascaputti avatar jwinf843 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.