Mastering Python Programming | Introduction – Lesson 1

Python programming, also known as coding, is a set of instructions that a user gives to a computer to tell it how to perform a specific task. This can be done with many different programming languages. In this series of lessons, we are focusing on Python programming.

Grammarly Writing Support

Think of adding 4 and 5. However, without programs, the computer is no more than plastic, metal, and wires with electricity passing through. Programs are how the computer knows how to perform this task.

Some examples of the tasks the computer performs would be:

  • Having a specific text being displayed on the computer monitor/screen;
  • Perform complex or simple calculations;
  • Controlling any type of electronic device, etc. 

There are many different types of programming languages, such as C, C++, Pascal, JavaScript, Java, and Python. In this series, we will focus on Python; however, we also have some Pascal lessons that may interest you.

Keep reading to learn:

  • What Python programming is;
  • Learn 4 reasons why you ought to learn Python; and
  • Find out what compilers are available for your operating system and where you can download a few.

What is Python programming?

Python is a high-level programming language. It is well known in the programming community for being easy to use and understand, and for its clear syntax. 

A computer screen with codes to represent python programming.

Why learn Python

There are many different reasons to learn Python. Whether you are a new programmer or a programming expert, Python’s widespread use makes it an important language to know. Here are some great reasons to embrace this language:

  1. Python is beginner-friendly; it can be read like English, which makes it easy to understand and write. You can do more with fewer lines of code when compared to other programming languages.
  2. Python can be used in multiple areas of programming, for example:
    • Web development;
    • Automation and scripting;
    • Cybersecurity;
    • Software testing; and
    • Data science and machine learning.

Python is great for rapid development and prototyping of new applications, as it allows you to build and test ideas quickly without dealing with all of the complex operations that would come with lower-tier programming languages.

Where to write Python code

Python codes can be written in text editors such as Notepad, which comes with your Windows computer and Notepad++, TextEdit for macOS, and gedit for Linux. Additionally, if you prefer, you may use one of the many Pascal online editors to write and run Pascal programs.

Installing Python and setting up the IDLE/VS CODE

Unless you plan to use an online compiler or your computer comes with one preloaded, you will need to install one. Installing a Python compiler and setting up IDLE/VS CODE is a simple process.

Here is a step-by-step for doing it:

  1. Step 1: Downloading and installing a Python Compiler 
    • Go to the official website for Python.
    • Download the version that best suits your operating system.
    • Run the installer on your pc.
    • Click on the section that says: Add Python to path.
    • Click on: Install Now
    • Please wait for it to complete, then click close.
  2. Verify Python installation
    • Open terminal (Mac/Linux) or command prompt (Windows)
    • Type in python – -version or python3 – -version,
    • Python 3,2, or 1 should be visible to users.
  3. Use Python IDLE (it comes attached to Python).
    • IDLE is installed with the Python installer.
    • Search your PC for IDLE and open it,
    • You will see a window that says:  >>>,
    • That is the Python shell, and you can start typing the code directly.
  4. Step 4: install VS CODE:
    • Go to the VS Code website.
    • Download and install the best version for your operating system software.
    • Launch VS Code. It can be launched automatically if set to launch while it’s being installed.
  5. Step 5: Install the extension for Python in VS Code:
    • Open VS Code.
    • Click the extension on the left or click Ctrl+Shift+x.
    • Use Microsoft to search for Python.
    • Click install.
  6. Configure Python in VS CODE, step 6:
    • Open a new folder or create a new Python file.
    • If VS Code does not detect Python, then press: command+shift+p for Mac or ctrl+shift+p for Windows.
    • Python: select interpreter.
    • Choose 3. x.x (your-path).

That is it. You have finished setting up your Python compiler.

Write your first Python program

The first program a novice programmers usually learn is a simple print statement.

Whether you are using an online compiler or have installed one on your computer, the steps to write your first program are laid out below:

Using VS CODE

  • Open and create a .py file.
  • Type:
    • print(“Hello world!”);
  • Right-click on the editor and run the Python file in the terminal.
  • You should see Hello world! displayed on the screen
  • That’s it.

That’s it.

Using an online compiler

Alternatively, if you are using an online compiler, you simply need to type print(“Hello world!”).

Click run. You should now see Hello World! displayed on screen.

Congratulations, you have written your first Python program.

Point to note

Coding takes practice, and making mistakes is part of the process. Be sure to play around with your code to see what happens when you change the syntax. This will help you to understand the structure of the language, what can be changed, and what cannot.

For instance, if you look at this first program, you will notice that only what is in the uplifted commas has been displayed on the screen. Additionally, changing what appears within the uplifted commas does not affect the integrity of the program.

Each time you change your code, you need to recompile your program.

Exercise

  1. Write a small program that displays a 5-line conversation between you and your friend.
  2. Write a program that uses * to print a pattern to the screen.

Before you go

Python programming is great for novice programmers for many reasons. It is close to the spoken language, easy to learn, and widely used. Follow us in Lesson 2 to continue learning Python.

.

Leave a Comment