Python Beginner Notes
A concise beginner-friendly introduction to Python programming.
1. What is Python?
Python is a high-level, readable programming language used in web development, data science,
automation, AI, and more.
2. Variables
Variables store data. Example: name = 'NJ', age = 20.
3. Data Types
Common types: int, float, str, bool, list, tuple, dict, set.
4. Input and Output
Use input() to receive data and print() to display output.
5. Operators
Arithmetic (+,-,*,/,%), comparison (==, !=, >, <), and logical (and, or, not).
6. Conditional Statements
if, elif, and else control program flow.
7. Loops
for loops repeat a known number of times; while loops repeat while a condition is true.
8. Functions
Functions are reusable blocks of code defined using def.
9. Lists
Lists store multiple items and are mutable.
10. Dictionaries
Dictionaries store key-value pairs.
11. Modules
Modules are files containing Python code that can be imported.
12. File Handling
Use open() to read or write files.
13. Error Handling
Use try and except to handle exceptions.
14. Object-Oriented Programming
Classes and objects help organise larger programs.
15. Practice Advice
Build small projects such as calculators, quizzes, and to-do lists.
Quick Reference
print("Hello World")
name = input("Enter name: ")
for i in range(5):
print(i)
def greet(name):
return f"Hello {name}"