# python memorandum (sequential update)

# item

- When you want to use a character string as a code (assignment statement)
`eval`

- When you want to overlap two with hist and make one transparent
`.hist (alpha = 0.5)`

- I want to use the square root!
``math.sqrt (x)``

- I want to make a list that numpy can use as it is! ``
`np.array ([0, 1, 2])`

`
- etc...

# 1. When you want to use a character string as a code (assignment statement) `eval`

A so-called assignment statement that can use the character string inside as a code with `eval ("~~~ ")`

?

`python`

```
list = ["dog","cat"]
dog, cat = "wan", "nya"
for i in list:
print(eval(i))
# wan
# nya
```

# 2. When you want to overlap two with hist and make one transparent `.hist (alpha = 0.5)`

`.hist (alpha =?)`

Makes it transparent, `1 ~ 0`

makes it darker as it gets closer to` 1`

, and `0.0`

makes it completely transparent.

`python`

```
x = np.random.randn(10000)
plt.hist(x, alpha =0.5)
plt.hist(x - 2, alpha = 0.5)
plt.show
```

# 3. I want to use the square root! `math.sqrt (x)`

I want to use the square root easily! In such a case, use `math`

to`.sqrt (x)`

!

`python`

```
import math
print(math.sqrt(4))
print(math.sqrt(144))
# 2.0
# 12.0
```

# 4. I want to make a list that numpy can use as it is! `Np.array ([0, 1, 2])`

By creating a list with `np.array ([list of int])`

, you can apply the numpy module to the list as it is.

`python`

```
x = np.array([812, 973, 1001])
np.max(x)
# 1001
```

5.etc...