Skip to content

Commit 30dd7ea

Browse files
Merge pull request #159 from codewizardshq/python-docs-add-round
Add `round()` docs to Python Language docs.
2 parents 143e228 + 64fa87d commit 30dd7ea

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

docs/python/python-language.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,8 +1305,6 @@ Example Output:
13051305
3 potato
13061306
```
13071307

1308-
Note that the last number is 3 in the example above, not 4!
1309-
13101308
###### Using the `step` parameter of the `range()` function
13111309

13121310
The `range()` function takes a third argument, `step`, which allows you to generate sequences of numbers separated by a given step:
@@ -1326,6 +1324,20 @@ Example Output:
13261324
10
13271325
```
13281326

1327+
##### `round()`
1328+
1329+
The `round()` function is used to round a decimal number (`float`) to an integer or to round a decimal number to a given number of digits after the decimal point:
1330+
1331+
```python
1332+
pi = 3.14159
1333+
1334+
pi_integer = round(pi)
1335+
print(pi_integer) # 3
1336+
1337+
pi_two_decimal_points = round(pi, 2)
1338+
print(pi_two_decimal_points) # 3.14
1339+
```
1340+
13291341
##### `sorted()`
13301342

13311343
The `sorted()` function is used to sort a `list`:

0 commit comments

Comments
 (0)