DevAcademia
C++C#CPythonJava
  • Python Fundamentals

  • Introduction to Python
  • Getting Started with Python
  • Python Syntax
  • Python Comments
  • Python Variables
  • Python Data Types
  • Python Numbers
  • Python Casting
  • Python Strings
  • Python Booleans
  • Python Operators
  • Python Lists
  • Python Tuples
  • Python Sets
  • Python Dictionaries
  • Python If...Else
  • Python Match
  • Python While Loops
  • Python For Loops
  • Python Functions
  • Python Lambda
  • Python Arrays
  • Python OOP

  • Python OOP
  • Python Constructors
  • Python Destructors
  • Python Classes/Objects
  • Python Inheritance
  • Python Polymorphism
  • Python Quiz

  • Python Fundamentals Quiz
  • Python Fundamentals

  • Introduction to Python
  • Getting Started with Python
  • Python Syntax
  • Python Comments
  • Python Variables
  • Python Data Types
  • Python Numbers
  • Python Casting
  • Python Strings
  • Python Booleans
  • Python Operators
  • Python Lists
  • Python Tuples
  • Python Sets
  • Python Dictionaries
  • Python If...Else
  • Python Match
  • Python While Loops
  • Python For Loops
  • Python Functions
  • Python Lambda
  • Python Arrays
  • Python OOP

  • Python OOP
  • Python Constructors
  • Python Destructors
  • Python Classes/Objects
  • Python Inheritance
  • Python Polymorphism
  • Python Quiz

  • Python Fundamentals Quiz

Loading Python tutorial…

Loading content
Python FundamentalsTopic 2 of 77
←PreviousPrevNextNext→

Python Installation

Before you can start coding in Python, you need to install it on your computer. Python is available for all major operating systems and can be installed in several ways: - **Official Python Installer**: Recommended for most users from [python.org/downloads](https://www.python.org/downloads) - **Package Managers**: Homebrew (macOS), apt/yum (Linux), Chocolatey (Windows) - **Anaconda Distribution**: Bundles Python with many scientific libraries - **Windows Store**: Official Python package available through Microsoft Store

Installation Guide

Follow one of these methods depending on your platform: - **Windows**: Use the installer from python.org (check 'Add Python to PATH' during installation) - **macOS**: Use Homebrew (`brew install python`) or the official installer. Some macOS versions ship with an older Python, so install Python 3 separately. - **Linux**: Use your package manager (`sudo apt install python3` or `yum install python3`). Run `python3` instead of `python` if needed. - **All Platforms**: Use Miniconda if you want environment management without the full Anaconda distribution.

Note: Python 3.8 or newer is recommended for all new projects.

Verifying Your Installation

After installation, check if Python is installed correctly by running the version command in your terminal or command prompt.

Example
python --version
# or
python3 --version
Output
Python 3.10.6

Choosing a Code Editor

You can write Python in any text editor, but specialized tools make development easier: - **VS Code**: Lightweight and extensible with Python support - **PyCharm**: Full-featured Python IDE (Community edition is free) - **Jupyter Notebook**: Interactive coding environment, great for data analysis - **Sublime Text**: Lightweight editor with Python plugins - **Vim/Emacs**: Popular terminal-based editors for advanced users

Note: Most editors require installing a Python extension or plugin for full functionality.

Your First Python Program

To confirm your setup, write the classic 'Hello, World!' program: 1. Create a file named `hello.py` 2. Add the code below 3. Run it from your terminal with `python hello.py` (or `python3 hello.py`)

Example
# This is a comment
print("Hello, World!")
Output
Hello, World!

Python Package Management

Python uses `pip` (package installer for Python) to install and manage external libraries.

Example
# Install a package
pip install package-name

# List installed packages
pip list

# Upgrade pip itself
python -m pip install --upgrade pip

Virtual Environments

Virtual environments isolate dependencies per project. This prevents conflicts between packages required by different projects.

Example
# Create a virtual environment
python -m venv myenv

# Activate it (Windows)
myenv\Scripts\activate

# Activate it (macOS/Linux)
source myenv/bin/activate

# Deactivate when done
deactivate
Note: Always use virtual environments when starting real projects.

Next Steps

With Python set up, you can: - Learn basic syntax (variables, loops, functions) - Explore the standard library - Install packages like `requests` or `numpy` - Practice using virtual environments - Engage with Python communities for support You're now ready to begin your Python journey! The following lessons will cover core programming concepts.

Python FundamentalsTopic 2 of 77
←PreviousPrevNextNext→