Python Programming – Beginner’s
Guide
Chapter 1: Introduction to Python
Python is a high-level, interpreted, general-purpose programming language. It was created
by Guido van Rossum in 1991.
Features of Python:
• Simple and easy to learn
• Open-source and free
• Portable and cross-platform
• Large standard library
• Supports multiple programming paradigms (OOP, procedural, functional)
Example: A simple Python program
print("Hello, World!")
Chapter 2: Technical Strength of Python
• Interpreted Language → No need for compilation
• Dynamically Typed → No need to declare variable types
• Vast Libraries → NumPy, Pandas, Matplotlib, etc.
• Used in multiple domains:
- Web development (Django, Flask)
- Data Science & Machine Learning
- Automation & Scripting
- Game Development
Chapter 3: Python Interpreter and Program Execution
Ways to run Python:
1. 1. Interactive mode
>>> print("Hello Python")
2. 2. Script mode
Save file as program.py, run: python program.py
Chapter 4: Using Comments in Python
# This is a single-line comment
"""
This is a
multi-line comment
"""
Chapter 5: Literals and Constants
Literals → Fixed values assigned to variables
• Numeric: 10, 3.14, 2+3j
• String: "Python", 'AI'
• Boolean: True, False
Constants → Values that don’t change (Python doesn’t enforce but use CAPS convention)
PI = 3.14159
GRAVITY = 9.8
Chapter 6: Python’s Built-in Data Types
1. Numbers
- Integers: x = 10
- Floats: y = 3.14
- Complex: z = 2 + 3j
- Real numbers: subset of floats
- Sets: {1, 2, 3}
2. Strings
- Creation:
name = "Python"
- Indexing:
print(name[0]) # P
- Slicing:
print(name[0:4]) # Pyth
- Concatenation:
print("Py" + "thon")
- Repetition:
print("Hi! " * 3)
Chapter 7: Accepting Input & Printing Output
Input from user:
name = input("Enter your name: ")
print("Hello", name)
Formatted printing:
age = 20
print(f"I am {age} years old")
Chapter 8: Simple Python Programs
Program: Find Sum of Two Numbers
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Sum =", a + b)
Chapter 9: Flowchart Symbols
• Oval → Start/End
• Parallelogram → Input/Output
• Rectangle → Process
• Diamond → Decision
Chapter 10: Basic Algorithms and Flowcharts
1. Sequential Processing
Example: Adding two numbers
Flowchart → Start → Input A,B → Process (A+B) → Output → End
2. Decision-Based Processing
Example: Check even/odd
n = int(input("Enter number: "))
if n % 2 == 0:
print("Even")
else:
print("Odd")
3. Iterative Processing
Example: Print numbers from 1 to 5
for i in range(1, 6):
print(i)