Names, objects, and basic types
A Python assignment binds a name to an object; the object has a type and a value.
Learning objectives
- Assign values to readable names.
- Recognize integers, floats, strings, and Booleans.
Binding a name
PYTHON
name = "Asha"
age = 20
ratio = 0.75
is_student = True= does not declare a fixed storage type in the way a C++ declaration does. It binds the name on the left to the object produced on the right. type(age) can inspect an object’s type when learning or debugging.
Trace and mistakes
After age = age + 1, Python reads the object currently bound to age, computes a new integer, then binds age to that result. Names should describe their purpose; student_count is clearer than x.
TrueandFalseare capitalized Boolean literals.- Do not combine text and a number with
+without an intentional conversion.
Applications and references
These types represent counts, measurements, messages, and yes/no state—the raw material of every later example.