2. Variables & Data Types
1. Simple Definition & Meaning
A Variable is just a labeled box where you can store information. Data Types are the kind of things you put in the box, like numbers or text.
2. Real-World Examples
- Example 1 (Variable): Think of a variable as a school bag with a name tag. You can put books inside it, take them out, or change them.
- Example 2 (Data Types): In your kitchen, you have different containers for sugar (Numbers) and water (Strings/Text). You can't mix them up!
3. Important Points
- To create a variable, just write a name and use the
=sign. Example:age = 10. - Strings: Text wrapped in quotes (e.g.,
"Hello"). - Integers: Whole numbers without decimals (e.g.,
5,100). - Variable names cannot start with a number!
📝 Exam Notes (Quick Revision)
- Variables: Containers for storing data values. Created the moment you assign a value.
- String (str): Text data (
name = "Kartik"). - Integer (int): Whole numbers (
score = 95). - Float: Decimal numbers (
price = 10.5).