Bạn đang xem thử công khai
Đăng nhập để lưu tiến độ, làm bài tập, thảo luận và nhận phản hồi.
Review lesson. A summary table of the variables, data types, and operators part of Module 1, for quick lookup and self-checking after studying units 1.2 → 1.6. If anything is still unclear, go back to the corresponding unit and rewatch the video.
| Type | Example | Ordered | Mutable | Notes |
|---|---|---|---|---|
int, float | 42, 3.14 | — | — | / always gives a float, // is floor division |
str | 'Python' | Yes | No | Indexing starts at 0, slice s[a:b] stops before b |
bool | True, False | — | — | True + True equals 2 |
list | [1, 2, 3] | Yes | Yes | b = a does not copy; use a.copy() |
tuple | (1, 2) | Yes | No | A single element needs a comma: (50,) |
set | {1, 2, 3} | No | Yes | Duplicate elements are not allowed |
dict | {"a": 1} | Yes | Yes | Keys are unique; d.get(k, default) does not raise an error when the key is missing |
From highest to lowest: ** → * / % // → + - → comparison → is, in → not and or.
input() always returns a string; to do arithmetic you must convert the type: int(input(...)).== compares values, is checks for the same object (commonly used for None).False None 0 0.0 '' [] () {} set(); the string "False" is still truthy.int(3.99) is 3 — int() truncates the decimal part, it does not round.snake_case, constants use UPPER_SNAKE_CASE, classes use PascalCase.