Python Beginner Notes
1. Introduction to Python
Python is a high-level, interpreted programming language known for its simplicity and readability. It supports
multiple programming paradigms and is widely used in web development, automation, data science, and
more.
2. Python Installation
You can install Python from the official site (python.org). Use 'python --version' to verify installation. You can
run Python files with 'python filename.py'.
3. Hello World Program
Example:
print('Hello, World!')
This prints the string to the console.
4. Variables and Data Types
Variables store data. Python is dynamically typed.
Examples:
name = 'Alice' (str)
age = 25 (int)
is_valid = True (bool)
5. Conditional Statements
Use if, elif, and else to control flow:
if age > 18:
print('Adult')
elif age == 18:
print('Just became adult')
else:
print('Minor')
Python Beginner Notes
6. Loops
Python supports for and while loops:
for i in range(5):
print(i)
while count < 5:
count += 1
7. Functions
Functions are defined using def keyword:
def greet(name):
return 'Hello ' + name
8. Lists and Tuples
Lists are mutable, tuples are immutable.
Examples:
fruits = ['apple', 'banana']
coords = (10, 20)
9. Dictionaries
Store key-value pairs:
student = {'name': 'John', 'age': 20}
Access with student['name']
10. Exception Handling
Use try-except blocks:
try:
x = 10 / 0
except ZeroDivisionError:
Python Beginner Notes
print('Cannot divide by zero')
11. File Handling
To read/write files:
f = open('file.txt', 'r')
data = f.read()
f.close()