Introduction to Python Programming
Introduction to Python Programming is the first step for Class 9 students who want to learn coding in a simple and practical way. Python is easy to read, easy to write, and widely used in schools, businesses, and technology companies.
Students who understand Python basics can later build websites, software, automation tools, and even business applications. That is why learning Python from Class 9 builds a strong technical foundation.

What is Python?
It is a high-level, general-purpose programming language. It uses simple English-like syntax, which makes it easy for beginners to read and write code. Furthermore, Python is an interpreted language, which means the computer runs each line of code one at a time without compiling the whole program first.
It is also an open-source language, so anyone can use it for free. It works on all major operating systems, including Windows, Linux, and macOS.
- It is easy to learn because its syntax is close to the English language.
- It is an interpreted language — you can run code line by line.
- Python is free and open-source.
- It supports multiple programming styles: procedural, object-oriented, and functional.
- Python files are saved with the
.pyextension.
History of Python Programming Language
Python was created by Guido van Rossum, a Dutch programmer. He started working on Python in the late 1980s and released the first version in 1991.Since then, Python has grown significantly and developers now use it all over the world.
- 1989: Guido van Rossum began developing Python during his Christmas holiday.
- 1991: The developers released Python 0.9.0 to the public for the first time.
- 1994: Python 1.0 launched with features like lambda, map, and filter.
- 2000: Python 2.0 introduced list comprehensions and garbage collection.
- 2008: The developers released Python 3.0 with major improvements and better Unicode support.
- Today: The Python Software Foundation maintains Python 3.x as the current version.
Interestingly, the name “Python” was not taken from the snake. Instead, Guido van Rossum named it after the British comedy show Monty Python’s Flying Circus. He wanted a short, unique, and slightly mysterious name for his language.
Features of Python
Python has several important features that make it stand out from other programming languages. Therefore, educators, researchers, and the software industry widely use it.
- Simple Syntax: Python code looks like plain English, so it is easy to read and understand.
- Interpreted: Python runs code line by line, which makes it easy to test and debug programs.
- Dynamically Typed: You do not need to declare the type of a variable. Python decides the type automatically.
- Object-Oriented: Python supports classes and objects for structured programming.
- Platform Independent: Python programs run on Windows, Linux, and macOS without any changes.
- Extensive Libraries: Python has a large collection of built-in libraries for math, files, internet, and more.
- Open Source and Free: Anyone can download, use, and share Python for free.
- Portable: You can run the same Python code on different computers and operating systems.
- Embeddable: You can use Python code inside programs written in other languages like C or C++.
- High-Level Language: Python handles memory and other system tasks automatically, so programmers focus only on logic.
Why Learn Python in Class 9?
Learning Python in Class 9 gives students a strong foundation in programming. Moreover, schools most widely teach Python because it is simple yet powerful.
- CBSE includes Python in the Class 9 and 10 computer science syllabus.
- Its simple syntax helps beginners focus on learning programming logic rather than memorising complex rules.
- Developers use Python in Artificial Intelligence, Data Science, and Web Development, so learning it early gives students a head start.
- Students can build small projects and games with Python from the very beginning.
- Python has a large online community, so finding help, tutorials, and examples is very easy.
- Knowledge of Python is also useful in competitive exams like Olympiads and coding competitions.
Applications
Python is a versatile language, and consequently, developers use it in almost every field of technology today. Here are the major areas where Python finds application:
- Web Development: Frameworks like Django and Flask use Python to build websites and web applications.
- Artificial Intelligence (AI) and Machine Learning: Python is the top choice for AI projects because of libraries like TensorFlow and Scikit-learn.
- Data Science: Data analysts use Python with tools like Pandas and NumPy to process and analyse large data sets.
- Automation and Scripting: Python automates repetitive tasks like renaming files, sending emails, and scraping websites.
- Game Development: Libraries like Pygame allow developers to create 2D games using Python.
- Scientific Computing: Researchers use Python for mathematical calculations, simulations, and data visualisation.
- Cybersecurity: Security professionals use Python to write tools for testing and protecting computer systems.
- Desktop Applications: Python helps developers build desktop software using libraries like Tkinter and PyQt.
Basic Syntax
Python has a clean and simple syntax. Unlike other languages, Python does not use curly brackets {} to define blocks of code. Instead, Python uses indentation (spaces or tabs). Therefore, proper spacing is very important in Python.
Key Syntax Rules
- Python is case-sensitive. For example,
Nameandnameare two different variables. - Each statement goes on a new line.
- Indentation (4 spaces or 1 tab) defines blocks of code inside loops, functions, and conditions.
- Comments begin with the
#symbol. Python does not execute them. - Strings go inside single quotes
'hello'or double quotes"hello".
Example of Indentation
if 5 > 3:
print("Five is greater than three")Adding Comments
# This is a single-line comment
print("Comments help explain the code")First Program
Traditionally, every programmer writes the Hello World program first. Similarly, in Python, you can display a message on the screen using just one line of code.
Program
print("Hello, World!")Output
Hello, World!
The print() function displays output on the screen. Furthermore, you can use it to print numbers, text, and results of calculations.
More Examples of print()
print("Welcome to Python")
print(10 + 20)
print("Sum of 5 and 3 is", 5 + 3)Output
Welcome to Python 30 Sum of 5 and 3 is 8
Keywords and Identifiers
Keywords
In Python, keywords are reserved words. They carry a fixed meaning and purpose in the language. Therefore, you cannot use them as variable names or function names.
- Python 3 has 35 keywords.
- All keywords are case-sensitive. For example,
Trueis a keyword buttrueis not.
Some commonly used Python keywords:
| Keyword | Purpose |
|---|---|
if | Handles conditional statements |
else | Works with if to handle an alternate condition |
for | Creates a loop |
while | Creates a while loop |
print | Displays output |
input | Takes input from the user |
True / False | Boolean values |
import | Imports a module |
def | Defines a function |
return | Returns a value from a function |
Identifiers
An identifier is the name you give to a variable, function, or class in Python. You create identifiers to label and use different values in your program.
Rules for writing identifiers:
- An identifier can contain letters (A–Z, a–z), digits (0–9), and underscores (_).
- It must start with a letter or an underscore, not a digit.
- Identifiers are case-sensitive. So
ageandAgeare different. - You cannot use a Python keyword as an identifier.
- Spaces are not allowed in identifiers. Use an underscore instead, e.g.,
student_name.
Valid identifiers: name, age1, _score, student_name
Invalid identifiers: 1name, student name, for, my-score
Variables and Data Types in Python
Variables
A variable is a named storage location in the computer’s memory. You use variables to store data that your program can use and change later. In Python, you create a variable simply by assigning a value to it using the = sign.
name = "Rahul" age = 14 marks = 95.5
Note that Python automatically detects the type of the variable. You do not need to declare the type separately. This feature is called dynamic typing.
Data Types
A data type tells Python what kind of value a variable holds. Python provides several built-in data types. The most common ones for Class 9 are:
| Data Type | Description | Example |
|---|---|---|
int | Integer (whole number) | age = 14 |
float | Decimal number | marks = 95.5 |
str | Text / String | name = "Rahul" |
bool | True or False value | passed = True |
list | Ordered collection of items | marks = [90, 85, 78] |
Checking Data Type with type()
You can use the type() function to check the data type of any variable.
x = 10 print(type(x)) # Output: <class 'int'> y = "Hello" print(type(y)) # Output: <class 'str'>
Input and Output
Output — print() Function
You use the print() function to display output on the screen. Additionally, you can print multiple values at once by separating them with commas.
print("My name is Rahul")
print("Age:", 14)
print("Marks:", 95.5)Input — input() Function
The input() function allows your program to accept data from the user during runtime. Python always stores the input as a string by default.
name = input("Enter your name: ")
print("Hello,", name)Taking Numeric Input
Since input() returns a string, you need to convert it to an integer or float to use it in calculations. You can do this using int() or float().
age = int(input("Enter your age: "))
print("You are", age, "years old.")Example Program — Simple Calculator
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
total = a + b
print("Sum =", total)Output
Enter first number: 10 Enter second number: 20 Sum = 30
Advantages and Disadvantages
Advantages
- Easy to Learn: Python’s simple syntax makes it the best language for beginners. As a result, students can start writing programs very quickly.
- Free and Open Source: You can download and use Python at no cost. Furthermore, you can share it freely.
- Large Standard Library: Python comes with thousands of built-in modules, so you do not need to write code from scratch for common tasks.
- Platform Independent: Python programs run on any operating system without modification.
- Versatile: Python works well in web development, AI, automation, data science, and many other fields.
- Strong Community Support: A large community of developers provides tutorials, forums, and free resources.
- Readable Code: Python code is clean and easy to read, which consequently makes maintenance and debugging simpler.
Disadvantages
- Slower Speed: Python runs slower than languages like C, C++, and Java because the interpreter executes it line by line, unlike compiled languages.
- High Memory Use: Python consumes more memory compared to low-level languages, which is a concern for resource-limited devices.
- Not Ideal for Mobile Development: Python is not commonly used for mobile app development.
- Runtime Errors: Since Python is dynamically typed, some errors appear only when you run the program, not before.
- Global Interpreter Lock (GIL): Python’s GIL limits the performance of multi-threaded programs.
- Not Suitable for Low-Level Programming: Developers do not use Python for system-level programming like writing operating systems or device drivers.
FAQs
Q1. Who created Python?
Guido van Rossum created Python. He began developing it in 1989 and released the first version publicly in 1991.
Q2. Why is Python called a high-level language?
Python is called a high-level language because it is closer to human language than machine language. It automatically manages memory and other low-level tasks, so programmers focus on writing logic.
Q3. What is the file extension for Python programs?
Python saves programs with the .py extension. For example, hello.py or calculator.py.
Q4. What is the difference between int and float in Python?
int stores whole numbers like 10, 25, or 100. float stores decimal numbers like 3.14, 9.5, or 100.0.
Q5. What is indentation in Python?
Indentation means adding spaces or tabs at the beginning of a line to show that it belongs to a code block. Python uses indentation instead of curly brackets to define blocks in loops, functions, and conditions.
Q6. What does the input() function do?
The input() function takes data from the user during the execution of a program. It always returns the data as a string. Therefore, you need to convert it to int or float for numeric calculations.
Q7. Is Python used in real jobs?
Yes, Python is one of the most in-demand programming languages in the job market. Companies use it for web development, data analysis, artificial intelligence, and automation.
Conclusion
Python is a powerful yet beginner-friendly programming language that every Class 9 student should learn. To summarise, Python offers simple syntax, dynamic typing, platform independence, and a wide range of applications in AI, web development, and data science. As a result, it is now a core part of the CBSE computer science curriculum. By understanding the basics — such as variables, data types, input/output, keywords, and identifiers — students build a strong foundation for advanced programming in higher classes. Therefore, start practising Python regularly, write small programs every day, and gradually you will become confident in your coding skills.
