Getting Started With Python
Getting Started With Python
Getting Started With Python
UNIT- 2 CHAPTER 2
• Software development
• Web development (server-side)
• System scripting
• Mathematics
Features of Python
1. Easy to use – Due to simple syntax rule
2. Interpreted language – Code execution & interpretation line by line
3. Cross-platform language – It can run on windows,linux,macintosh etc. equally
4. Expressive language – Less code to be written as it itself express the purpose of
the code.
5. Completeness – Support wide rage of library
6. Free & Open Source – Can be downloaded freely and source code can be
modify for improvement
Limitations of Python
1. Lesser libraries – as compared to other programming languages like
c++,java,.net
2. Slow language – as it is interpreted languages, it executes the program
slowly.
3. Weak on Type-binding – It not pin point on use of a single variable for
different data type.
Let’s Start Exploring 😊
https://www.python.org/downloads/
1. Click Download
2. Run the file
3. Select Add Python to PATH
4. Click Install Now
5. Next
6. Next
7. And you are Done
Don’t Forget to Select This
Programming Environment
• The default graphical development environment for Python is IDLE.
(Integrated Development and Learning Environment)
• IDLE comes with the Python installation.
• pip is the preferred installer program which is also included by default.
• PyCharm, PyDev, Spyder are other popular IDE’S
(Integrated development environment)
INTERACTIVE MODE
(PYTHON SHELL)
PYTHON
SCRIPT MODE
(PYTHON EDITOR)
Interactive Mode
Click start button -> All programs -> python <version> -> IDLE
Click start button -> All programs -> python <version> -> Python.exe
Interactive Mode
• The interactive mode involves running your codes directly on
the Python shell (Interpreter)
• As soon as we press enter, the interpreter executes the statement and displays
the result
• Interactive mode is handy when you just want to execute basic Python
commands (One command at a time, Immediate Output)
• we cannot save the statements for future use
Python Shell
Example of Special Literals in Python Python has one special literal called 'None'. The
name = None 'None' literal is used to indicate something that
has not yet been created
String Literals
Single Line Strings
Strings we create using single or double quotes are normally single line.
They terminate in one single line.
Subject=“python”
Subject=“python
“
EOL Error: By default python creates strings with both quotes and it must terminate
in the same line by quotes
String Literals
Multi Line Strings
We use multiline strings in python to store some text across multiple lines.
Two ways – Escape character as EOL or triple quotes
Subject=“python\
is interesting“ Subject=“””python
is interesting”””
print(Subject) print(Subject)
OUTPUT OUTPUT
python is interesting python
is interesting
String Literals
• Size of string = No. of characters in it
• Escape sequence is counted as one character
Floating Literals
• Fractional Form: signed or unsigned with decimal part
• E.g. 14.1, -121.0, 0.7
• Exponent Form: it consist of two parts “Mantissa” and “Exponent”
E.g. 25.5 = 0.255 * 102
= 0.255E02
Mantissa=0.255, Exponent=02
Escape Sequences
• Similarly, there are other relational operators like < = and > =
Assignment Operator
• Similarly, there are other assignment operators like *=, /=, %=, / / = , and
**=.
• Known as Augmented Assignment Operators / Short Hands
Logical Operators
Membership Operators
The membership operators in Python are used to validate whether a value is
found within a sequence such as such as strings, lists, or tuples
Eg: Str=“test”
print(“t” in Str)
Membership Operators
Identity Operator
is operator
Returns true if both variables point to
the same object and false otherwise
Eg: X is Y
is not operator
Returns false if both variables point to
the same object and true otherwise
Eg: X is not Y
Identity Operator v/s = = Operator
• Identity operator ( “is” and “is not” ) is used to compare the object's
memory location. '==' compares if both the object values are
identical or not
X= 10 145465654 133365654
Y= 10
Z 10 10
Z= X
print(X==Y) True X
print(X is Y) False Y
print(X==Z) True
print(X is Z) True
Operator Precedence
Precedence is used
to decide ,which
operator to be
taken first for
evaluation when
two or more
operators comes
in an expression.
5. Punctuators