Chapter 1: Introduction to Python
1.1 What is Python?
Python is a high-level, interpreted programming language known for its readability and ease of use. It
supports multiple programming paradigms, including procedural, object-oriented, and functional
programming.
1.2 Why Learn Python?
• Beginner-friendly syntax
• Extensive community and libraries
• Versatile: used for web development, data science, automation, etc.
1.3 How to Install Python
Step-by-step guide on installing Python from python.org.
1.4 Hello, World!
python
Copy code
# This is your first Python program
print("Hello, World!")
Chapter 2: Python Basics
2.1 Variables and Data Types
Python supports various data types: integers, floats, strings, and booleans.
python
Copy code
x = 10 # integer
y = 3.14 # float
name = "Alice" # string
is_happy = True # boolean
2.2 Comments in Python
Comments are lines that Python ignores during execution. Use # for single-line comments.
python
Copy code
, # This is a comment
print("This will run") # This comment is inline
2.3 Basic Input and Output
python
Copy code
name = input("Enter your name: ") # Taking input from the user
print("Hello, " + name) # Printing output
Chapter 3: Control Structures
3.1 Conditional Statements
python
Copy code
age = 20
if age >= 18:
print("You are an adult")
else:
print("You are a minor")
3.2 Loops
Python supports both for and while loops.
• For Loop:
python
Copy code
for i in range(5):
print(i) # Prints numbers from 0 to 4
• While Loop:
python
Copy code
i=0
while i < 5:
print(i)
i += 1