Skip to content

Commit 20f8d21

Browse files
Merge pull request freeCodeCamp#17 from bgroveben/beginner_math
Beginner Math Challenges added to challenge directory. Not added to challenges.json yet.
2 parents 50eb7b6 + 0af5f1b commit 20f8d21

Some content is hidden

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

54 files changed

+500
-0
lines changed

challenges/4.1.Addition/lesson.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Python Addition
2+
3+
In Python, an integer (int) is one of 3 distinct numeric types.
4+
- https://docs.python.org/3.6/library/stdtypes.html#numeric-types-int-float-complex
5+
6+
In this exercise, you will add two integers using the plus (+) operator.
7+
- https://docs.python.org/3.6/library/operator.html#operator.add
8+
- https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
9+
```
10+
>>> 2 + 2
11+
4
12+
```
13+
14+
**_Instructions:_**
15+
**Change the 0 so that total will equal 20.**
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+
total = 10 + 0
4+
5+
### Modify the code above ###
6+
7+
print(total)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import unittest
2+
import lesson_code
3+
4+
class AdditionTests(unittest.TestCase):
5+
def test_main(self):
6+
total = lesson_code.total
7+
self.assertIsInstance(total, int)
8+
self.assertEqual(total, 20)
9+
10+
# To run the tests from the console:
11+
# Make sure that you are in the '4.1.Addition' directory
12+
# ⇒ 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 Subtraction
2+
3+
In Python, an integer (int) is one of 3 distinct numeric types.
4+
- https://docs.python.org/3.6/library/stdtypes.html#numeric-types-int-float-complex
5+
6+
In this exercise, you will subtract two integers using the minus (-) operator.
7+
- https://docs.python.org/3.6/library/operator.html#operator.sub
8+
- https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
9+
10+
```
11+
>>> 4 - 2
12+
2
13+
```
14+
15+
**_Instructions:_**
16+
**Change the 0 so that total will equal 10.**
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+
total = 20 - 0
4+
5+
### Modify the code above ###
6+
7+
print(total)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import unittest
2+
import lesson_code
3+
4+
class SubtractionTests(unittest.TestCase):
5+
def test_main(self):
6+
total = lesson_code.total
7+
self.assertIsInstance(total, int)
8+
self.assertEqual(total, 10)
9+
10+
# To run the tests from the console:
11+
# Make sure that you are in the '4.2.Subtraction' directory
12+
# ⇒ 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)

0 commit comments

Comments
 (0)