Python by Wipro
Python by Wipro
Python Introduction:
Python is a high level, Interpreted, Interactive and Object-Oriented
Scripting Language.
Python is designed to be highly readable.
Python is Interpreted:
Python is processed at runtime by Interpreter. You don’t need to
compile your program before executing it. This is similar to PHP.
X
Saif Panjeshah
Technical Consultant
Python is Interactive:
You can actually sit at python prompt And Interact with the
Interpreter, directly to write your programs.
Installation of python:
• choco install python –pre
• Anaconda Distribution:
https://repo.anaconda.com/archive/Anaconda3-2022.05-
Windows-x86_64.exe
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
Pycharm Community Versions
X
Saif Panjeshah
Technical Consultant
Fig. Installation of python3 on Ubuntu
First code in Ubuntu by python3:
Invoke the Interpreter
X
Saif Panjeshah
Technical Consultant
Make it executable:
X
Saif Panjeshah
Technical Consultant
Difference between Bash Scripts & Python Indentation:
X
Saif Panjeshah
Technical Consultant
Resolving IndentationError: unexpected indent
X
Saif Panjeshah
Technical Consultant
Task 2:
Quotes & Comments:
X
Saif Panjeshah
Technical Consultant
• Variables:
#Multiple Assignments:
X
Saif Panjeshah
Technical Consultant
Mutable and Immutable Datatypes:
List:
• Mutable
• Collection of Multi Data types, enclosed in square brackets.
Tuple:
• Immutable
• Collection of Multi Data types, enclosed in round brackets.
X
Saif Panjeshah
Technical Consultant
• Dictionary: Elements are stored in Key & Value Pair (key:
value) Enclosed in Curly brackets.
X
Saif Panjeshah
Technical Consultant
Printing Format:
Slicing:
X
Saif Panjeshah
Technical Consultant
Slicing of a String, to get a Substring:
Slicing tuple:
X
Saif Panjeshah
Technical Consultant
Slicing List:
Slicing Dictionary:
X
Saif Panjeshah
Technical Consultant
Python Operators:
• Operators are the constructs which can manipulate the value
of operands. Consider the expression 4 + 5 = 9
• Here, 4 and 5 are called as Operands and “+” is called as
Operator.
• Types of Operators:
• Arithmetic operators.
• Assignment operators.
• Comparison operators.
• Logical operators.
• Identity operators.
• Membership operators.
• Bitwise operators.
X
Saif Panjeshah
Technical Consultant
Types of Operators:
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
Condition: if, else if, el if
X
Saif Panjeshah
Technical Consultant
Loops:
Loops are used when you have a block of code that you want to
repeat it for fixed numbers of time or until a condition is not
satisfied.
While Loop:
Repeat the blocks of code until the while condition is true
Syntax:
While test_case:
Body of While
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
For Loop:
Repeat the block of code for a number of time.
Syntax:
For variable in sequence:
Body of For
X
Saif Panjeshah
Technical Consultant
Example of Nested for Loop:
X
Saif Panjeshah
Technical Consultant
Break & Continue :
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
Pyramid Program :
X
Saif Panjeshah
Technical Consultant
Built-in Functions.
The Python interpreter has a number of functions and types built into it that are
always available. They are listed here in alphabetical order.
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
List:
X
Saif Panjeshah
Technical Consultant
Tuples:
X
Saif Panjeshah
Technical Consultant
Functions in python:
• It is used for resuability of code .
X
Saif Panjeshah
Technical Consultant
If we printing function & not return anything in function it will be
print none.
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
How to resolve this Error using different Argument:
Default Argument:
X
Saif Panjeshah
Technical Consultant
Two Arguments:
Keywords Arguments :
X
Saif Panjeshah
Technical Consultant
Functions part – 2
X
Saif Panjeshah
Technical Consultant
Variable Length Argument(**kwargs Arguments):
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
Modules :
Installation of Modules:
X
Saif Panjeshah
Technical Consultant
Adding modern.py files
Run :
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant
X
Saif Panjeshah
Technical Consultant