Python Programming for Beginners
A Step-by-Step Learning Guide
Table of Contents
1. Introduction to Python
2. Installing Python
3. Writing Your First Program
4. Variables and Data Types
5. Input and Output
6. Operators
7. Conditional Statements
8. Loops
9. Functions
10. Lists
11. Tuples
12. Dictionaries
13. Sets
14. Strings
15. File Handling
16. Exception Handling
17. Modules and Packages
18. Object-Oriented Programming (Introduction)
19. Working with Excel Files
20. Python for Engineering Applications
21. Mini Projects
22. Practice Exercises
23. Recommended Learning Path
Chapter 1: Introduction to Python
What is Python?
Python is a high-level, interpreted programming language that is easy to read and write. It is
one of the most popular programming languages because it has a simple syntax and a wide
range of applications.
Python is used in:
Automation
Data Analysis
Machine Learning
Artificial Intelligence
Web Development
Scientific Computing
Structural Engineering
Finite Element Automation
Excel Automation
Why Learn Python?
Python offers several advantages:
Easy to learn
Simple syntax
Large community support
Free and open source
Cross-platform compatibility
Extensive libraries for engineering and data analysis
Chapter 2: Installing Python
Step 1
Download Python from the official website.
Step 2
Run the installer.
✔ Check "Add Python to PATH" before clicking Install.
Step 3
Open Command Prompt and type:
python --version
You should see a version number if Python is installed correctly.
Chapter 3: Your First Python Program
Open IDLE, VS Code, or another editor and type:
print("Hello, World!")
Output:
Hello, World!
Congratulations! You have written your first Python program.
Chapter 4: Variables and Data Types
Variables store data.
Example:
name = "Rashmi"
age = 30
salary = 50000
height = 1.65
Common data types:
Data Type Example
Integer 10
Float 3.14
String "Python"
Boolean True
List [1,2,3]
Tuple (1,2,3)
Dictionary {"A":1}
Chapter 5: Input and Output
Taking input:
name = input("Enter your name: ")
print(name)
Numbers:
age = int(input("Enter age: "))
Decimal numbers:
salary = float(input("Salary: "))
Chapter 6: Operators
Arithmetic Operators
a = 10
b = 3
print(a+b)
print(a-b)
print(a*b)
print(a/b)
print(a%b)
print(a**2)
Comparison Operators
print(a>b)
print(a==b)
Logical Operators
True and False
True or False
not True
Chapter 7: If Statements
age = 18
if age >= 18:
print("Eligible")
else:
print("Not Eligible")
Multiple conditions:
marks = 75
if marks >= 90:
print("A")
elif marks >= 75:
print("B")
else:
print("C")
Chapter 8: Loops
For Loop
for i in range(5):
print(i)
Output:
0
1
2
3
4
While Loop
count = 1
while count <= 5:
print(count)
count += 1
Chapter 9: Functions
def add(a, b):
return a + b
result = add(5, 7)
print(result)
Functions make programs reusable and easier to maintain.
Chapter 10: Lists
fruits = ["Apple", "Mango", "Orange"]
print(fruits[0])
[Link]("Banana")
Useful methods:
append()
insert()
remove()
pop()
sort()
Chapter 11: Tuples
numbers = (1,2,3)
print(numbers[1])
Tuples cannot be modified after creation.
Chapter 12: Dictionaries
student = {
"Name":"Rashmi",
"Age":30,
"City":"Delhi"
}
print(student["Name"])
Chapter 13: Sets
numbers = {1,2,3,4}
[Link](5)
Sets automatically remove duplicate values.
Chapter 14: Strings
text = "Python"
print([Link]())
print([Link]())
print(len(text))
Useful methods:
split()
replace()
find()
strip()
Chapter 15: File Handling
Writing a file:
file = open("[Link]","w")
[Link]("Hello")
[Link]()
Reading:
file = open("[Link]","r")
print([Link]())
[Link]()
Chapter 16: Exception Handling
try:
x = 10/0
except ZeroDivisionError:
print("Cannot divide by zero")
Chapter 17: Modules
Example:
import math
print([Link](25))
Chapter 18: Object-Oriented Programming
Example:
class Student:
def __init__(self,name):
[Link]=name
def display(self):
print([Link])
s=Student("Rashmi")
[Link]()
Chapter 19: Working with Excel
Install the required package:
pip install openpyxl
Example:
from openpyxl import Workbook
wb = Workbook()
ws = [Link]
ws["A1"] = "Python"
[Link]("[Link]")
Applications include:
Reading Excel files
Writing Excel files
Formatting worksheets
Creating reports
Automating repetitive tasks
Chapter 20: Python for Engineering
Python is widely used for:
Structural analysis calculations
Excel automation
[Link] automation
SAP2000 API scripting
AutoCAD automation
Load combination generation
Wind load calculations
Seismic calculations
Reinforcement quantity calculations
Data visualization
Chapter 21: Mini Projects
Try building these beginner projects:
1. Calculator
2. Unit converter
3. Student marks calculator
4. Expense tracker
5. Number guessing game
6. Password generator
7. Excel data cleaner
8. Structural section property calculator
Chapter 22: Practice Exercises
1. Print numbers from 1 to 100.
2. Find the largest of three numbers.
3. Calculate the factorial of a number.
4. Reverse a string.
5. Count vowels in a sentence.
6. Read data from an Excel file.
7. Create a multiplication table.
8. Generate Fibonacci numbers.
9. Sort a list of numbers.
10. Write student details to a file.
Chapter 23: Recommended Learning Path
Week 1
Python installation
Variables
Data types
Input/output
Week 2
Operators
Conditions
Loops
Week 3
Functions
Lists
Tuples
Dictionaries
Week 4
File handling
Modules
Exception handling
Week 5
Object-oriented programming
Excel automation
Week 6
Engineering applications
Mini projects
Revision
Final Tips
Practice coding every day, even if only for 30–60 minutes.
Type the examples yourself instead of copying and pasting them.
Break problems into smaller steps before writing code.
Learn to read error messages—they often point directly to the issue.
Build small projects regularly to reinforce what you've learned.
With consistent practice, you'll develop a solid foundation in Python and be ready to tackle
automation, data analysis, and engineering applications.