0% found this document useful (0 votes)
7 views20 pages

Python Handbook Beginner To Advanced

The Complete Python Handbook is a comprehensive guide for beginners to advanced learners, covering essential topics such as variables, data types, operators, conditional statements, loops, functions, and more. It includes example code and practice exercises for each topic to reinforce learning. Additionally, it touches on advanced concepts like object-oriented programming, modules, and automation, making it a valuable resource for mastering Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views20 pages

Python Handbook Beginner To Advanced

The Complete Python Handbook is a comprehensive guide for beginners to advanced learners, covering essential topics such as variables, data types, operators, conditional statements, loops, functions, and more. It includes example code and practice exercises for each topic to reinforce learning. Additionally, it touches on advanced concepts like object-oriented programming, modules, and automation, making it a valuable resource for mastering Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Complete Python Handbook (Beginner →

Advanced)

This handbook is designed for students who want to learn Python step■by■step. It includes simple
explanations, many example programs, and practice exercises.
1. Introduction to Python

Python is one of the most popular programming languages in the world.

It is used in:
• Web development
• Data science
• Artificial intelligence
• Automation
• Embedded systems

Python is easy to learn because its syntax is simple and readable.

Example Code
print("Hello World")
print("Welcome to Python")

Practice Exercises
• Install Python

• Run a Hello World program

• Print your name and age using Python


2. Variables and Data Types

Variables store information in memory.

Common Python data types:


• int (integer)
• float (decimal numbers)
• str (text)
• bool (True/False)

Example Code
name = "Praveen"
age = 21
height = 5.8
student = True
print(name)
print(type(age))

Practice Exercises
• Create variables for your name, city, and branch

• Print the type of each variable


3. Operators

Operators perform operations on values.

Types of operators:
Arithmetic: + - * / %
Comparison: == != > <
Logical: and or not

Example Code
a = 10
b = 5
print(a + b)
print(a - b)
print(a > b)
print(a > 5 and b < 10)

Practice Exercises
• Write a program to calculate area of a rectangle
4. Conditional Statements

Conditional statements allow decision making in programs.

Python supports:
if
elif
else

Example Code
marks = 80
if marks >= 90:
print("Grade A")
elif marks >= 60:
print("Grade B")
else:
print("Grade C")

Practice Exercises
• Write a program to check if a number is even or odd
5. Loops

Loops repeat a block of code multiple times.

Types:
for loop
while loop

Example Code
for i in range(1,6):
print(i)
x = 0
while x < 5:
print(x)
x += 1

Practice Exercises
• Print numbers from 1 to 10

• Find sum of first 10 numbers


6. Functions

Functions help organize programs into reusable blocks.

Example Code
def add(a,b):
return a+b
print(add(5,3))

Practice Exercises
• Create a function that finds square of a number
7. Lists

Lists store multiple values in one variable.

Example Code
numbers = [1,2,3,4]
[Link](5)
for n in numbers:
print(n)

Practice Exercises
• Create a list of 5 fruits and print them
8. Tuples

Tuples are similar to lists but cannot be modified.

Example Code
data = (10,20,30)
print(data[1])

Practice Exercises
• Create a tuple with 5 numbers
9. Dictionaries

Dictionaries store key■value pairs.

Example Code
student = {
"name":"Praveen",
"age":21,
"branch":"ECE"
}
print(student["name"])

Practice Exercises
• Create a dictionary for a book (title, author, price)
10. Strings

Strings represent text and support many useful methods.

Example Code
text = "python programming"
print([Link]())
print([Link]())
print(len(text))

Practice Exercises
• Reverse a string
11. File Handling

Python allows reading and writing files.

Example Code
file = open("[Link]","w")
[Link]("Hello Python")
[Link]()

Practice Exercises
• Write a program to save your name into a file
12. Exception Handling

Exception handling prevents program crashes.

Example Code
try:
a = 10/0
except:
print("Error occurred")

Practice Exercises
• Write a program that handles division by zero
13. Object Oriented Programming

OOP helps structure large programs.

Concepts:
• Class
• Object
• Encapsulation
• Inheritance

Example Code
class Student:
def __init__(self,name):
[Link] = name
def greet(self):
print("Hello", [Link])
s1 = Student("Praveen")
[Link]()

Practice Exercises
• Create a class called Car with attributes name and speed
14. Inheritance

Inheritance allows a class to inherit features from another class.

Example Code
class Animal:
def speak(self):
print("Animal speaks")
class Dog(Animal):
pass
d = Dog()
[Link]()

Practice Exercises
• Create a class Vehicle and inherit it with Car
15. Modules and Libraries

Modules help organize Python code.

Popular libraries:
NumPy
Pandas
Matplotlib
TensorFlow

Example Code
import math
print([Link](36))

Practice Exercises
• Import math module and calculate factorial of 6
16. Python Mini Project: Calculator

A simple calculator project using Python.

Example Code
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Addition:",a+b)
print("Subtraction:",a-b)
print("Multiplication:",a*b)
print("Division:",a/b)

Practice Exercises
• Extend calculator to support power operation
17. Automation Example

Python can automate repetitive tasks.

Example Code
import os
files = [Link]()
print(files)

Practice Exercises
• List all files in a folder
18. Python for Embedded / IoT

Python (MicroPython) is used in microcontrollers such as:


• Raspberry Pi Pico
• ESP32

Useful for IoT and embedded systems.

Example Code
from machine import Pin
from time import sleep
led = Pin(25, [Link])
while True:
[Link]()
sleep(1)

Practice Exercises
• Blink LED using MicroPython
19. Tips to Master Python

Practice daily.
Build small projects.
Read other people's code.
Solve programming problems.

Example Code
print("Keep coding!")

Practice Exercises
• Write at least 5 small Python programs

You might also like