Back to Study Material Python

Python Introduction

Python is a high-level, general-purpose programming language created by Guido van Rossum and first released in 1991. It emphasizes readability and simplici...

Python Introduction

What is Python?

Python is a high-level, general-purpose programming language created by Guido van Rossum and first released in 1991. It emphasizes readability and simplicity, using indentation to define code blocks rather than curly braces or keywords. Python follows the philosophy that code should be easy to read and write, making it one of the most beginner-friendly languages available today.

Why Python is Popular

Python has grown into one of the most widely used programming languages in the world for several reasons. Its syntax is clean and close to plain English, which reduces the learning curve significantly. A massive standard library and a rich ecosystem of third-party packages mean that most common tasks already have well-tested solutions. Python is also cross-platform, running identically on Windows, macOS, and Linux.

Python Versions

Python 2 and Python 3 are the two major lineages. Python 2 reached end-of-life in January 2020, so all new projects should target Python 3. The two versions differ in important ways: in Python 3, print is a function (print("hello")), integer division with / returns a float, and strings are Unicode by default. Always confirm you are running Python 3 when following modern tutorials.

How Python Code Runs

Python is an interpreted language. When you run a script, the Python interpreter reads your source code, compiles it to bytecode (.pyc files stored in __pycache__), and then executes that bytecode on the Python Virtual Machine (PVM). This differs from compiled languages like C, where the compiler produces machine code before execution. The interpreted model makes development fast but can mean slower runtime for CPU-intensive tasks.

A First Python Program

The classic first program is simply: print("Hello, World!"). Save this line in a file named hello.py and run it with the command "python hello.py" in your terminal. Python executes the file top-to-bottom. The print function sends output to the standard output stream. Even this tiny example shows Python's philosophy: no semicolons, no boilerplate class or main function is required.

Exam Tip

Exam questions often ask about Python's key characteristics. Remember the four most tested points: Python is interpreted (not compiled to machine code), dynamically typed (variable types are determined at runtime), strongly typed (implicit type coercion between unrelated types is not allowed), and uses significant whitespace (indentation defines blocks). Confusing "dynamically typed" with "weakly typed" is a very common mistake.