Variable Type | Description | Example |
int | integer | -3, 0, 34, ... |
float | real | -23.43, 4.56 ... |
str | string | "hello" |
bool | True or False | True or 1 , False or 0 |
list | sequence | [1, 2, 3, 'four', 5.3] |
tuple | sequence | (1, 2, 3, 'four', 5.3) |
dict | sequence | {'key': 'value'} ex) {'name': 'Alice', 'age': 30, 'profession': 'Engineer'} |
set | sequence | {1, 2, 3, 'four', 5.3} |
List vs (1D) array
Type | Built-in Python data type | Provided by the NumPy library |
Flexibility | Can contain elements of different types | Typically contains elements of a single data type |
Operations | General-purpose operations (appending, slicing) |
Optimized for numerical operations (element-wise operations, mathematical functions) |
Performance | Generally slower for numerical operations |
Generally faster and more efficient for numerical operations |
Syntax | my_list = [1, 2, 3, 4, 5] | import numpy as np my_array = np.array( [1, 2, 3, 4, 5] ) |
'Python' 카테고리의 다른 글
Python_G-007. List vs Tuple vs set vs dictionary (0) | 2025.01.16 |
---|---|
Python_G-006. 10 Basic Plot (with Matplotlib) (0) | 2025.01.12 |
Python_G-005. Loop Type (0) | 2025.01.12 |
Python_G-004 : 10 basic operations & functions (0) | 2025.01.12 |
Python_G-002 : 10 basic Libraries (0) | 2025.01.12 |