Skip to content

Commit 906957e

Browse files
committed
Finish adding beginner math challenges
1 parent d3578d9 commit 906957e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+435
-3
lines changed

challenges/4.1.Addition/lesson_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ def test_main(self):
88
self.assertEqual(total, 20)
99

1010
# To run the tests from the console:
11-
# Make sure that you are in the 'addition' directory
11+
# Make sure that you are in the '4.1.Addition' directory
1212
# ⇒ python3 -m unittest lesson_tests

challenges/4.2.Subtraction/lesson.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ In Python, an integer (int) is one of 3 distinct numeric types.
66
In this exercise, you will subtract two integers using the minus (-) operator.
77
- https://docs.python.org/3.6/library/operator.html#operator.sub
88
- https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
9+
910
```
1011
>>> 4 - 2
1112
2
1213
```
1314

1415
**_Instructions:_**
15-
**Change the 0 so that total will equal 10.**
16+
**Change the 0 so that total will equal 10.**

challenges/4.2.Subtraction/lesson_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ def test_main(self):
88
self.assertEqual(total, 10)
99

1010
# To run the tests from the console:
11-
# Make sure that you are in the 'subtraction' directory
11+
# Make sure that you are in the '4.2.Subtraction' directory
1212
# ⇒ python3 -m unittest lesson_tests
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Python Multiplication
2+
3+
Python uses the asterisk (\*) operator for multiplication.
4+
If any or all of the numbers being multiplied are floating point numbers, then the product will be a float.
5+
- https://docs.python.org/3/library/operator.html#operator.mul
6+
- https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
7+
- https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
8+
```
9+
>>> 3 * 3
10+
9
11+
>>> 4.0 * 4
12+
16.0
13+
```
14+
15+
**_Instructions:_**
16+
**Change the 0 so that product will equal 80.**
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Modify the code below ###
2+
3+
product = 8 * 0
4+
5+
### Modify the code above ###
6+
7+
print(product)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import unittest
2+
import lesson_code
3+
4+
class MultiplicationTests(unittest.TestCase):
5+
def test_main(self):
6+
product = lesson_code.product
7+
self.assertIsInstance(product, int)
8+
self.assertEqual(product, 80)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Python Float Division
2+
3+
Python 3 distinguishes between integer (floor) division and float (true) division.
4+
Python uses a single forward slash (/) operator for float division.
5+
When using float division, even if the quotient (result) is a whole number like 1 or 2, a floating point number will be returned instead of an int.
6+
- https://docs.python.org/3/library/operator.html#operator.truediv
7+
- https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
8+
- https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
9+
```
10+
>>> 1 / 1
11+
1.0
12+
>>> 3 / 2
13+
1.5
14+
```
15+
16+
**_Instructions:_**
17+
**When you run the existing code, the variable named quotient will have a value of 1.0**
18+
**Change the the second number (the denominator) so that quotient has a value of 2.5**
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Modify the code below ###
2+
3+
quotient = 5 / 5
4+
5+
### Modify the code above ###
6+
7+
print(quotient)

0 commit comments

Comments
 (0)