Name derived from famous BBC comedy show namely Monty Python’s flying circus
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
1
| | |
| ||
| | |
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
2
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
3
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
4
In C++ | In Python |
int a=2, b=3, tmp; | a,b=2,3 |
tmp=a; | a,b=b,a |
a=b; | |
b=tmp; VINOD KUMAR VER | MA, PGT(CS), KV OEF KANPUR & |
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
5
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
6
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
7
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
8
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
9
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
10
Before we start working on Python we need to install Python in our computer. There are multiple distributions available today:
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
11
available as a part of ANACONDA.
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
12
After Python installation we can start working with python. In Python we can work in 2 ways:
Python working Ways
Interactive Mode
(Immediate Mode)
Script Mode
The default installation of CPython comes with Python
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
13
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)
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
14
>>> 20 + 30
50
(command give by user)
(output given by python)
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
15
)
( )
( )
(
(
)
( )
print (“Hello”)
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
16
program and then we can execute the entire program
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
17
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
18
Save the program and press F5
(
)
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
19
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
20
Type the below code in script file:
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
21
#My First Program print(“Hello World!”)
When you execute the script file output will be only Hello World
Note: the first line starts from # which makes line as a comment i.e. only for programmer information not for interpreter. Comments are ignored by interpreter
To print or display output Python 3.x provides print() function. Examples:-
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
22
print(“Welcome to Python”)
it will print Welcome to Python
print(„Python rocks!‟)
it will print Python rocks!
Note: Python allows both single quotation and double quotation to enclose string. In any case both opening and closing must be same.
print(„Look carefully”)
it will give error because both opening and closing quotes are different.
Note:
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
23
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
24
A JAGADEESHWARAN -Mavens-i Softech Solutions Pvt Ltd
25