# [Python] Use and and or when creating variables

## How to use and and or did not know

** The logical operators and, or not only output bool types such as True and False, but also output numerical values, character strings, lists, etc. depending on the conditions. </ b>**

**
**#### conditions

The expressions x and y first evaluate x; if x is false, return the value of x; otherwise, evaluate the value of y and return the result.
The expression x or y first evaluates x; returns the value of x if x is true; otherwise it evaluates the value of y and returns the result.
6. expression — Python 3.8.3 documentation

##### The objects that are considered False are:

- bool type False
- None
- Numerical value (int type or float type) 0, 0.0
- Empty string''
- Empty containers (lists, tuples, dictionaries, etc.) [], (), {}

#### Example

```
x = 5 # True
y = 0 # False
print(x and y)
# 0
print(x or y)
# 5
print(not x)
# False
```

```
x = 10 # True
y = 100 # True
print(x and y)
# 100
print(y and x)
# 10
print(x or y)
# 10
```

Reference site
[https://note.nkmk.me/python-boolean-operation/:embed:cite]

**
**