Hello everyone and welcome to this amazing introductory lesson on python. If you are new to this platform, please do check out our previous lessons. If you are new in python, then this guide has been composed specifically for you (beginners and newbies) as you will be taken through your very first program. Hence, if you’re one, then kindly go through the lesson till the end.
In this lesson, we will discuss the following
- Getting started with python (what is python)
- Installation and setup of python
- First hello world code of python
- Windows
Download Python for windows by clicking the yellow block. The file name appears as python-3.9.0.exe (depending on the version you are downloading).
Open the file, a popup window will appear. Click run.
A window will appear for installation. Do you want to install Python? Click on install button.
It will require an additional space of the disk space after installation. So, make sure you select a path with enough free space.
After browsing the path where the Python will install, click on the install button and installation will start.
The setup completes.
- Mac OS X and linux
Most recent version of linux and python already has python installed in them. . However, if the already installed python is out of date, you can update it to the latest version of Python. Visit the same website as above https://www.python.org/downloads/ and download Python for your operating system. Follow the easy steps to install the python on your operating system
How to run python.
Before we start running our first Python program, it is important that we understand how we can run python programs. This simply means that we are making the computer process instructions/lines of codes.
- Immediate Mode
It is a way of running python programs that are not written in a file. We enter the immediate mode by typing the word python or py in the command line and which will instruct the interpreter to change into immediate mode. The immediate mode allows typing of expressions directly, and pressing enter generates the output. The sign below is the Python prompt:
>>>
- Script Mode
The script mode is used to process python information found in a file; the file is called a script.
- Integrated Development Environment (IDE)
An IDE provides a better way of writing and running Python programs. Some of the advantages of IDE include helping in removing repetitive work and simplify coding for beginners
Hello World is the most simple program you will ever write, but it is also the first program you will ever write in Python (or ever, if you have never programmed before). So get excited!
Start IDLE
Once you click on the python IDLE, you will see the shell screen
Go to the File menu and click file
Type in the following sentence in the shell screen
>>>print (“Hello World”)
On the file, menu click on Save As. Type the name of my first Program1.py
Go Run(found at the top of the python shell) and click Run to run the program.
The result (output) of the statement written above is program is “hello world”.
Explanation
Here is what has happened, the Print () is an inbuilt function, it is prewritten and preloaded for you and is used to display whatever is contained in the () as long as it is between the double quotes. The computer will display anything written within the double quotes.
Practice the following
a) print(“I am now a Python Language programmer!”)
b) print(“python programming is really cool!”)
c) print(“I want to study web programming”)
Comments
Post a Comment
Please do not enter any spam link in the comment box.