1. Variables
- Containers that store data values.
- Each variable has a name and holds a value.
2. Data Types
- Define the kind of data a variable can hold.
Common types:
- Integer (int): Whole numbers (e.g., 5, -10)
- Float (float): Decimal numbers (e.g., 3.14, -0.001)
- String (str): Text (e.g., "Hello", "123")
- Boolean (bool): True or False
- Character (char): Single characters (in some languages)
- Arrays/Lists: Collections of values (e.g., [1, 2, 3])
3. Operators
- Symbols that perform operations on variables and values.
Types include:
- Arithmetic: +, -, *, /, %
- Comparison: ==, !=, <, >, <=, >=
- Logical: and, or, not
- Assignment: =, +=, -=, etc.
4. Control Structures
a) Conditionals (If Statements)
- Make decisions in code based on conditions.
b) Loops
- Repeat a block of code multiple times.
- For Loop: Runs for a specific number of times or over items.
- While Loop: Runs as long as a condition is true.
5. Functions (or Methods)
- Blocks of reusable code that perform a specific task.
- Can take inputs (parameters) and return outputs.
0 Comments