Python Basics

Python Get Started

Install Python, set up your development environment, and write your first Python script.

Installing Python

To check if you already have Python installed, open your terminal/command prompt and type:

python --version or python3 --version

If Python is not installed, download it from python.org.

The Python Command Line

You can test Python code directly in the Python Command Line (REPL):

Type python or python3 in your terminal, then type any Python code and press Enter.

Creating a Python File

Python files have the .py extension. To run a Python file, use the command:

python filename.py

Python Quickstart

Python is an interpreted language, which means that instead of compiling your code, Python code is executed line by line.

Using an IDE

For writing Python code, you can use:

  • VS Code with the Python extension
  • PyCharm — purpose-built Python IDE
  • DevForge Compiler — Run Python directly in your browser

Example

python
# Your first Python script (save as hello.py)
print("Hello, World!")

# Run with: python hello.py

# Or try more complex code
name = input("What is your name? ")
print(f"Hello, {name}! Welcome to Python.")

# Simple math
x = 10
y = 3
print(f"{x} + {y} = {x + y}")
print(f"{x} * {y} = {x * y}")
print(f"{x} / {y} = {x / y:.2f}")
print(f"{x} % {y} = {x % y}")
Try it yourself — PYTHON