mirror of
https://github.com/venomade/calculator.git
synced 2026-11-16 18:27:39 +00:00
Add addition and subtraction functions
This commit is contained in:
commit
31f4fa6c31
3 files changed
+32
No files matched your search
@@ -0,0 +1,15 @@
|
|||||||
|
# Calculator
|
||||||
|
A simple calculator application for the Terminal, built step by step in SCCM4910.
|
||||||
|
It will run on `Python 3` via the `calculator.py` script.
|
||||||
|
|
||||||
|
## What It Will Do
|
||||||
|
Add, subtract, multiply and divide two numbers; display the result.
|
||||||
|
|
||||||
|
## How to Run It
|
||||||
|
From Week 3: `python3 calculator.py`
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
- First enter a number
|
||||||
|
- Then enter an operator (`+`,`-`,`*` or `/`)
|
||||||
|
- Lastly enter a second number
|
||||||
|
- Read the result, printed as `Result: ` followed by the answer.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Requirements
|
||||||
|
1. Addition
|
||||||
|
2. Subtraction
|
||||||
|
3. Multiplication
|
||||||
|
4. Division
|
||||||
|
5. Displaying a result
|
||||||
|
6. Run in a standard terminal
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
Input: `12 / 0`
|
||||||
|
Output: `Runtime error: Divide by zero`
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
def add(a, b):
|
||||||
|
return a + b
|
||||||
|
|
||||||
|
def subtract(a , b):
|
||||||
|
return a - b
|
||||||
Reference in new issue
Block a user