0% found this document useful (0 votes)
12 views

Python LEC 1 Introduction

This document provides an overview of Python programming including: 1. An introduction to Python defining it as a high-level, general-purpose programming language used to communicate with computers. 2. Examples of Python uses like game development, software development, web development, and graphics. 3. Reasons for using Python including its simplicity, portability, requiring less coding than other languages, and large standard library.

Uploaded by

4541 AizaHashmi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Python LEC 1 Introduction

This document provides an overview of Python programming including: 1. An introduction to Python defining it as a high-level, general-purpose programming language used to communicate with computers. 2. Examples of Python uses like game development, software development, web development, and graphics. 3. Reasons for using Python including its simplicity, portability, requiring less coding than other languages, and large standard library.

Uploaded by

4541 AizaHashmi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

PYTHON PROGRAMMING

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.

7. Finally, python is downloaded on your computer, Click close to close this


window.
Using Python IDLE:
Search IDLE on your computer’s search bar and then click on IDLE or press enter
key on your keyboard to open python IDLE where we’ll write our program.
Python IDLE will open as shown below. This window is also called Python shell
or Python prompt window. Python prompt appears as >>> (Triple greater than
sign) We can type Python statements here.

We can make Python programs in two modes:


Interactive Mode
Script Mode
1. Interactive Mode
In Interactive mode, we can directly type Python statements in a Python shell and
get output immediately.
We can use Python statements at >>> prompt to get output as given below:

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:

We can type Python statements in this window as follows:

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.

We can specify the file name as per our choice.


Running a script/Module/file
After creating a Python script or file we need following steps:
1. Click on File-> Open and select the Python script file you want to run. If
it is already open you can directly jump to step 2.
2. Click on Run->Run or Press function key F5 to run the script

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.

Your First Program:

You might also like