Chapter 1: Introduction
1.1 How to Get Started with Python
Welcome to our comprehensive guide to getting started with Mastering Python Fundamentals – a step-by-step introduction to help you master the basics. Getting started with Python is straightforward, even if you’re new to coding or computers. Follow these step-by-step instructions to install Python on both Windows and Linux.
Installing Python on Windows
- Download Python:
- Visit the official Python website.
- Click the “Download Python” button to start the download.
- Run the Installer:
- Locate the downloaded file in your
Downloads
folder and double-click to start the installation. - Important: Check the box that says “Add Python to PATH” before clicking “Install Now.”
- Verify the Installation:
- Open Command Prompt by typing
cmd
in the Start menu. - Type
python --version
and press Enter. You should see the Python version number displayed.
Installing Python on Linux
- Open the Terminal:
- Press
Ctrl + Alt + T
to open the Terminal.
- Update Your System:
- Type the following command and press Enter:
bash sudo apt update
- Install Python:
- Install Python by typing:
bash sudo apt install python3
- Install Dependencies:
- Install
pip
by typing:bash sudo apt install python3-pip
- Verify the Installation:
- Check the Python version by typing:
bash python3 --version
With Python installed, you’re ready to start coding!
1.2 Your First Program
Now that Python is set up, let’s create your first program.
Step 1: Open Your Text Editor
- Use a text editor like Notepad on Windows or Gedit on Linux.
- On Windows, open Notepad by searching for it in the Start menu. On Linux, open Gedit by typing
gedit
in the Terminal.
Step 2: Write the Code
- Type the following code in the text editor:
print("Hello, World!")
- This simple line of code will display the message “Hello, World!” on your screen.
Step 3: Save the File
- Save the file as
hello_world.py
in a location you can easily find.
Step 4: Run the Program
- On Windows:
- Open Command Prompt, navigate to the file location using
cd
, and run the program by typing:bash python hello_world.py
- On Linux:
- Open Terminal, navigate to the file location using
cd
, and run the program by typing:bash python3 hello_world.py
You should see the message “Hello, World!” displayed on your screen, marking your first step into Python programming!
Read Next :
Free Coding Tutorials: Mastering Python Fundamentals – Part 2 : Variables, Constants and Literals; Type Conversion; Basic Input and Output