You are on page 1of 13

PYTHON

INTRODUCTION ABOUT PYTHON:


Paradigm: Multi paradigm, object oriented, imperative
function,
procedural, reflective.
Designed by: Guido Van Rossum.
Developer: Python Software Foundation.
First Appeared: 20 February 1991, 25 years ago stable
release: 3.5.1/7
December 2015.
File Extension: .py .pyc .pyd .pyo .pyw .pyz
Python is a high level language or dynamic programming
language. This language is less complicated than any
other language like c++ or java. This language provides
us the clear idea about both the small as well as large
scale programs. The Python language is used for rapid
prototyping.
Python is Dynamic type language, where we can give our
variable names and allocate or assign values to them.
Python is considered as interpreted language, it doesnt
have a compiler.
Since they have interpretation, Python and similar
languages are used for (Rapid application development)
and for program prototyping

LECTURE 1 (INSTALLATION) 13 SEPTEMBER


2016 16:00pm

Installation procedure of PYTHON in Windows:


STEP 1: Open the Browser and go to following link
https:// www.python.org
STEP 2: Then download the second option with a version
of

[2.7.11] python.

STEP 3: Then save the file of this version as


Python.msi file
STEP 4: Open the saved .msi file and run this software
then click on next option and install the software.
STEP 5: Now a dialogue box will open to change the
directory of the software.
EX: D: /python27/
STEP 6: Then proceeding on above by clicking next
option.
STEP 7: Then a black screen will occur i.e. the command
prompt will occur, with the directory D: / python27/
python.exe
STEP 8: Then a finish wizard will come and the installation
completes.

SETTING UP PATH:
STEP 1: Now moving to the resource folder of python
file.

STEP 2: Copy the path i.e. D: /python27/


STEP 3: Then moving towards the option my computers
then by open the properties by right click on it

then choosing the advance system setting


go
through the environment variables shown at the bottom
then by choosing the advance option edit the path
from system variables.
Variable name: Path
Variable value: . /;/ python27/
CONDITION: If the admin rights are absent then.
STEP 1: Edit the user path using the temp code as
Temp. /; D:/ python27/
STEP 2: Then by choosing ok ok close.
STEP 3: Then by searching power shell in computer as
windows power shell(X86)
STEP 4: The dialogue box of windows power shell opens:
PS D: /users/admin> python
Python 2.7.11 (v2.7.11.6d, b6968f775, Sep 13 2016
16:30) (64 bit (Intel)
STEP 5: The print function follows as:

>>>> print hello world!


world!) OUTPUT

(hello

>>>> quit () then press enter.

STEPS TO DOWNLOAD NOTEPAD-PLUS-PLUS


FOR PYTHON PROGRAMS
STEP 1: Go to web Browser https:// www.notepad-plusplus.org
STEP 2: Then download the latest version by clicking on
the link DOWNLOAD.
STEP 3: Then download the .exe file.
STEP 4: then by open the reference downloaded file and
run that file.
STEP 5: Then choose ENGLISH then select OK then
opt the new notepad++ V6.8.8 setup then proceed to
next then choose I agree then moving towards the
installation path change it accordingly.
D: next next create shortcut on desktop then
install finish
STEP 6: The shortcut created on the desktop notepad++
its easy to use the syntax highlighting feature.
STEP 7: Create a new folder to save all python programs.
STEP 8: Name that folder as python program.
#) Write a sample program in notepad++ & save it in the
program & run it.

Program of writing hello world:


Print hello world!
world.py

save it with name

Save as type: python file (*.py , .*pyw)


on (save)

hello

then click

STEP 1: Go to the windows power shell from search


option.
STEP 2: Navigate the position of folder.
a) PS D: / users admin> cd D:/python27/ python
programs
b)PS D: /python27/ python programs> python
helloworld.py
STEP 3: Then press enter.

LECTURE 1 (VARIABLES)
2016 20:20pm

13 SEPTEMBER

STEP 1: Variables print statement in python; it is used to


print a value given to it.
EX:

>>>> print Mohit


Mohit

STEP 2: Now print a number


statement can print

# Print
>>>>

anything.
45
decimal, alphabets.

print

45

EX: A no. ,

STEP 3: Now print a decimal


>>>> print 6.7
6.7
STEP 4: Use of comma
>>>> Print Mohit, 45

Mohit 45

#) to check type of value then we use python built in


function called type.
EX:

>>>> type (Mohit)


<type str>

EX:

>>>> Type (45)


< type int >

Use help for more type functions


1)>>>> help () ] help console
2)Q then enter ] for quit help console & inter
enterpreter.

#) to use variable
Variable is a name given to value
EX: >>>> name = Mohit
>>>> Height =6.3
>>>> Age = 32
>>>> type ( name)
< type str>
#) NOTE: Everything given in single quote is string
either float or innt value.
EX: >>>> type (32)
< type str
# NAVIGATE THIS PROGRAM
PS D: /users/admin>cd D: /python27/python programs
PS
D:
/python27/python
stringquotes.py

programs>python

# RULES TO FOLLOW FOR VARIABLE ALLOCATION:


1)A variable name can be composed of letters and
numbers but it cannot start with a number.

EX: >>>> ben10 = cartoon


2)Special characters cannot be used in variable
names.However,an underscore _ can be used in it.
EX:

>>>> ben_10 = cartoon


>>>> _ben10 = cartoon

3)Pythons keywords cannot be used as variable


names.
4)Python has 31 keywords.
OPERATORS:
1)Used for arithmetic operations
EX: >>>> 3+4
7
EX: >>>> 3*4
12
EX: >>>> 3-4
-1
EX: >>>> 5/2
2 float division

# ORDER OF OPERATION
P PARENTHESES
E EXPONENTIATION
M MULTIPLICATION
D DIVISION
A ADDITION
S SUBSTRACTION
EX: >>>> 5*(6+3)/9-3 2
#) HOW TO MAKE INPUT FROM USER
By using raw_input
EX: what is your name boy?
>Mohit
>>>> Print name
Mohit
#) /n symbol is used to add new line.
PS
D:
inputs.py

/python27/python

#) function for comment in python


Try & except block

programs>python

Try:
Except:
Print please enter numbers

LECTURE 1 (BOOLEAN EXPRESSION)


SEPTEMBER 2016 22:40pm

13

A Boolean Expression is an expression which is either true


or false.
EX:

>>>> 1==1 comparison operators

a)

True
B

>>>> 1>2
False

#) COMPARISON OPERATORS
X==y
X!=y
X<y
x>y
x<=y
x>=y
x is y
x is not y
# Logical operator
and both side should be true

or if both side false then false


not gives true if expression is false otherwise true.
[Not>and>or]
# condition execution
1)If statement
EX: X =3
If x<3:
Print x is less than 3
If x==3:
Print x is equals to 3
# save program by:
File name: if example.py
Save as: python file (*.py *.pyw)
# CONDITIONAL STATEMENT
B=3
If x<3
Print x is less than 3
Else:
If x>3:

Print x is greater than 3


Else:
Print x is equals to 3

You might also like