> For the complete documentation index, see [llms.txt](https://huang-jason.gitbook.io/python/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://huang-jason.gitbook.io/python/basic.md).

# Basic - 1

## 1. Import

```python
import numpy as np
from six.moves import cPickle as pickle
```

## 2. Multi-line statement

```python
a = 1 + 2 + 3 + \
    4 + 5 + 6 + \
    7 + 8 + 9

a = 1; b = 2; c = 3

a = (1 + 2 + 3 +
    4 + 5 + 6 +
    7 + 8 + 9)
```

## 3. `__doc__`

```python
def double(num):
    """Function to double the value"""
    return 2*num

>>> print(double.__doc__)
Function to double the value
```

## 4. list, tuple, set, dictionary

* list = ordered collections
* tuple = immutable list
* set = unordered, unique collections
* dictionary = key-value pair

```python
# List = ordered sequence of items.
a = [5,10,15,20,25,30,35,40]
a[2] # 15

# Tuple = immutable list
t = (5,'program', 1+3j)
t[1] # 'program'
t[0] = 10 # error

# Set = unordered collection of unique items.
s = {5,2,3,1,4}
s[1] # error

# Dictionary = key-value pairs
d = {1:'value','key':2}
d[1] # 'value'
```

## 5. string format

```python
x = 5; y = 10
print('The value of x is {} and y is {}'.format(x,y))
#      The value of x is 5 and y is 10

x = 12.3456789
print('The value of x is %3.4f' %x)
#      The value of x is 12.3457
```
