Python Programming Basics
Python Programming Basics
Real-life Analogy: Using Python is like writing instructions in plain English for the computer to
follow.
2. Variables in Python
A variable is a container that stores data values. You don’t need to declare the type of variable
in Python; it is determined automatically.
Syntax:
variable_name = value
Example:
name = "Alice"
age = 21
Real-time Example:
Think of a variable like a labeled jar where you store something.
milk = "Amul"
quantity = 2 # liters
3. Data Types
Python has several built-in data types. Common ones include:
Real-time Example:
temperature = 36.6
student_name = "John"
is_present = True
4. Operators in Python
Operators are symbols that perform operations on variables and values.
Arithmetic Operators:
+ (Addition)
- (Subtraction)
* (Multiplication)
/ (Division)
// (Floor Division)
% (Modulus)
** (Exponentiation)
Real-time Example:
price = 50
discount = 10
final_price = price - discount
age = 18
is_eligible = age >= 18
Summary
- Variables store data.
- Data types determine the kind of data (number, text, etc.).
- Operators perform calculations and logic.
- Use input() for user interaction and assignment (=) for storing values.
- Real-time examples make programs meaningful and relevant.