Python Tutorial / What Is Python? Features and Practical Uses

Python is a general-purpose programming language with readable syntax. You can use it to organize files, process data and build web services; this course connects the fundamentals through programs that accept, validate and store expense data.

Understand what runs a Python program

A program is a set of instructions that takes input, applies rules and produces a result. The Python interpreter is the program that runs Python source code. Saving a file with a .py extension does not by itself tell every operating system how to execute its contents.

For the relevant APIs and platform requirements, see Python: .

Task Example What else you need
Automation Find CSV files and calculate totals Input files and permission to read them
Data analysis Group expenses by category A package such as pandas when appropriate
Web services Return JSON for an HTTP request A web framework and a deployment environment

The core examples use Python 3.12 or later and emphasize data types, control flow, functions and input/output. They do not require every feature of the newest release. A mobile interface or a high-performance game engine involves additional tools and design decisions.

Installation and project isolation build on the rules demonstrated in Install Python on Windows and Verify the Interpreter and Set Up Python on macOS and Ubuntu.

Separate the editor, terminal and interactive prompt

An editor creates source files. A terminal accepts operating-system commands. The interactive Python prompt lets you try Python expressions directly. Enter python hello.py in the terminal and put print(...) in the file or Python prompt. Do not copy interactive prompt characters into a script.

Create a practice folder and save source files as UTF-8. Keep the code and its expected output together so you can compare them. Changing one value at a time makes it easier to identify which part of a program caused a different result.

Run a complete first example

Save the complete code below as hello.py in a separate practice folder, using UTF-8. Run python hello.py in a terminal with your project virtual environment selected. Outside a virtual environment on macOS or Ubuntu, use python3 when that is your interpreter command.

name = "Python"
amounts = [3500, 8000, 2500]
print(f"Hello, {name}!")
print("total:", sum(amounts))

Expected output:

Hello, Python!
total: 14000

Choose one installation route for your operating system, then create a separate virtual environment for each project. The installation commands differ between Windows, macOS and Ubuntu; the Python language exercises that follow use the same concepts.

Trace the values and make a controlled change

name refers to a text value; amounts contains three numbers in a list. The built-in sum() function adds those numbers. Follow the input, calculation and output before trying to memorize every syntactic detail.

  1. Change 8000 to 9000 and check that the total becomes 15000.
  2. Restore 8000. Change only the name Python and verify that the total remains 14000.
  3. If you add unexpected indentation at the beginning of a line and see an error, remove it before continuing.

A command-not-found message concerns the interpreter command or its path. A cannot-open-file message may concern the working directory or filename. Read the last line of the error first, then distinguish interpreter selection from source-file location.