Python Data Types
While I was studying Python, I realized that there are lots of different data types in Python.
Numerical data types are used to represent numbers. They primarily consist of integers and floating-point numbers, used for calculations and numerical operations.
In Python, two main types of numerical data are commonly used:
1. Integer:
- Integers represent whole numbers without a decimal point.
- They can include both positive and negative integers.
- For example, `1`, `-5`, `100` are integers.
- In Python, integers are represented by the `int` type.
2. Float:
- Floating-point numbers represent numbers with a decimal point.
- They can include both integer and fractional parts.
- For example, `3.14`, `-0.5`, `2.71828` are floats.
- In Python, floating-point numbers are represented by the `float` type.
In Python, these numerical data types can be manipulated through arithmetic operations and assigned to variables for use.
Sequence type refers to a data type in Python that stores elements in a specific order.
These elements can be of various data types and are arranged sequentially.
1. List:
- The most commonly used sequence type, created using square brackets `[]`.
- Lists can contain elements of different data types.
- Examples include `[1, 2, 3]`, `['apple', 'banana', 'orange']`.
2. Tuple:
- Similar to lists but immutable, meaning they cannot be modified once created.
- Created using parentheses `()`.
- Examples include `(1, 2, 3)`, `('apple', 'banana', 'orange')`.
3. String:
- A sequence of characters enclosed in single (`'`) or double (`"`) quotes.
- Examples include `'hello'`, `"Python"`.
Sequence types support common operations such as indexing, slicing, and iteration, making them useful for processing and manipulating data. They also provide various built-in functions and methods for performing different tasks in Python.
'Study Note > Python' 카테고리의 다른 글
Missing data handling (0) | 2024.05.02 |
---|---|
Taitanic data analysis (0) | 2024.04.30 |
Lambda function (0) | 2024.04.05 |
10. Purpose of 'while' and 'for in' (0) | 2024.04.02 |
9. Method vs Function / Dictionary vs List (0) | 2024.03.28 |