```python
round(22/7, 3)
```


```python
import random
```


```python
def zero_or_one():
    r = random.choice([0, 1])
    return r

trial = [zero_or_one() for i in range(20)] 

print(trial, sum(trial))
```


```python
N_coins = 50
N_heads = 25

N_simul = 20000

count = 0
for i in range(N_simul):
    trial = [zero_or_one() for i in range(N_coins)]
    if sum(trial) >= N_heads:
        count += 1

print( 1.0 * count / N_simul )
```


```python
trial = np.random.randint(2, size=10)
print(trial)
print(trial.sum())
```


```python
N = 100000
n_coins = 50
n_heads = 25

count = 0
for i in range(N):
    trial = np.random.randint(2, size=n_coins)
    if trial.sum() >= 25:
        count += 1
        
1.0 * count / N
```

# Sympy


```python
from sympy import symbols, solve

x = symbols('x')

solve(x**2 - 2, x)
```


```python
from sympy import diff, sin, exp
diff(sin(x) * exp(x), x)
```


```python
from sympy import init_printing
init_printing(use_unicode=True)

diff(sin(x) * exp(x), x)
```


```python
from sympy import integrate, cos
integrate(exp(x)*sin(x) + exp(x)*cos(x), x)
```

# Prettier graphs


```python
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
```


```python
# seaborn package is not include in anaconda
# neet to run `conda install seaborn` or `pip install seaborn`

import seaborn
seaborn.set_style('whitegrid')
```


```python
def f(x):
    return x*x

x = np.linspace(-5, 5, 100)
plt.plot(x, f(x))

s = x[::5]
plt.plot(s, f(s), 'ro')


#plt.savefig('/tmp/toto.png', dpi=300)
```

0aa36a2e91a372193d1a742795c810b4a776ed50
ipynb
Jupyter Notebook
code/scratch.ipynb
vanzaj/2016-06-11-ntu
a453d1608e5d1a7fc80ea011fa08351c6f642925
CC-BY-4.0
code/scratch.ipynb
vanzaj/2016-06-11-ntu
a453d1608e5d1a7fc80ea011fa08351c6f642925
CC-BY-4.0
code/scratch.ipynb
vanzaj/2016-06-11-ntu
a453d1608e5d1a7fc80ea011fa08351c6f642925
CC-BY-4.0
Qwen/Qwen-72B
1. YES
2. YES