Python is a high-level, general-purpose, interpreted programming language created by Guido van Rossum in the Netherlands. Its first version, Python 0.9.0, was released in 1991, and the name was inspired by the British comedy show "Monty Python's Flying Circus", not by the snake. Python was designed with an emphasis on code readability; its syntax is clean, simple and closely resembles the English language, which makes it an ideal first language for beginners and a powerful tool for professionals.
Python is an interpreted language, meaning that an interpreter translates and executes the source code line by line at runtime, rather than compiling the entire program to machine code in advance. Python is also dynamically typed; the programmer does not declare the data type of a variable, and the type is determined at runtime from the value assigned. These features make Python extremely flexible and easy to debug, though generally slower than compiled languages like C. Python is free and open source, and it runs on almost every platform, including Windows, Linux and macOS.
Today Python is one of the most popular programming languages in the world. It is used for web development, data science, artificial intelligence, scientific computing, automation, game development and, of course, as the primary teaching language in Indian schools. This chapter introduces the student to the Python environment: how Python is organised, how to run programs, and the very first elements of the language, such as comments and the print function.
Python owes its popularity to a combination of excellent features:
Python software is distributed in the form of an interpreter package that includes the core interpreter and a standard library of modules. The official distribution can be downloaded from the Python Software Foundation website. On most GNU/Linux and macOS systems, Python comes pre-installed, but an updated version can be installed easily.
The most popular way to interact with Python for beginners is IDLE (Integrated Development and Learning Environment), which is bundled with the standard Python installation. IDLE provides an interactive shell, an editor window with syntax highlighting, and a debugger. Two common working modes exist in IDLE:
A Python program, called a script, is stored in a file with the .py extension. To execute it, the script file is given to the Python interpreter. There are several ways to run Python code:
python script.py (or python3 script.py on some systems).# This is my first Python program saved as first.py
print("Hello, World!")
print("Welcome to Computer Science Class 11")
When this script runs, the interpreter reads the file line by line, converts the statements into an intermediate form called bytecode, and executes them, producing the output shown on the screen. Python first converts source to bytecode, then the Python Virtual Machine executes it.
Comments are lines in the source code that are ignored by the interpreter. They exist to help human readers understand the program. Python supports two forms of comments:
# This is a single-line comment
print("Comment is ignored above")
'''
This is a multi-line string used as a docstring.
It can span several lines.
'''
print("Documentation done")
Comments do not affect the output of a program; they are purely for human readability. Good programmers use comments to explain the why, not the what, of their code.
The print() function is the standard way to display output in Python. It writes its arguments to the console. It can accept one or more values, separated by commas, and joins them with a space by default.
print("Hello")
print(42)
print("Result is", 42)
print("Class", 11, "Computer Science")
Key facts about print():
A character set is the set of valid characters that can be used in a Python program. Python's character set includes: - Letters: A-Z, a-z - Digits: 0-9 - Whitespace: space, tab, newline - Special symbols: + - * / % < > = ! & | ^ ~ , . ; : ( ) [ ] { } @ # $ etc.
The smallest individual units of a program are called tokens. Python breaks the source code into five types of tokens: 1. Keywords: Reserved words with fixed meanings such as if, else, while, for, def, import, True, False, None. They cannot be used as variable names. 2. Identifiers: Names given by the programmer to variables, functions, classes, etc. 3. Literals: Data values written directly in the program, such as 42, 3.14, "Hello", True. 4. Operators: Symbols that perform operations, such as +, -, , /, ==, <. 5. Punctuators (Delimiters):* Symbols used for grouping and separation, such as ( ) [ ] { } , ; :.
Keywords are reserved words whose meaning is fixed by the Python language. They cannot be redefined or used as identifiers. Examples include: False, True, None, and, or, not, if, elif, else, for, while, break, continue, def, return, import, from, class, in, is, lambda, try, except, finally, with, as, pass, del, global, nonlocal, raise, yield and assert.
Identifiers are the names used for variables, functions and other objects. The rules for forming a valid identifier are:
valid = 10 # valid
_valid = 20 # valid, leading underscore allowed
name_1 = "Aman" # valid
# 2nd_name = 5 # invalid: begins with a digit
# if = 10 # invalid: 'if' is a keyword
Although the language rules define what is legal, community conventions make code readable:
| Mode | Where | Best For |
|---|---|---|
| Interactive | IDLE shell / terminal (>>>) | Experimenting, quick checks |
| Script | IDLE editor / file with .py | Real programs, multiple lines |
| From terminal | python script.py |
Running saved programs |
| Token | Examples | Purpose |
|---|---|---|
| Keywords | if, while, def, True | Reserved words with fixed meaning |
| Identifiers | num, total, avg | User-defined names |
| Literals | 42, 3.14, "Hi", True | Data values |
| Operators | +, -, *, /, == | Perform operations |
| Punctuators | ( ) , : ; [ ] | Grouping and separation |
Getting started with Python means understanding not only the language but also the environment in which it runs. Python is a high-level, interpreted, dynamically typed language whose readable syntax makes it ideal for beginners. Programs are written as .py scripts and executed by the interpreter, which converts them to bytecode before running them in the Python Virtual Machine. Comments help document the code, and the print() function provides output. Every program is built from tokens: keywords, identifiers, literals, operators and punctuators, and identifiers must follow strict naming rules. With the environment and basics in place, the next chapter dives into Python fundamentals: variables, literals and operators in detail.