Skip to content

Commit 5a21a6c

Browse files
Update README.md
Signed-off-by: Fabiana 🚀 Campanari <113218619+FabianaCampanari@users.noreply.github.com>
1 parent 86c9b88 commit 5a21a6c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,29 +1850,36 @@ The modulo operator (%) returns the remainder of a division. In simulations invo
18501850

18511851
## 2- [Why Use Modulo in Random Number Simulations]() ?
18521852

1853-
In simulations, we often need random values within a specific interval for example, simulating a dice roll (1 to 6) or selecting a random day of the week (0 to 6). Random number generators typically produce large numbers, so the modulo operation helps normalize these into the desired range.
1853+
In simulations, we often need random values within a specific interval, for example, simulating a dice roll (1 to 6) or selecting a random day of the week (0 to 6). Random number generators typically produce large numbers, so the modulo operation helps normalize these into the desired range.
18541854

18551855
<br>
18561856

18571857
## 3- [Example]():
18581858

18591859
Imagine your random number generator gives you a number like 247. If you want to simulate a 6-sided dice roll:
18601860

1861+
1862+
```pyhton
18611863
dice_roll = (247 % 6) + 1 # Adding 1 to shift range from [0–5] to [1–6]
1864+
```
1865+
1866+
#### **This ensures the result is always [between 1 and 6]()**.
18621867

1863-
This ensures the result is always between 1 and 6.
1868+
<br>
18641869

1865-
Simulation Use Case:
1870+
## 4- [Simulation Use Case]():
18661871

18671872
In a banking simulation, you might simulate customer behavior across 7 days of the week. If a random function returns a number like 123456, you can use:
18681873

1874+
```python
18691875
day_of_week = 123456 % 7 # Result is between 0 and 6
1876+
```
18701877

1871-
This maps any large number into the range of weekdays (e.g., 0 = Sunday, 6 = Saturday).
1878+
#### **This maps any large number [into the range of weekdays]() (e.g., 0 = Sunday, 6 = Saturday)**.
18721879

18731880
<br>
18741881

1875-
## 4- [Summary]():
1882+
## 5- [Summary]():
18761883

18771884
In simulations, the % operator is a simple and efficient way to control the range of random outputs. It transforms raw random data into usable, context-specific values, essential for realistic and accurate simulation scenarios.
18781885

0 commit comments

Comments
 (0)