You are on page 1of 6

Module 1: Installation Of Python

Introduction:
Python is a popular programming language. It was created by Guido van
Rossum, and released in 1991.
It is used for:
 Web development (server side)
 Software development
 Mathematics
 System scripting

Installation of python:
Process:
 Visit website python.org
 Downloads click and then windows
 Select version 3.6.2
 Click add python 3.6 and click customize installation click next
 In advance option select install for all users and click install button.
Python is recognized by ‘>>>’.
TOPIC 2: Using the python interpreter, IDLE  Integrated development environment.
OBJECTIVE:
 Use the python interpreter IDLE
 Basic program to display the text, hello world.
Using IDLE: Extension used for python ‘.py’
INTRODUCING VARIABLES:
anyname = input(“what is your name?”)
Print(“hello world! This is “,anyname)
Where anyname  variable.
NOTE:
 More than one comma separated value can appear within brackets of the print
function.
 A non-numeric value is included in inverted commas whereas a variable doesn’t
have inverted commas.

EX: >>> a = 20

>>>b = 10
>>> c = a*b
>>>c
200
TOPIC 3: Sailent features of python
OBJECTIVE:
 History of python
 Describe common features of python
 Difference between 2.X and 3.X
 Python is a popular high level programming language. According to TOIBE(The
importance of being earnest), python currently ranks in 4th.
 Python support multiple programming parameters:-
 Imperative
 Procedural
 Object-oriented
 Functional
 Python is also an open source software,many developers contribute tools
development.
Principle author: ’Guido van rossum’
Python community has given him BDFL(Benevolent dictator for life)

Design Philosophy Of Python:-


Summarized in 20 principles:
Some are:-

 Beautiful is better than ugly


 Complex is better than complicated.
 Simple is better than complex
 Explicit is better than implicit
 Readability counts

To see all the principles of python:


Open command prompt and type python, then type import this
Then all principles will be displayed on prompt.
Features of python:
 Enhanced readability
 Dynamic typing
 Interpreted language
 Extensible language
 Standard DB2 API
 GUI programming
 Embeddable
Difference Between 2.X And 3.X :
Python 2.X Python 3.X

*Not mandatory to use parenthesis *Parenthesis are mandatory with


With in-built print function. Print function.
*Valid Statement: *Valid Statement:
Print “Hello world” Print (“Hello world”)
Print (“Hello world”)
*String are stored as ASCII by default. *Stores string as Unicode by
default.

TOPIC 4: Basic Syntax Of Python


OBJECTIVE:
 Describe basic python identifiers.
 Add indents in the correct format
 Add comments in the correct format
What is syntax: Computers are machines that can interpret your instruction only if you type
them in exact format that the computer expects.
This expected format the spelling, formatting and grammar is called the
Syntax.

Identifiers:
o Keywords
o Indents
o Comments

Common to use programming elements such as:


Variables --------> _bookname, num1
Keywords ---------> if, while, yield
Functions ----------> print(), int(), len()
Classes ----------->complex, exception
Modules ----------->calender, random
Packages ---------->pillow, tkinter

Identifiers should start with lowercase, uppercase or underscore.

Invalid identifiers: 5number, *house, $value, )book


 Keywords: Are predefined words, it should be in lowercase ie,, if, while
 Class: Begins with uppercase ie,, Complex, Exception
 Private Variable: It begins with single underscore ie,, _adharnum, _accountnum.
 Strongly Variable: It begins with double underscore ie,, __mobilenum, __loginid
 Special purpose: _add_, _int_

Keywords:
 Reserved words and have a predefined meaning, keywords used for
programming instruction, and they cannot be used for identifiers.
 Python 3.6 has 33 keywords, Python 2 has 30 keywords, False, True,
None and Nonlocal are additional keywords.
 Python 3, print is no longer a keyword but a built in function.

To Display All Keywords We Use:


Start idle
>>>import keyword
>>>keyword. Kwlist

Some of the python keywords are as follows:


*False *Class *Finally *Is *Assert *Else
*None *Continue *For *Lambda *Import *While
*True *Def *From *Nonlocal *Break *Exc
*And *Del *Global *Not *Try *Yield
*As *Elif *If *Return
Indents:
Space at the beginning of a code line, Python uses indentation to separate the block of
code.
EX: i = 1
While (i<=6)
Print(“Value is” + str(i))
i = i+1

Comments:
Comments can be used to explain python code, comments can be used to make the code
more readable.
Comments does not have to be text that explains the code, it can also be used to prevent
python from executing code.
Comments starts with a ‘#’ and python will ignore them.
Comments can be placed at end of a line, and python will ignore the rest of the line.
EX: print(“Hello World!”) #this is a comment

Multiline comments:
Python does not really have a syntax for multi line comments, to add a multiline comment
you could insert a ‘#’ for each line.
EX: #this is a comment
#written in
#more than just one line
Print(“Hello, World!”)
Since Python will ignore string literals that are not assigned to a variable, You can add a
multiline string(triple quotes) in your code, and place your comment inside it.
EX: “ “ “
This is a comment
Written in
More than just one line”””
Print(“Hello, World!”)

You might also like