## Data Type
^ Example                                       ^ Data Type  ^
| x = "Hello World"                             | str        |
| x = 20                                        | int        |
| x = 20.5                                      | float      |
| x = 1j                                        | complex    |
| x = ["apple", "banana", "cherry"]             | list       |
| x = ("apple", "banana", "cherry")             | tuple      |
| x = range(6)                                  | range      |
| x = {"name" : "John", "age" : 36}             | dict       |
| x = {"apple", "banana", "cherry"}             | set        |
| x = frozenset({"apple", "banana", "cherry"})  | frozenset  |
| x = True                                      | bool       |
| x = b"Hello"                                  | bytes      |
| x = bytearray(5)                              | bytearray  |
| x = memoryview(bytes(5))                      |            |
ref: https://medium.com/@shawnren527/learn-about-python-3-data-types-numbers-and-strings-76c75a917c9b
### Class
ref:https://www.w3schools.com/python/python_classes.asp
## Create a list of objects from a class
```python
   swatchList = []
   swatchList.append(Swatch("Sky1",22,40,76))
   # Swatch is the name of the class
```
Reference:\\
 - [[https://www.daniweb.com/programming/software-development/code/216631/a-list-of-class-objects-python|A List of Class Objects]]
## Format Variables
```python
   print('%s %.2f' % ("hue =",swSky1.hue))
   print('{0} {1:.2f}'.format("hue =",swSky1.hue))
   print("hue =", format(swSky1.hue,'.2f'))
   # f:float, x:hex, s:string
```
The three lines above give the same result ````hue = 220.00````.\\
The first line is the old way, "s" means string and "f" means float. The second line is the new way. 0 in {} refer to the first variable and 1:.2f in {} refers to the second variable swSky1.hue and format it to 2 digits behind decimal point. 
Reference:\\
 - Using % and .format() for great good!: https://pyformat.info/
## Plot (matplotlib)
py37-matplotlib has the following notes:\\
The default backend is the interactive Mac OS X backend. Different backends can be specified using the
~/.matplotlib/matplotlibrc file. More details regarding backends can be found in the matplotlib FAQ:
https://matplotlib.org/tutorials/introductory/usage.html#backends
```python
import matplotlib.pyplot as plt
plt.plot(x, y, color='black', linestyle = 'none', marker='o', markerfacecolor=(swatch.r/255.0,swatch.g/255.0,swatch.b/255.0), markersize=12)
```
Note: ```markerfacecolor``` accept RGB, HEX and simple color text description: ```markerfacecolor=(r,g,b)```, ```markerfacecolor='#333399'```, ``` markerfacecolor='green'```
### 3D plot:
https://jakevdp.github.io/PythonDataScienceHandbook/04.12-three-dimensional-plotting.html
## Common Error
```python
    File "main.py", line 15
    self.sat = (cMax - cMin)/(1-abs(2*self.lum-1))
                                                 ^
    TabError: inconsistent use of tabs and spaces in indentation
```
{{ ::python_error_1_space_and_tab.png |}}
Convert all tab to space will solve this problem.