PYTHON Tutorial

Installing Python

Key Concepts:

  • Download Python
  • Install Python
  • Configure IDE

Install Python:

Windows

  • Visit the Python website: https://www.python.org/downloads/
  • Download the latest stable Python version for Windows.
  • Run the installer and follow the on-screen instructions.
  • Check the "Add Python 3.x to PATH" option.
  • Click "Install Now".

macOS

  • Open the Terminal app.
  • Run the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/head/install.sh)"
  • Press Enter and enter your password when prompted.
  • Run the following command to install Python:
brew install python

Linux (Ubuntu)

  • Open the Terminal app.
  • Run the following command:
sudo apt-get install python3
  • Enter your password when prompted.

Setting Up the Development Environment:

  • Choose an IDE (Integrated Development Environment) like PyCharm or Visual Studio Code.
  • Create a new Python project.
  • Configure the IDE to use the installed Python version.

Simple Python Example:

# Hello World program in Python

print("Hello, world!")

Save the file as "hello_world.py".

To run the program:

  • Open the Terminal or Command Prompt app.
  • Navigate to the directory where the file is saved.
  • Run the following command:
python hello_world.py

This will print "Hello, world!" in the console.

Additional Tips:

  • It's recommended to use a virtual environment to isolate different Python projects.
  • You can upgrade Python by repeating the installation steps for the desired version.
  • Refer to the official Python documentation for more detailed instructions.