Introduction to Python

What is Python?

Python is a high-level, interpreted programming language known for its simplicity and readability. It was created by Guido van Rossum and was first released in 1991. Python supports multiple programming paradigms, including procedural, object-oriented, and functional programming.

Key Features of Python:

  • Easy to Learn: Python has a simple syntax which is easy to read and write, making it an ideal choice for beginners.
  • Extensive Libraries: Python comes with a vast standard library and community-contributed packages for diverse fields like web development, data analysis, and machine learning.
  • Cross-Platform: Python is available for all major operating systems, such as Windows, macOS, and Linux.
  • Dynamic Typing: Python dynamically determines the data type of variables during runtime.
  • Open Source: Python is free to use and has a strong, active community.

Installing Python

To install Python:

  • Visit python.org and download the latest version for your operating system.
  • During installation, ensure that the option “Add Python to PATH” is selected.

Verify the installation by opening a terminal or command prompt and typing:

python --version

Running Python Code

You can run Python code in two modes:

  • Interactive Mode: Open the Python shell by typing python in the terminal.
  • Script Mode: Write Python code in a .py file and execute it using the command python filename.py.

Example: Hello World

# A simple Python program
print("Hello, World!")

Output:

Hello, World!