mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-27 10:00:40 -04:00
fix(curriculum): use correct modulo/reminder wording (#66096)
Co-authored-by: Aditya Singh <anshul8303858511@gmail.com>
This commit is contained in:
@@ -142,8 +142,8 @@ my_float_2 = 12.0
|
||||
mod_ints = my_int_1 % my_int_2
|
||||
mod_floats = my_float_2 % my_float_1
|
||||
|
||||
print('Integer Modulus:', mod_ints) # Integer Modulus: 8
|
||||
print('Float Modulus:', mod_floats) # Float Modulus: 1.1999999999999993
|
||||
print('Integer Modulo:', mod_ints) # Integer Modulo: 8
|
||||
print('Float Modulo:', mod_floats) # Float Modulo: 1.1999999999999993
|
||||
```
|
||||
|
||||
Floor division divides two numbers and returns the greatest integer less than or equal to the result. This is done with the double forward slash operator (`//`):
|
||||
|
||||
@@ -84,7 +84,7 @@ total_pages //= 5
|
||||
print(total_pages) # 4
|
||||
```
|
||||
|
||||
- The modulus assignment operator (`%=`) computes the remainder of the left variable divided by the right and stores it back in the left variable:
|
||||
- The modulo assignment operator (`%=`) computes the remainder of the left variable divided by the right and stores it back in the left variable:
|
||||
|
||||
|
||||
```python
|
||||
|
||||
@@ -22,7 +22,7 @@ console.log(evenNumbers); // [2, 4, 6, 8, 10]
|
||||
|
||||
:::
|
||||
|
||||
In this example, the `filter` method applies a callback function to each element of the `numbers` array. The callback checks whether each number is even using the modulo operator (`%`).
|
||||
In this example, the `filter` method applies a callback function to each element of the `numbers` array. The callback checks whether each number is even using the remainder operator (`%`).
|
||||
|
||||
If the number is even, the function returns `true`, and that number is included in the new array. If it's odd, the function returns `false`, and that number is excluded.
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ Think about how to combine mathematical operations and reassignment.
|
||||
|
||||
## --text--
|
||||
|
||||
What does the `modulus` assignment operator (`%=`) do in JavaScript?
|
||||
What does the remainder assignment operator (`%=`) do in JavaScript?
|
||||
|
||||
## --answers--
|
||||
|
||||
@@ -158,7 +158,7 @@ Divides a variable by the specified number and assigns the quotient to the varia
|
||||
|
||||
### --feedback--
|
||||
|
||||
Think about how the `modulus` operator works in a normal arithmetic operation.
|
||||
Think about how the remainder operator works in a normal arithmetic operation.
|
||||
|
||||
---
|
||||
|
||||
@@ -166,7 +166,7 @@ Multiplies a variable by the specified number and assigns the product to the var
|
||||
|
||||
### --feedback--
|
||||
|
||||
Think about how the `modulus` operator works in a normal arithmetic operation.
|
||||
Think about how the remainder operator works in a normal arithmetic operation.
|
||||
|
||||
---
|
||||
|
||||
@@ -178,7 +178,7 @@ Adds the remainder of a division to the variable.
|
||||
|
||||
### --feedback--
|
||||
|
||||
Think about how the `modulus` operator works in a normal arithmetic operation.
|
||||
Think about how the remainder operator works in a normal arithmetic operation.
|
||||
|
||||
## --video-solution--
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ dashedName: review-bash-scripting
|
||||
- `-` (subtraction): Subtract second number from first
|
||||
- `*` (multiplication): Multiply two numbers
|
||||
- `/` (division): Divide first number by second (integer division)
|
||||
- `%` (modulus): Remainder after division
|
||||
- `%` (modulo): Remainder after division
|
||||
- `**` (exponentiation): Raise first number to power of second
|
||||
|
||||
```bash
|
||||
@@ -277,7 +277,7 @@ dashedName: review-bash-scripting
|
||||
- `-=` (subtract and assign): Subtract value from variable
|
||||
- `*=` (multiply and assign): Multiply variable by value
|
||||
- `/=` (divide and assign): Divide variable by value
|
||||
- `%=` (modulus and assign): Set variable to remainder
|
||||
- `%=` (modulo and assign): Set variable to remainder
|
||||
|
||||
```bash
|
||||
(( counter = 0 ))
|
||||
@@ -558,7 +558,7 @@ for server in "${servers[@]}"
|
||||
|
||||
- **Random numbers**: Generate random values using the `$RANDOM` variable.
|
||||
- `$RANDOM` generates numbers between 0 and 32767
|
||||
- Use modulus operator to limit range: `$RANDOM % 75`
|
||||
- Use modulo operator to limit range: `$RANDOM % 75`
|
||||
- Add 1 to avoid zero: `$(( RANDOM % 75 + 1 ))`
|
||||
- Must use `$(( ... ))` syntax for calculations with `$RANDOM`
|
||||
|
||||
@@ -580,7 +580,7 @@ for server in "${servers[@]}"
|
||||
echo ${RESPONSES[$N]}
|
||||
```
|
||||
|
||||
- **Modulus operator**: Use `%` to get the remainder of division operations.
|
||||
- **Modulo operator**: Use `%` to get the remainder of division operations.
|
||||
- Essential for limiting random number ranges
|
||||
- Works with `$RANDOM` to create bounded random values
|
||||
- `RANDOM % n` gives numbers from 0 to n-1
|
||||
|
||||
@@ -417,7 +417,7 @@ float_1 = 5.4
|
||||
print(int_1 + float_1) # 61.4
|
||||
```
|
||||
|
||||
- **Modulus Operator (`%`)**: This returns the remainder when a number is divided by another number:
|
||||
- **Modulo Operator (`%`)**: This returns the remainder when a number is divided by another number:
|
||||
|
||||
```py
|
||||
int_1 = 56
|
||||
@@ -544,7 +544,7 @@ total_pages //= 5
|
||||
|
||||
print(total_pages) # 4
|
||||
|
||||
# Modulus assignment
|
||||
# Modulo assignment
|
||||
bits = 35
|
||||
bits %= 2
|
||||
|
||||
|
||||
@@ -417,7 +417,7 @@ float_1 = 5.4
|
||||
print(int_1 + float_1) # 61.4
|
||||
```
|
||||
|
||||
- **Modulus Operator (`%`)**: This returns the remainder when a number is divided by another number:
|
||||
- **Modulo Operator (`%`)**: This returns the remainder when a number is divided by another number:
|
||||
|
||||
```py
|
||||
int_1 = 56
|
||||
@@ -544,7 +544,7 @@ total_pages //= 5
|
||||
|
||||
print(total_pages) # 4
|
||||
|
||||
# Modulus assignment
|
||||
# Modulo assignment
|
||||
bits = 35
|
||||
bits %= 2
|
||||
|
||||
|
||||
@@ -706,7 +706,7 @@ CREATE DATABASE database_name;
|
||||
- `-` (subtraction): Subtract second number from first
|
||||
- `*` (multiplication): Multiply two numbers
|
||||
- `/` (division): Divide first number by second (integer division)
|
||||
- `%` (modulus): Remainder after division
|
||||
- `%` (modulo): Remainder after division
|
||||
- `**` (exponentiation): Raise first number to power of second
|
||||
|
||||
```bash
|
||||
@@ -723,7 +723,7 @@ CREATE DATABASE database_name;
|
||||
- `-=` (subtract and assign): Subtract value from variable
|
||||
- `*=` (multiply and assign): Multiply variable by value
|
||||
- `/=` (divide and assign): Divide variable by value
|
||||
- `%=` (modulus and assign): Set variable to remainder
|
||||
- `%=` (modulo and assign): Set variable to remainder
|
||||
|
||||
```bash
|
||||
(( counter = 0 ))
|
||||
@@ -1005,7 +1005,7 @@ for server in "${servers[@]}"
|
||||
|
||||
- **Random numbers**: Generate random values using the `$RANDOM` variable.
|
||||
- `$RANDOM` generates numbers between 0 and 32767
|
||||
- Use modulus operator to limit range: `$RANDOM % 75`
|
||||
- Use modulo operator to limit range: `$RANDOM % 75`
|
||||
- Add 1 to avoid zero: `$(( RANDOM % 75 + 1 ))`
|
||||
- Must use `$(( ... ))` syntax for calculations with `$RANDOM`
|
||||
|
||||
@@ -1027,7 +1027,7 @@ for server in "${servers[@]}"
|
||||
echo ${RESPONSES[$N]}
|
||||
```
|
||||
|
||||
- **Modulus operator**: Use `%` to get the remainder of division operations.
|
||||
- **Modulo operator**: Use `%` to get the remainder of division operations.
|
||||
- Essential for limiting random number ranges
|
||||
- Works with `$RANDOM` to create bounded random values
|
||||
- `RANDOM % n` gives numbers from 0 to n-1
|
||||
|
||||
Reference in New Issue
Block a user