Python Introduction
Python Introduction
Python Introduction
UNIT : 2
PYTHON
INTRODUCTION
In C++ In Python
int a=2, b=3, tmp; a,b=2,3
tmp=a; a,b=b,a
a=b;
b=tmp;
• It is interpreted not compiled, thus executes code line by line
and it makes python easy-to-debug and suitable for beginners
and advanced users
• When you install Python, you get everything i.e. you don‟t need
to install additional libraries. All functionality is available with
Python additional library. Features like web-pages, database
connectivity, GUI features are available in Python standard
library. Python follows – “Battery included” philosophy
• Python can run equally well on variety of platforms – Windows,
Linux/UNIX, Macintosh, supercomputers, smart phones. Python is
portable language.
Interactive Mode
(Immediate
Python working Mode)
Ways
Script Mode
The default installation of CPython comes with Python
Interpreter, Python IDLE and pip(package installer). To work in
either interactive mode or script we need to open Python
IDLE
To work in interactive mode, follow the process given below:
(i) Click start button All Programs Python 3.6.x IDLE
Or
Click start button All Programs Python 3.6.x Python
(command line)
Interactive modes – one command at a time
Python executes the given command and gives the output.
In interactive mode we type command at IDLE prompt ( >>> )
For e.g if you type 20 + 30 in from of IDLE prompt
>>> 20 + 30 (command give by user)
50 (output given by python)
From the above example you can see than at >>> we have to
just give the command to execute and python we execute it if it
is error free otherwise gives an error.
( )
( )
( )
( )
( )
print (“Hello”)
Script Mode – multiple commands can be saved in a file as a
program and then we can execute the entire program
we type Python program in a file and then use the interpreter
to execute the content from the file.
Working in interactive mode is convenient for beginners and for
testing small pieces of code, as we can test them immediately.
But for coding more than few lines, we should always save our
code so that we may modify and reuse the code
In Python IDLE :
Click File New
In new window type the commands you want to save in program
For example:
print(“Hello World!”)
(c) (d)
Johny Johny Yes Papa This is my first program
No Papa Johny Johny Yes Papa
No PapaLittle Star
VINOD KUMAR V
(a) “Sayonara” (b) „Sayonara‟
(c) “Sayonara‟ (d) „Sayonara”
(e) {Sayonara}
• Who developed Python Programming Language?
• Is Python Object Oriented Language?
• Python is a high level interpreted language. What does it means
• What does cross-platform means?
• Python is free and open source. What do you understand by
this feature?
• What is the difference in interactive mode and Script mode in
Python?