Difficulty: Beginner
Python is a high-level, interpreted programming language created by Guido van Rossum and first released in 1991. It emphasizes code readability with its use of significant indentation and a clean, expressive syntax. Python supports multiple programming paradigms including procedural, object-oriented, and functional programming.
Python has become one of the most popular programming languages in the world, consistently ranking in the top three across every major language index. Its popularity stems from its gentle learning curve, massive ecosystem of libraries, and versatility across domains like web development, data science, machine learning, automation, and scripting.
One key characteristic of Python is that it is an interpreted language. Unlike compiled languages such as C or Java, Python code is executed line by line by the Python interpreter. This means you can write a script and run it immediately without a separate compilation step, which makes the development cycle faster and more interactive.
To run your first Python script, you simply create a file with a .py extension and use the python command to execute it. Python also comes with an interactive shell (REPL -- Read, Eval, Print, Loop) where you can type expressions and see results immediately. This makes it an excellent tool for experimentation and learning.
Python uses a "batteries included" philosophy, meaning its standard library provides modules for a wide range of tasks -- from file handling and networking to regular expressions and data serialization -- without needing to install anything extra.
print("Hello, World!")
The print() function outputs text to the console. This single line is a complete, valid Python program. No boilerplate, no class wrappers -- just one function call.
print("Welcome to Python!")
print("Python is fun.")
print("Let's start coding.")
Python executes statements top to bottom, one line at a time. Each print() call outputs its text followed by a newline character by default.
# This is a single-line comment
print("Comments are ignored by Python") # Inline comment
# You can use comments to explain your code
# or temporarily disable lines
Comments start with the # symbol. Everything after # on that line is ignored by the interpreter. They are used to document code and make it easier to understand.
import sys
print(sys.version_info.major)
print(sys.version_info.minor)
The sys module provides access to interpreter information. sys.version_info gives you the major and minor version numbers. Most modern environments run Python 3.10 or above.
Python overview, Interpreted language, Running scripts, REPL