Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions concepts/bools/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ Each of the operators has a different precedence, where `not` is evaluated befor
Brackets can be used to evaluate one part of the expression before the others:

```python
>>>not True and True
>>> not True and True
False

>>>not (True and False)
>>> not (True and False)
True
```

Expand All @@ -45,25 +45,25 @@ A few `built-ins` are always considered `False` by definition:


```python
>>>bool(None)
>>> bool(None)
False

>>>bool(1)
>>> bool(1)
True

>>>bool(0)
>>> bool(0)
False

>>>bool([1,2,3])
>>> bool([1,2,3])
True

>>>bool([])
>>> bool([])
False

>>>bool({"Pig" : 1, "Cow": 3})
>>> bool({"Pig" : 1, "Cow": 3})
True

>>>bool({})
>>> bool({})
False
```

Expand Down Expand Up @@ -95,25 +95,25 @@ The `bool` type is implemented as a _sub-type_ of _int_.


```python
>>>1 == True
>>> 1 == True
True

>>>0 == False
>>> 0 == False
True
```

However, `bools` are **still different** from `ints`, as noted when comparing them using the _identity operator_, `is`:


```python
>>>1 is True
>>> 1 is True
False

>>>0 is False
>>> 0 is False
False
```

> Note: in python >= 3.8, using a literal (such as 1, '', [], or {}) on the _left side_ of `is` will raise a warning.
> Note: in python >= 3.8, using a literal (such as `1`, `''`, `[]`, or `{}`) on the _left side_ of `is` will raise a warning.


It is considered a [Python anti-pattern][comparing to true in the wrong way] to use the equality operator to compare a boolean variable to `True` or `False`.
Expand Down
2 changes: 1 addition & 1 deletion concepts/numbers/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Numbers can be converted from `int` to `floats` and `floats` to `int` using the

## Round

Python provides a built-in function [`round(number, <decimal_places>)`][round] to round off a floating point number to a given number of decimal places.
Python provides a built-in function [`round(<number>, <decimal_places>)`][round] to round off a floating point number to a given number of decimal places.
If no number of decimal places is specified, the number is rounded off to the nearest integer and will return an `int`:

```python
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/currency-exchange/.meta/exemplar.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_change(budget, exchanging_value):
float: The amount left of your starting currency after the exchange

Examples:
.>>> get_change(127.5, 120.0)
>>> get_change(127.5, 120.0)
7.5

>>> get_change(300.75, 150.25)
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/currency-exchange/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_change(budget, exchanging_value):
float: The amount left of your starting currency after the exchange

Examples:
.>>> get_change(127.5, 120.0)
>>> get_change(127.5, 120.0)
7.5

>>> get_change(300.75, 150.25)
Expand Down
Loading