Chapter 1 - Introduction to Python
1.1 What is Python?
Python is a high-level, general-purpose programming language
used to write instructions for computers.
It is easy to learn, powerful, and widely used in modern technologies such as:
- Artificial Intelligence
- Web Applications
- Data Science
- Robotics
- Game Development
1.2 Why Learn Python? (Features of Python)
- Simple and Easy – English-like commands
- Interpreted
Language – executes line by line
- Free and Open Source
- Portable – runs on Windows, Mac, Linux
- Large Library Support
- Beginner-Friendly
1.3 How to Use Python? (Modes of Execution)
1. Interactive Mode
- Used for small commands
- Executes immediately
Example:
>>> print("Hello")
Hello
2. Script Mode
- Used to write full programs
- File saved as .py (example: program.py)
1.4 Writing Your First Python Program
Program:
print("Welcome to Python")
Output:
Welcome to Python
The print() function is used to display messages.
1.5 Comments in Python
Comments are notes written for humans, ignored by Python.
Single-line comment
# This is a comment
Multi-line comment
"""
This is a multi-line comment
"""
1.6 Variables
Definition:
A variable is a name used to store data in the computer’s
memory.
It works like a box or container that holds a value.
Example:
name = "Asha"
age = 12
Here:
name → variable storing a
string
age → variable storing a number
Rules for Naming Variables
- Cannot start with a number
- No spaces allowed
- Only letters, digits, and underscore
- Case-sensitive (Age ≠ age)
- Should not use Python keywords
1.7 Data Types
Data types tell what kind of value a variable holds.
Common Data Types in Python
|
Data Type |
Example |
|
Integer (int) |
20, 45 |
|
Float |
3.5, 9.8 |
|
String (str) |
"Hello", 'A' |
- price = 50 # int
- rating = 4.5 # float
- student = "Aditi" # string
- is_pass = True # boolean
1.8 Keywords
Definition:
Keywords are special reserved words in Python with
predefined meaning.
You cannot use them as variable names.
Examples:
if, elif, else, while, for, True, False, break, class, import
1.9 Identifiers
Identifiers are names given to variables, functions, classes,
etc.
Examples:
- student_name
- totalMarks
- sum1
Identifiers must follow the variable naming rules
(already taught).
1.10 Input and Output in Python
Output → Using print()
print("Python is fun!")
Input → Using input()
name = input("Enter your name: ")
print("Hello", name)
1.11 Python as a Calculator
print(10 + 5)
print(12 - 7)
print(6 * 4)
print(25 / 5)
1.12 Summary
- Python is a simple, powerful programming language.
- It can run in interactive or script mode.
- print() displays output on the screen.
- Comments help explain the code.
- A variable stores data (important concept).
- Data types include int, float, string, boolean.
- Keywords are reserved words and cannot be used as variable names.
- Identifiers are names for variables, functions, etc.
- The input() function takes user input.

