Variables
1. variable
1.2. Notes
Static vs. Dynamic Typing:
Java and C++ (static): Require explicit type declaration, checked at compile time.
Python (dynamic): Type is inferred at runtime, offering flexibility but potential errors.
Naming Conventions:
Use meaningful names (e.g., studentCount instead of sc).
Follow language-specific conventions (e.g., camelCase in Java: isStudent, snake_case in Python: is_student).
Immutability: Some languages (e.g., Java’s final, Python’s tuples) allow variables to be made constant.
2. Expressions
An expression is a combination of variables, literals (e.g., numbers, strings), operators (e.g., +, -, *), and function calls that evaluates to a single value.
Characteristics
Components:
Literals: Fixed values (e.g., 42, "hello", 3.14).
Variables: Named values (e.g., age, height).
Operators: Symbols defining operations (e.g., + for addition, == for comparison).
Function Calls: Invoking functions that return values (e.g., Math.sqrt(16) in Java).
Evaluation: Produces a single value Ascertainable System: value of a specific type (e.g., int for arithmetic expressions).
Types of Expressions:
Arithmetic: Involves numerical operations (e.g., x + y * 2).
Relational: Compares values, returning a boolean (e.g., x > y).
Logical: Combines boolean values (e.g., isStudent && age < 18).
Assignment: Assigns a value to a variable (e.g., total = x + y).