Skip to content

Commit

Permalink
Merge pull request #2 from sourcebots/update-lab
Browse files Browse the repository at this point in the history
Update the lab to fix some niggles
  • Loading branch information
RealOrangeOne authored Aug 6, 2023
2 parents c32ee09 + 2f30da7 commit 2d50dfd
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,30 @@ Select operation:
- Subtract (-)
- Multiply (*)
- Divide (/)
- Exponent (^)
Enter choice: ^
- Exponent (**)
Enter choice: **
Enter first number: 2
Enter second number: 3
2 ** 3 = 8
```

In Python, the "power of" operator is `**`, but to keep the operations a single character, use "^".
In Python, the "power of" operator is `**`.

### Implement squaring, where only a single number is prompted
### Implement square root, where only a single number is prompted

```
Select operation:
- Add (+)
- Subtract (-)
- Multiply (*)
- Divide (/)
- Exponent (^)
- Square (2)
Enter choice: 2
Enter first number: 3
3 ** 2 = 9
- Exponent (**)
- Square Root (sqrt)
Enter choice: sqrt
Enter first number: 9
sqrt 9 = 3
```

Bonus: Use the square symbol (`²`) for the operation and display

### If the calculation fails, show a sensible message

```
Expand All @@ -106,40 +104,40 @@ Select operation:
- Subtract (-)
- Multiply (*)
- Divide (/)
- Exponent (^)
- Square (2)
- Exponent (**)
- Square Root (sqrt)
Enter choice: /
Enter first number: 3
Enter second number: 0
3 / 0 failed: ZeroDivisionError: float division by zero
Enter choice:
```

### Ask for all inputs at once, much like a conventional calculator
### Let the user enter the entire equation at once

```
Available operations:
- Add (+)
- Subtract (-)
- Multiply (*)
- Divide (/)
- Exponent (^)
- Square (2)
- Exponent (**)
- Square (sqrt)
> 2 + 3
= 5
```

### Support "Reverse Polish" notation, where the operator comes after the numbers
### Support "[Reverse Polish](https://www-stone.ch.cam.ac.uk/documentation/rrf/rpn.html)" notation, where the operator comes after the numbers

```
Available operations:
- Add (+)
- Subtract (-)
- Multiply (*)
- Divide (/)
- Exponent (^)
- Square (2)
- Exponent (**)
- Square (sqrt)
> 2 3 +
= 5
Expand Down

0 comments on commit 2d50dfd

Please sign in to comment.