Python Programming Basics
1. Introduction
Python is a high-level, interpreted, easy-to-read programming language used for web development,
AI, automation, data science, and more.
2. Variables
Variables store data. Example: x = 10, name = 'Alice'. Python is dynamically typed.
3. Data Types
int, float, str, bool, list, tuple, set, dict.
4. Operators
Arithmetic (+,-,*,/,%), Comparison (==,!=,<,>), Logical (and, or, not), Assignment (=, +=).
5. Input and Output
Use input() to read user input and print() to display output.
6. Conditional Statements
if, elif, else control program flow.
7. Loops
for loop iterates over sequences. while loop repeats while a condition is True.
8. Functions
Define using def. Functions improve code reuse. Example: def add(a,b): return a+b
9. Lists
Ordered, mutable collection. Methods: append(), remove(), sort().
10. Tuples
Ordered, immutable collection.
11. Dictionaries
Key-value pairs. Example: {'name':'Alice','age':20}.
12. Exception Handling
Use try, except, finally to handle errors.
13. Modules
Import reusable code using import module_name.
14. File Handling
open(), read(), write(), close() or use with open(...).
15. OOP Basics
Classes and objects. Concepts: encapsulation, inheritance, polymorphism.