Python LEC 1 Introduction
Python LEC 1 Introduction
Lecture# 1
Lecture Content
1. Introduction To python
2. Getting Started with Python
3. Comments
4. Your First Program
Introduction To Python:
What is Python?
Python is a high-level, general-purpose, and popular computer
programming language.
A programming language is a computer language that is used by
programmers (developers) to communicate with computers. In addition, it’s
like a set of instructions that tells the computer what to do.
High-Level languages are languages that are easy to understand by humans.
Uses Of Python:
As python is a general-purpose language, it has many uses but some are
illustrated below:
Game Software
Development Development
Python
Web Graphics
Development
Why Python?
Python has many advantages over other languages, some of which are described
below:
Simplicity: Python has a simple syntax similar to the English language.
Portable: Python is portable in the sense that the same code can be used on
different machines. Suppose you write Python code on a Mac. If you want to
run it on Windows or Linux later, you don't have to make any changes to it.
Needs Less Coding: Python has a syntax that allows developers to write
programs with fewer lines than some other programming languages.
Large Standard Library: Python provides a rich set of libraries by which
there is no need to write code for each and everything.
Getting Started with Python:
How To Download Python IDLE (Integrated Development
Environment)?
1. Go to this website by clicking on this link: https://www.python.org/.
2. Click on Downloads. Different options will be shown. You can choose the
version you want to download as per your operating system and if you use
windows then click on Download Python 3.11.1.
3. Double-click on the Python installer downloaded on your computer. The
dialog box will appear as follow and then click on the Run button to
continue the installation.
4. Dialog Box will appear as. Click on Install Now and tick the checkboxes as
well.
5. Python installation will start and the following window will appear.
6. When installation gets completed, the following window will appear.
The main drawback of Interactive mode is that we can’t save Python statements.
So, we need to type Python statements again if we want to get the same output.
2. Script Mode
In script mode, we can save the Python statements in a file. Python statements
written in this file will run consecutively one after another.
Creating a script/module/file
To create a Python script or file we need to follow the following steps:
Click on File-> New File from Python IDLE as:
A new window will appear as:
Then we need to save the file with extension .py. We can click File->save or
shortcut Ctrl+S to save the file as follows:
On clicking File->Save following dialog box will appear.
The output of the script will be displayed in the Python shell as:
Comments:
Comments in Python are the inclusion of short descriptions along with the code to
increase its readability.
Single-Line Comments: It begins with the “#” character. The syntax for writing
single-line comments is:
# Comments here
Multi-Line Comments: It begins with either a ‘’ or “” quotation marks three
times.