python memorandum (sequential update)

item

  1. When you want to use a character string as a code (assignment statement) eval
  2. When you want to overlap two with hist and make one transparent .hist (alpha = 0.5)
  3. I want to use the square root! `math.sqrt (x)`
  4. I want to make a list that numpy can use as it is! `` np.array ([0, 1, 2]) `
  5. 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

スクリーンショット 2020-11-10 0.55.04.png

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...

Recommended Posts

python memorandum (sequential update)
Python memorandum
Python Memorandum 2
Python update (2.6-> 2.7)
Python memorandum
python memorandum
python memorandum
Python memorandum
python memorandum
Python memorandum
Python pathlib memorandum
Python memorandum (algorithm)
Python memorandum [links]
Python memorandum numbering variables
Sequential search with Python
python chromedriver automatic update
Linux command (sequential update)
Python memorandum (personal bookmark)
Python basic memorandum part 2
[Python] Iterative processing_Personal memorandum
Memorandum @ Python OR Seminar
python memorandum super basic
Effective Python Learning Memorandum Day 15 [15/100]
Cisco Memorandum _ Python config input
Effective Python Learning Memorandum Day 6 [6/100]
Effective Python Learning Memorandum Day 12 [12/100]
Effective Python Learning Memorandum Day 9 [9/100]
How to update Python Tkinter to 8.6
Automatic update of Python module
Effective Python Learning Memorandum Day 8 [8/100]
ABC memorandum [ABC163 C --managementr] (Python)
About python beginner's memorandum function
Memorandum @ Python OR Seminar: matplotlib
[Python] SQLAlchemy error avoidance memorandum
Update python on Mac to 3.7-> 3.8
A memorandum about correlation [Python]
Effective Python Learning Memorandum Day 14 [14/100]
Effective Python Learning Memorandum Day 1 [1/100]
Memorandum @ Python OR Seminar: Pulp
Effective Python Learning Memorandum Day 13 [13/100]
A memorandum about Python mock
Effective Python Learning Memorandum Day 3 [3/100]
Effective Python Learning Memorandum Day 5 [5/100]
Memorandum @ Python OR Seminar: Pandas
[python] Random number generation memorandum
Effective Python Learning Memorandum Day 4 [4/100]
Memorandum @ Python OR Seminar: scikit-learn
[Python beginner] Update pip itself
Effective Python Learning Memorandum Day 7 [7/100]
Effective Python Learning Memorandum Day 2 [2/100]
python parallel / asynchronous execution memorandum
Python pywin32 (win32com) Excel operation memorandum
Python
Replace dictionary value with Python> update ()
[Python] A memorandum of beautiful soup4
python dict object memorandum (mysterious document)
ABC memorandum [ABC161 C --Replacing Integer] (Python)
Git & Github & python & VScode Personal memorandum
PIL (Python Imaging Library) installation memorandum
ABC memorandum [ABC158 C --Tax Increase] (Python)
Memorandum of beginners Python "isdigit" movement