SCSA1211- Python Programming
SCHOOL OF COMPUTING
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
UNIT-I Python Programming – SCSA1211
1
,SCSA1211- Python Programming
INTRODUCTION
History of Python- Introduction to the IDLE interpreter (shell) -Expressions – Data Types -
Built-in function - Conditional statements - Iterative statements- Input/output -Compound Data
Types - Nested compound statements
1. Program
A program performs a task in the computer. But, in order to be executed,
a program must be written in the machine language of the processor of a
computer. Unfortunately, it is extremely difficult for humans to read or write a
machine language program. This is because a machine language is entirely
made up of sequences of bits. However, high level languages are close to
natural languages like English and only use familiar mathematical characters,
operators and expressions. Hence, people prefer to write programs in high level
languages like C, C++, Java, or Python. A high level program is translated into
machine language by translators like compiler or interpreter.
a. About Python
Python is a high level programming language that is translated by the
python interpreter. As is known,an interpreter works by translating line-by-
line and executing. It was developed by Guido-van-rossum in 1990, at the
National Research Institute for Mathematics and Computer Science in
Netherlands. Python doesn’t refer to the snake but was named after the famous
British comedy troupe, Monty Python’s Flying Circus.
The following are some of the features of Python:
2
,SCSA1211- Python Programming
Python is an Open Source: It is freely downloadable, from the link http://
python.org/”
Python is portable: It runs on different operating systems / platforms3
Python has automatic memory management
Python is flexible with both procedural oriented and object oriented
programming
Python is easy to learn, read and maintain
It is very flexible with the console program, Graphical User Interface (GUI)
applications, Web related programs etc.
POINTS TO REMEMBERWHILE WRITING A PYTHON PROGRAM
Case sensitive : Example - In case of print statement use only
lower case and not upper case, (See the snippet below)
Fig1. Print Statement
Punctuation is not required at end of the statement
In case ofstring use single or double quotes i.e. ‘ ’ or “ ”
Must use proper indentation:The screen shotsgiven below show, how
the value of “i” behaves with indentation and without indentation.
3
, SCSA1211- Python Programming
Fig 2 indentation
Special characters like (,),# etc.are used
() ->Used in opening and closing parameters of functions
#-> The Pound sign is used to comment a line
1.2 TWO MODES OF PYTHON PROGRAM
Python Program can be executed in two different modes:
Interactive mode programming
Script mode programming
4
SCHOOL OF COMPUTING
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
UNIT-I Python Programming – SCSA1211
1
,SCSA1211- Python Programming
INTRODUCTION
History of Python- Introduction to the IDLE interpreter (shell) -Expressions – Data Types -
Built-in function - Conditional statements - Iterative statements- Input/output -Compound Data
Types - Nested compound statements
1. Program
A program performs a task in the computer. But, in order to be executed,
a program must be written in the machine language of the processor of a
computer. Unfortunately, it is extremely difficult for humans to read or write a
machine language program. This is because a machine language is entirely
made up of sequences of bits. However, high level languages are close to
natural languages like English and only use familiar mathematical characters,
operators and expressions. Hence, people prefer to write programs in high level
languages like C, C++, Java, or Python. A high level program is translated into
machine language by translators like compiler or interpreter.
a. About Python
Python is a high level programming language that is translated by the
python interpreter. As is known,an interpreter works by translating line-by-
line and executing. It was developed by Guido-van-rossum in 1990, at the
National Research Institute for Mathematics and Computer Science in
Netherlands. Python doesn’t refer to the snake but was named after the famous
British comedy troupe, Monty Python’s Flying Circus.
The following are some of the features of Python:
2
,SCSA1211- Python Programming
Python is an Open Source: It is freely downloadable, from the link http://
python.org/”
Python is portable: It runs on different operating systems / platforms3
Python has automatic memory management
Python is flexible with both procedural oriented and object oriented
programming
Python is easy to learn, read and maintain
It is very flexible with the console program, Graphical User Interface (GUI)
applications, Web related programs etc.
POINTS TO REMEMBERWHILE WRITING A PYTHON PROGRAM
Case sensitive : Example - In case of print statement use only
lower case and not upper case, (See the snippet below)
Fig1. Print Statement
Punctuation is not required at end of the statement
In case ofstring use single or double quotes i.e. ‘ ’ or “ ”
Must use proper indentation:The screen shotsgiven below show, how
the value of “i” behaves with indentation and without indentation.
3
, SCSA1211- Python Programming
Fig 2 indentation
Special characters like (,),# etc.are used
() ->Used in opening and closing parameters of functions
#-> The Pound sign is used to comment a line
1.2 TWO MODES OF PYTHON PROGRAM
Python Program can be executed in two different modes:
Interactive mode programming
Script mode programming
4