SlideShare a Scribd company logo
PYTHON NOTES
1. What is Python?
 Python is a high-levellanguage like other high-level
language such as Java, C++, PHP, Ruby, Basic and Perl.
 Python is an object-orientedprogramming language.
 Python provides security.
 The CPU understands a language which is called as
Machine Language.
 Machinelanguage is very complex and very
troublesome to write because it is represented all in
zero’s and one’s.
 The actualhardware inside CPU does not understand
any of these high-level languages.
2. Program:
 A Program can be defined as a set of instructions
given to a computer to achieve any objective.
 Instructions can be given to a computer by writing
programs.
 Tasks can be automated by giving instructionsto the
computers.
3. Defining Computer Hardware:
Components:
 CPU: It helpsin processing the instructions.
 Main Memory: It provides storage support during
execution of any program in computer Eg: RAM.
 The Secondary Memory: It helps to store the data
permanently inside the computer. Eg: Disk drives,
flash memory, DVD and CD.
 The Input and Output Devices:
o Input Devices helps users to generate any
command or input any data.
o Output Device helps user to get output from
computer. Eg: Mouse, Printer, Keyboard,
Monitoretc.
4. Constants and Variables:
 Variables can have any name, but Python reserved
words cannot be used.
 A variable provides a named storage that the
program can manipulate.
 Variablesare named memory locationused to store
data in program which keeps on changing during
execution.
 Programmers can decide the names of the variables.
 Fixed values used in programs such as numbers,
letters and strings are called “Constants”.
 Values of constants never change during program
execution.
5. Variable NamingConventions:
 Must start with a letter or an underscore “_”.
 Must consist of a letters, numbers and underscores.
 It is a case sensitive.
 Eg: First_Name, Age, Num1.
 Cannot be used: 1_hello, @hello, h123#2, -abc.
 Note: You cannot use reserved words for variable
names and identifiers.
6. Mnemonic Variable Names:
 Use simple rules of variable naming and avoid
reserved words.
 While using simple rules, we have a lot of choice for
variablenaming.
 Initiallythis choice can be confusing either in reading
or writing the program.
 The followingtwo programs are identicalin terms of
what they accomplish,but very different when you
read and try to understand them:
Eg 1: a=35.0
b=12.50
c=a*b
print(c)
O/P: 437.5
Eg 2: hours=35.0
rate=12.50
pay=hours*rate
print(pay)
O/P: 437.5
7. Reserved Words in Python:
 and, as, assert, break, class, continue,def, del, elif, else,
except, exec, finally, for, from, global, if, import, in, is ,
lambda,not, or, pass, print, raise, return, try, while,
with, yield.
8. Compilersand Interpreters:
 Compiler is a computer program(or a set of programs)
that transforms source code written in a programming
language into another computer language.
 Interpreters reads the source code of the program, line
by line, passes the source code, and interprets the
instructions.
9. Python language:
 The Python language acts as an intermediator
between the end user and the programmer.
 Python script will have .py extensions.
 Every one line can be a program in Python.
10. Types of errors:
 A syntax error: It occurs when the “grammar” rules of
Python are violated.
 A logic error:It occurs when the program hasgood
syntax but there is a mistake in the order of the
statements.
Eg:
o Using wrong variablename.
o Making a mistake in a Boolean
expression.
o Indenting a block to the wrong level.
o Using integer divisioninstead of
floating-pointdivision.
 A Semantic error: It occurs when the description
of the steps to take is syntacticallyperfect, but
the program does not do what it was intended
to do.
11. Difference between Programmersand Users:
 Programmers use software developmenttools
availablein a computer to developsoftware
for the computer.
 A programmer may write the program to
automate the task for himself or for any other
client.
 After learning programming language, the
programmer can developthe software that can
be utilized by end users.
 Usersuse the tools availablein a computer like
word processor, spreadsheet etc., whereas
programmers learn the computer language and
develop these tools.
12. Building blocks of a Program:
These are some of the conceptual patterns that are used
to construct a program:
 Input: Input will come from the user typing data
on the keyboard.
 Output: Display the results of the program on a
screen or store them in a file.
 Sequential Execution: Perform statements one
after another in the order in which they are
encountered in the script.
 Conditional Execution: Checks for certain
conditionsand then execute or skip a sequence
of statements.
 Repeated Execution: Perform some set of
statements repeatedly,usually with some
variation.
 Reuse: Write a set of instructionsonce then
reuse those instructionsin the program.
13. Various Components of programmingstatements:
 Variable.
 Operator.
 Constant.
 Reserved Words.
14. Operators and its Precedence:
 Operators are used to manipulatethe values of
operands.
 There are various types of operators used in
program:
o Comparison (relational)operators.
o Assignment operators.
o Logical operators.
15. Arithmetic Operators:
 Are the symbols that are used to perform arithmetic
operationson operands.
Types of Arithmetic operators:
o + ,- ,* ,/ ,%.
16. Comparison Operators:
 Compares the values of an operandsand decide the
relation among them.
 They are also called as Relational Operators.
Types of ComparisonOperators:
o < - less than.
o >- greater than.
o <= - less than equal to.
o >= - greater than equal to.
o == - equal to.
o != - not equalto.
17. Logical Operators:
 Are used to evaluateexpressions and return a
Booleanvalue.
Types of Logical Operators:
o x && y: Performs a logical AND of the two
operands.
o x || y: Performs a logical OR of the two
operands.
o ! x: Performs a logical NOT of the operand.
18. Logical Operators (Contd..):
 There are three logicaloperators and, or and not.
 The semantics of these operators is similarto their
meaning in English.
 Eg: x>0 and x<10 (is true only if x is greater than 0
and less than 10).
 n %2==0 or n % 3==0(is true if either of the
conditionis true).
 The not operator negates a Boolean expression.
 Eg: not(x>y) is true if x>y is false.
19. Operator Precedence:
 When we use multipleoperators in an expression,
program must know which operator to execute first.
This is called as “Operator Precedence”.
 The followingexpression multipleoperators but they
will execute as per precedence rule:
o X=1+2*3-4/5**6.
 Eg 1: b=10, a=5, b%a O/P: 0.
 Eg 2: b=10, a=5, b%a==5 O/P: False.
20. Highest Precedence rule to Lowest Precedence rule:
 Parentheses are alwaysrespected hence given first
priority.
 Exponentiation (raiseto a power).
 Multiplication,Divisionand Remainder.
 Additionand Subtraction.
 Left to Right.
 Ie: Parentheses
Power
Multiplication
Addition
Left to Right
21. Comments:
 Comments helps in getting description aboutthe
code for future reference.
 In Python, Comment starts with # symbol.
 Eg: # compute the percentage of the hour that has
elapsed percentage = (minute*100)/60.
 In the above case, the comment appearson a line by
itself. Comments can also be put at the end of a line.
 Percentage = (minute*100)/60.
# - Percentage of an hour.
22. Functions:
 In the context programming, defining a function
means declaring the elements of its structure.
 The followingsyntax can be used to define a
function:
 Syntax:
def function_name(parameters):
function_body
return [value].
 A function is a named sequence of statement
that performs an operation.
 After defining, the function can be executed by
calling it.
23. Built-in Functions:
 Python provides a number of important built-in
functionsthat can be used without needing to
provide the function definition.
 abs(), divmod(), str(), sum(), super(), int(), eval(), bin(),
bool(), file(), filter(), format(), type().
 Math module: It provides functions for specialized
mathematicaloperations.
24. Conditional Execution:
 There are situationswhere an action performed
based on a condition.This is known as “Conditional
Execution”.
 The variousconditional constructsare implemented
using
o If statement.
o If else statement.
o Chainedstatement.
o Nested statement.
25. If statement:
 Containsa logicalexpression using which data is
compared and a decisionis made based on the result
of comparison.
 Syntax: if condition:
action
26. Chained Conditions:
 Elif statement: Allows to heck multiple expressions
for TRUE and execute a block of code as soon as one
of the conditionsevaluatesto TRUE.
 Nested Conditions: There may be a situationwhen
there is need to check for another conditionresolves
to true. In such a situation,the nested if construct is
used.
27. Loop Pattern:
 Loops are generally used to:
o Iterate a list of items.
o View content of a file.
o Find the largest and smallest data.
 There are two types of loops:
o Infinite loops.
o Definite loops.
28. Infinite loops:
 Sequence of instructionsin a computer program
which loops endlessly.
 Also known as endless loop or unproductive loop.
 Solutionto an infiniteloop is using break statement.
29. Break and Continue Statement:
 The break statement is used to exit from the loop.
 The break statement prevents the execution of the
remaining loop.
 The Continue Statement is used to skip all the
subsequent instructions and take the control back to
the loop.
30. For loop:
 Used to execute a block of statements for a specific
number of times.
 Used to construct a definite loop.
 Syntax: for<destination>in <source>
statements
print <destination>
31. While loop:
 Is used to execute a set of instructionsfor a
specified number of times until the condition
becomes False.
 Syntax: while(condition)
Executes code
exit.
32. Workingof While loop:
 Evaluatethe condition,yieldingTrue of False.
 If the conditionis false, exit the while statement and
continue execution at next statement.
 If the conditionis true, execute the body and then go
back to step 1.
33. String:
 A string is a sequence of characters.
 Single quotes or doublequotes are used to represent
strings.
 There are some special operators used in string.
34. Special String Operators:
 Concatenation (+): Adds values on either side of the
operator.
 Repetition (*): Creates new strings, concatenating
multiplecopies of the same string.
 Slice ([]): Gives the character from the given index.
 Range Slice ([:]): Gives the character from the given
range.
 Membership (in): Returns True if a character exists in
the given string.
 Membership (not in): Returns True if a character
does not exists in the given string.
 Some of the built-inString Methodsare as follows:
o Capitalize().
o isupper().
o istitle().
o len(string).
o lower()
o Istrip().
o upper().
35. Format Operator:
 “%” operator allowsto construct strings, replacing
parts of the strings with the data stored in variables.
 “%” operatorwill work as modulusoperator for
strings.
 “%” operatorworks as a format operator if the
operand is string.
36. Exception Handling:
 An Exception is an event, which occurs during the
execution of a program that stops the normal flow of
the program’s instructions.
 When Python script raises exception it must either
handleor terminate.
 Exceptionsare handledusing the try and except
keywords.
 Syntax:
try
//Code
except Exception 1:
//error message
except Exception 2:
//error message
else:
//success message
37. List:
 Most versatile datatypeavailablein python.
 Defined as a sequence of values.
 Holds values between square brackets separated by
commas.
 Holds Homogenousset of items.
 Indices start at 0.
 Lists are Mutable.
38. List Functions:
 sum( ): Using this function, we can add elements of
the list. It will work only with the numbers.
 min( ): Using this function, we can find the minimum
value from the list.
 max( ): Using this function, we can find the maximum
value from the list.
 len( ): Using this function, we can find the number of
elements in the list.
39. Dictionary:
 It is a “bag” of values, each with its own label.
 It containsthe values in the form of key-value pair.
 Every value in Dictionaryis associated with a key.
40. Characteristics of Dictionary:
 Dictionaries are Python’s most powerful data
collection.
 Dictionariesallows us to do fast database-like
operationsin Python.
 Dictionarieshave different names in different
languages.
o Associative Arrays- Perl/PHP.
o Properties or Map or HashMap- Java.
o Property Bag- C#/ .NET.
 DictionaryKeys can be of any Python data type.
Because keys are used for indexing, they should be
immutable.
 DictionaryValues can be of any Python data type.
Values can be mutable or immutable.
41. Difference between Lists and Dictionary:
LIST DICTIONARY
List is a list of values.
Starting from zero.
It is an index of words and
each of them has a
definition.
We can add the element
index wise.
Element can be added in
Dictionaryin the form of
key-value pair.
42. Tuples:
 A Tuple is an immutableList.
 A Tuple stores values, similarto a List, but uses
different syntax.
 A Tuple cannot be changed once it is created.
 Tuple uses parentheses, whereas lists use square
brackets.
 A Tuples is a sequence of immutablePython objects.
43. Features of Tuples:
 Tuples are more efficient.
 Tuples are faster than Lists.
 Tuples are converted into Lists, and vice-versa.
 Tuples are used in String Formatting.
 Note: We cannot perform Add, Delete and Search
operationson Tuples.
44. Operations which can be performed on Tuples:
 You can’t add elements on tuple. Tuples have no
appendor extend method.
 You can’t remove elements from a tuple. Tuples have
no remove or pop method.
 You can’t find elements in a tuple. Tuples have no
index method.
 You can however, check if an element exist in the
tuple.
45. Creating Tuples:
 Creating a Tuple is as simple assigning values
separated with commas.
 Optionally,you can put these comma-separated
values between parentheses also.
 Eg: # Zero-element tuple.
a= ( )
# One-element tuple.
b= (“one”,)
# Two-element tuple.
c= (“one”,”two”)
46. Updating Tuples:
 Tuples are immutable.
 An immutableobject cannot be changed once it is
created it alwaysremain the same.
 The values of Tuple element cannot be updatedor
changed.
 Portions of existing tuples can be used to create new
tuples.
47. Deleting Tuples:
 Removing individual Tupleelements is not possible.
 “del” statement is used to remove an entire Tuples.
 It is possible to merge two Tuples.
 Tuples can be reassigned with different values.
Ad

More Related Content

What's hot (20)

Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Python final ppt
Python final pptPython final ppt
Python final ppt
Ripal Ranpara
 
Python basic
Python basicPython basic
Python basic
Saifuddin Kaijar
 
Javascript
JavascriptJavascript
Javascript
Manav Prasad
 
Python programming
Python programmingPython programming
Python programming
Prof. Dr. K. Adisesha
 
Python Presentation
Python PresentationPython Presentation
Python Presentation
Narendra Sisodiya
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
Relational operators
Relational operatorsRelational operators
Relational operators
Graphic Era Hill University,Bhimtal
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
Sumit Satam
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
Mohammed Sikander
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
Register allocation and assignment
Register allocation and assignmentRegister allocation and assignment
Register allocation and assignment
Karthi Keyan
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
Megha V
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
Ahmad Idrees
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
Nilesh Dalvi
 
Benefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of pythonBenefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of python
paradisetechsoftsolutions
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
Sumit Satam
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
Register allocation and assignment
Register allocation and assignmentRegister allocation and assignment
Register allocation and assignment
Karthi Keyan
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
Megha V
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
Ahmad Idrees
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
Nilesh Dalvi
 
Benefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of pythonBenefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of python
paradisetechsoftsolutions
 

Similar to PYTHON NOTES (20)

C Programming Slides for 1st Year Engg students
C Programming Slides for 1st Year Engg studentsC Programming Slides for 1st Year Engg students
C Programming Slides for 1st Year Engg students
MysoreYogesh
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
MeoRamos
 
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptxpython notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
yuvarajkumar334
 
computer ppt group22222222222222222222 (1).pptx
computer ppt group22222222222222222222 (1).pptxcomputer ppt group22222222222222222222 (1).pptx
computer ppt group22222222222222222222 (1).pptx
JoyLedda3
 
265 ge8151 problem solving and python programming - 2 marks with answers
265   ge8151 problem solving and python programming - 2 marks with answers265   ge8151 problem solving and python programming - 2 marks with answers
265 ge8151 problem solving and python programming - 2 marks with answers
vithyanila
 
Book management system
Book management systemBook management system
Book management system
SHARDA SHARAN
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ranjith kumar
 
CP c++ programing project Unit 1 intro.pdf
CP c++ programing project  Unit 1 intro.pdfCP c++ programing project  Unit 1 intro.pdf
CP c++ programing project Unit 1 intro.pdf
ShivamYadav886008
 
c_programming.pdf
c_programming.pdfc_programming.pdf
c_programming.pdf
Home
 
pyton Notes1
pyton Notes1pyton Notes1
pyton Notes1
Amba Research
 
python introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptxpython introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptx
ChandraPrakash715640
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
Salahaddin University-Erbil
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
Vikram Nandini
 
JAVA-java-basic and introduction.module.pptx
JAVA-java-basic and introduction.module.pptxJAVA-java-basic and introduction.module.pptx
JAVA-java-basic and introduction.module.pptx
catliegay
 
C++ Tutorial
C++ TutorialC++ Tutorial
C++ Tutorial
freema48
 
Fundamentals of programming final
Fundamentals of programming finalFundamentals of programming final
Fundamentals of programming final
Ricky Recto
 
Cp week _2.
Cp week _2.Cp week _2.
Cp week _2.
shahidullah57
 
Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language Course
Vivek Singh Chandel
 
Survelaine murillo ppt
Survelaine murillo pptSurvelaine murillo ppt
Survelaine murillo ppt
Survelaine Murillo
 
C Programming Slides for 1st Year Engg students
C Programming Slides for 1st Year Engg studentsC Programming Slides for 1st Year Engg students
C Programming Slides for 1st Year Engg students
MysoreYogesh
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
MeoRamos
 
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptxpython notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
yuvarajkumar334
 
computer ppt group22222222222222222222 (1).pptx
computer ppt group22222222222222222222 (1).pptxcomputer ppt group22222222222222222222 (1).pptx
computer ppt group22222222222222222222 (1).pptx
JoyLedda3
 
265 ge8151 problem solving and python programming - 2 marks with answers
265   ge8151 problem solving and python programming - 2 marks with answers265   ge8151 problem solving and python programming - 2 marks with answers
265 ge8151 problem solving and python programming - 2 marks with answers
vithyanila
 
Book management system
Book management systemBook management system
Book management system
SHARDA SHARAN
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ranjith kumar
 
CP c++ programing project Unit 1 intro.pdf
CP c++ programing project  Unit 1 intro.pdfCP c++ programing project  Unit 1 intro.pdf
CP c++ programing project Unit 1 intro.pdf
ShivamYadav886008
 
c_programming.pdf
c_programming.pdfc_programming.pdf
c_programming.pdf
Home
 
python introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptxpython introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptx
ChandraPrakash715640
 
JAVA-java-basic and introduction.module.pptx
JAVA-java-basic and introduction.module.pptxJAVA-java-basic and introduction.module.pptx
JAVA-java-basic and introduction.module.pptx
catliegay
 
C++ Tutorial
C++ TutorialC++ Tutorial
C++ Tutorial
freema48
 
Fundamentals of programming final
Fundamentals of programming finalFundamentals of programming final
Fundamentals of programming final
Ricky Recto
 
Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language Course
Vivek Singh Chandel
 
Ad

More from Ni (13)

Embedded Systems Q and A M.Sc.(IT) PART II SEM III
Embedded Systems Q and A M.Sc.(IT) PART II SEM IIIEmbedded Systems Q and A M.Sc.(IT) PART II SEM III
Embedded Systems Q and A M.Sc.(IT) PART II SEM III
Ni
 
Cryptography summary
Cryptography summaryCryptography summary
Cryptography summary
Ni
 
INFORMATION SECURITY MANAGEMENT
INFORMATION SECURITY MANAGEMENTINFORMATION SECURITY MANAGEMENT
INFORMATION SECURITY MANAGEMENT
Ni
 
INFORMATION SECURITY: THREATS AND SOLUTIONS.
INFORMATION SECURITY: THREATS AND SOLUTIONS.INFORMATION SECURITY: THREATS AND SOLUTIONS.
INFORMATION SECURITY: THREATS AND SOLUTIONS.
Ni
 
India's social challenge
India's social challengeIndia's social challenge
India's social challenge
Ni
 
ADOBE DREAMWEAVER
ADOBE DREAMWEAVERADOBE DREAMWEAVER
ADOBE DREAMWEAVER
Ni
 
Code coverage analysis in testing
Code coverage analysis in testingCode coverage analysis in testing
Code coverage analysis in testing
Ni
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
Ni
 
LASER
LASERLASER
LASER
Ni
 
Java communication api
Java communication apiJava communication api
Java communication api
Ni
 
Library management system
Library management systemLibrary management system
Library management system
Ni
 
Impact of social networking sites- advantages and disadvantages
Impact of social networking sites- advantages and disadvantagesImpact of social networking sites- advantages and disadvantages
Impact of social networking sites- advantages and disadvantages
Ni
 
Ppt on nan
Ppt on nanPpt on nan
Ppt on nan
Ni
 
Embedded Systems Q and A M.Sc.(IT) PART II SEM III
Embedded Systems Q and A M.Sc.(IT) PART II SEM IIIEmbedded Systems Q and A M.Sc.(IT) PART II SEM III
Embedded Systems Q and A M.Sc.(IT) PART II SEM III
Ni
 
Cryptography summary
Cryptography summaryCryptography summary
Cryptography summary
Ni
 
INFORMATION SECURITY MANAGEMENT
INFORMATION SECURITY MANAGEMENTINFORMATION SECURITY MANAGEMENT
INFORMATION SECURITY MANAGEMENT
Ni
 
INFORMATION SECURITY: THREATS AND SOLUTIONS.
INFORMATION SECURITY: THREATS AND SOLUTIONS.INFORMATION SECURITY: THREATS AND SOLUTIONS.
INFORMATION SECURITY: THREATS AND SOLUTIONS.
Ni
 
India's social challenge
India's social challengeIndia's social challenge
India's social challenge
Ni
 
ADOBE DREAMWEAVER
ADOBE DREAMWEAVERADOBE DREAMWEAVER
ADOBE DREAMWEAVER
Ni
 
Code coverage analysis in testing
Code coverage analysis in testingCode coverage analysis in testing
Code coverage analysis in testing
Ni
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
Ni
 
LASER
LASERLASER
LASER
Ni
 
Java communication api
Java communication apiJava communication api
Java communication api
Ni
 
Library management system
Library management systemLibrary management system
Library management system
Ni
 
Impact of social networking sites- advantages and disadvantages
Impact of social networking sites- advantages and disadvantagesImpact of social networking sites- advantages and disadvantages
Impact of social networking sites- advantages and disadvantages
Ni
 
Ppt on nan
Ppt on nanPpt on nan
Ppt on nan
Ni
 
Ad

Recently uploaded (20)

Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 

PYTHON NOTES

  • 1. PYTHON NOTES 1. What is Python?  Python is a high-levellanguage like other high-level language such as Java, C++, PHP, Ruby, Basic and Perl.  Python is an object-orientedprogramming language.  Python provides security.  The CPU understands a language which is called as Machine Language.  Machinelanguage is very complex and very troublesome to write because it is represented all in zero’s and one’s.  The actualhardware inside CPU does not understand any of these high-level languages. 2. Program:  A Program can be defined as a set of instructions given to a computer to achieve any objective.  Instructions can be given to a computer by writing programs.  Tasks can be automated by giving instructionsto the computers.
  • 2. 3. Defining Computer Hardware: Components:  CPU: It helpsin processing the instructions.  Main Memory: It provides storage support during execution of any program in computer Eg: RAM.  The Secondary Memory: It helps to store the data permanently inside the computer. Eg: Disk drives, flash memory, DVD and CD.  The Input and Output Devices: o Input Devices helps users to generate any command or input any data. o Output Device helps user to get output from computer. Eg: Mouse, Printer, Keyboard, Monitoretc. 4. Constants and Variables:  Variables can have any name, but Python reserved words cannot be used.  A variable provides a named storage that the program can manipulate.
  • 3.  Variablesare named memory locationused to store data in program which keeps on changing during execution.  Programmers can decide the names of the variables.  Fixed values used in programs such as numbers, letters and strings are called “Constants”.  Values of constants never change during program execution. 5. Variable NamingConventions:  Must start with a letter or an underscore “_”.  Must consist of a letters, numbers and underscores.  It is a case sensitive.  Eg: First_Name, Age, Num1.  Cannot be used: 1_hello, @hello, h123#2, -abc.  Note: You cannot use reserved words for variable names and identifiers. 6. Mnemonic Variable Names:  Use simple rules of variable naming and avoid reserved words.  While using simple rules, we have a lot of choice for variablenaming.
  • 4.  Initiallythis choice can be confusing either in reading or writing the program.  The followingtwo programs are identicalin terms of what they accomplish,but very different when you read and try to understand them: Eg 1: a=35.0 b=12.50 c=a*b print(c) O/P: 437.5 Eg 2: hours=35.0 rate=12.50 pay=hours*rate print(pay) O/P: 437.5 7. Reserved Words in Python:  and, as, assert, break, class, continue,def, del, elif, else, except, exec, finally, for, from, global, if, import, in, is , lambda,not, or, pass, print, raise, return, try, while, with, yield.
  • 5. 8. Compilersand Interpreters:  Compiler is a computer program(or a set of programs) that transforms source code written in a programming language into another computer language.  Interpreters reads the source code of the program, line by line, passes the source code, and interprets the instructions. 9. Python language:  The Python language acts as an intermediator between the end user and the programmer.  Python script will have .py extensions.  Every one line can be a program in Python. 10. Types of errors:  A syntax error: It occurs when the “grammar” rules of Python are violated.  A logic error:It occurs when the program hasgood syntax but there is a mistake in the order of the statements. Eg: o Using wrong variablename.
  • 6. o Making a mistake in a Boolean expression. o Indenting a block to the wrong level. o Using integer divisioninstead of floating-pointdivision.  A Semantic error: It occurs when the description of the steps to take is syntacticallyperfect, but the program does not do what it was intended to do. 11. Difference between Programmersand Users:  Programmers use software developmenttools availablein a computer to developsoftware for the computer.  A programmer may write the program to automate the task for himself or for any other client.  After learning programming language, the programmer can developthe software that can be utilized by end users.  Usersuse the tools availablein a computer like word processor, spreadsheet etc., whereas programmers learn the computer language and develop these tools.
  • 7. 12. Building blocks of a Program: These are some of the conceptual patterns that are used to construct a program:  Input: Input will come from the user typing data on the keyboard.  Output: Display the results of the program on a screen or store them in a file.  Sequential Execution: Perform statements one after another in the order in which they are encountered in the script.  Conditional Execution: Checks for certain conditionsand then execute or skip a sequence of statements.  Repeated Execution: Perform some set of statements repeatedly,usually with some variation.  Reuse: Write a set of instructionsonce then reuse those instructionsin the program. 13. Various Components of programmingstatements:  Variable.  Operator.  Constant.
  • 8.  Reserved Words. 14. Operators and its Precedence:  Operators are used to manipulatethe values of operands.  There are various types of operators used in program: o Comparison (relational)operators. o Assignment operators. o Logical operators. 15. Arithmetic Operators:  Are the symbols that are used to perform arithmetic operationson operands. Types of Arithmetic operators: o + ,- ,* ,/ ,%. 16. Comparison Operators:  Compares the values of an operandsand decide the relation among them.  They are also called as Relational Operators.
  • 9. Types of ComparisonOperators: o < - less than. o >- greater than. o <= - less than equal to. o >= - greater than equal to. o == - equal to. o != - not equalto. 17. Logical Operators:  Are used to evaluateexpressions and return a Booleanvalue. Types of Logical Operators: o x && y: Performs a logical AND of the two operands. o x || y: Performs a logical OR of the two operands. o ! x: Performs a logical NOT of the operand. 18. Logical Operators (Contd..):  There are three logicaloperators and, or and not.
  • 10.  The semantics of these operators is similarto their meaning in English.  Eg: x>0 and x<10 (is true only if x is greater than 0 and less than 10).  n %2==0 or n % 3==0(is true if either of the conditionis true).  The not operator negates a Boolean expression.  Eg: not(x>y) is true if x>y is false. 19. Operator Precedence:  When we use multipleoperators in an expression, program must know which operator to execute first. This is called as “Operator Precedence”.  The followingexpression multipleoperators but they will execute as per precedence rule: o X=1+2*3-4/5**6.  Eg 1: b=10, a=5, b%a O/P: 0.  Eg 2: b=10, a=5, b%a==5 O/P: False. 20. Highest Precedence rule to Lowest Precedence rule:  Parentheses are alwaysrespected hence given first priority.  Exponentiation (raiseto a power).
  • 11.  Multiplication,Divisionand Remainder.  Additionand Subtraction.  Left to Right.  Ie: Parentheses Power Multiplication Addition Left to Right 21. Comments:  Comments helps in getting description aboutthe code for future reference.  In Python, Comment starts with # symbol.  Eg: # compute the percentage of the hour that has elapsed percentage = (minute*100)/60.  In the above case, the comment appearson a line by itself. Comments can also be put at the end of a line.  Percentage = (minute*100)/60. # - Percentage of an hour. 22. Functions:  In the context programming, defining a function means declaring the elements of its structure.
  • 12.  The followingsyntax can be used to define a function:  Syntax: def function_name(parameters): function_body return [value].  A function is a named sequence of statement that performs an operation.  After defining, the function can be executed by calling it. 23. Built-in Functions:  Python provides a number of important built-in functionsthat can be used without needing to provide the function definition.  abs(), divmod(), str(), sum(), super(), int(), eval(), bin(), bool(), file(), filter(), format(), type().  Math module: It provides functions for specialized mathematicaloperations. 24. Conditional Execution:
  • 13.  There are situationswhere an action performed based on a condition.This is known as “Conditional Execution”.  The variousconditional constructsare implemented using o If statement. o If else statement. o Chainedstatement. o Nested statement. 25. If statement:  Containsa logicalexpression using which data is compared and a decisionis made based on the result of comparison.  Syntax: if condition: action 26. Chained Conditions:  Elif statement: Allows to heck multiple expressions for TRUE and execute a block of code as soon as one of the conditionsevaluatesto TRUE.  Nested Conditions: There may be a situationwhen there is need to check for another conditionresolves
  • 14. to true. In such a situation,the nested if construct is used. 27. Loop Pattern:  Loops are generally used to: o Iterate a list of items. o View content of a file. o Find the largest and smallest data.  There are two types of loops: o Infinite loops. o Definite loops. 28. Infinite loops:  Sequence of instructionsin a computer program which loops endlessly.  Also known as endless loop or unproductive loop.  Solutionto an infiniteloop is using break statement. 29. Break and Continue Statement:  The break statement is used to exit from the loop.  The break statement prevents the execution of the remaining loop.
  • 15.  The Continue Statement is used to skip all the subsequent instructions and take the control back to the loop. 30. For loop:  Used to execute a block of statements for a specific number of times.  Used to construct a definite loop.  Syntax: for<destination>in <source> statements print <destination> 31. While loop:  Is used to execute a set of instructionsfor a specified number of times until the condition becomes False.  Syntax: while(condition) Executes code exit. 32. Workingof While loop:  Evaluatethe condition,yieldingTrue of False.
  • 16.  If the conditionis false, exit the while statement and continue execution at next statement.  If the conditionis true, execute the body and then go back to step 1. 33. String:  A string is a sequence of characters.  Single quotes or doublequotes are used to represent strings.  There are some special operators used in string. 34. Special String Operators:  Concatenation (+): Adds values on either side of the operator.  Repetition (*): Creates new strings, concatenating multiplecopies of the same string.  Slice ([]): Gives the character from the given index.  Range Slice ([:]): Gives the character from the given range.  Membership (in): Returns True if a character exists in the given string.  Membership (not in): Returns True if a character does not exists in the given string.  Some of the built-inString Methodsare as follows:
  • 17. o Capitalize(). o isupper(). o istitle(). o len(string). o lower() o Istrip(). o upper(). 35. Format Operator:  “%” operator allowsto construct strings, replacing parts of the strings with the data stored in variables.  “%” operatorwill work as modulusoperator for strings.  “%” operatorworks as a format operator if the operand is string. 36. Exception Handling:  An Exception is an event, which occurs during the execution of a program that stops the normal flow of the program’s instructions.  When Python script raises exception it must either handleor terminate.  Exceptionsare handledusing the try and except keywords.  Syntax:
  • 18. try //Code except Exception 1: //error message except Exception 2: //error message else: //success message 37. List:  Most versatile datatypeavailablein python.  Defined as a sequence of values.  Holds values between square brackets separated by commas.  Holds Homogenousset of items.  Indices start at 0.  Lists are Mutable. 38. List Functions:  sum( ): Using this function, we can add elements of the list. It will work only with the numbers.  min( ): Using this function, we can find the minimum value from the list.
  • 19.  max( ): Using this function, we can find the maximum value from the list.  len( ): Using this function, we can find the number of elements in the list. 39. Dictionary:  It is a “bag” of values, each with its own label.  It containsthe values in the form of key-value pair.  Every value in Dictionaryis associated with a key. 40. Characteristics of Dictionary:  Dictionaries are Python’s most powerful data collection.  Dictionariesallows us to do fast database-like operationsin Python.  Dictionarieshave different names in different languages. o Associative Arrays- Perl/PHP. o Properties or Map or HashMap- Java. o Property Bag- C#/ .NET.  DictionaryKeys can be of any Python data type. Because keys are used for indexing, they should be immutable.
  • 20.  DictionaryValues can be of any Python data type. Values can be mutable or immutable. 41. Difference between Lists and Dictionary: LIST DICTIONARY List is a list of values. Starting from zero. It is an index of words and each of them has a definition. We can add the element index wise. Element can be added in Dictionaryin the form of key-value pair. 42. Tuples:  A Tuple is an immutableList.  A Tuple stores values, similarto a List, but uses different syntax.  A Tuple cannot be changed once it is created.  Tuple uses parentheses, whereas lists use square brackets.  A Tuples is a sequence of immutablePython objects. 43. Features of Tuples:  Tuples are more efficient.  Tuples are faster than Lists.
  • 21.  Tuples are converted into Lists, and vice-versa.  Tuples are used in String Formatting.  Note: We cannot perform Add, Delete and Search operationson Tuples. 44. Operations which can be performed on Tuples:  You can’t add elements on tuple. Tuples have no appendor extend method.  You can’t remove elements from a tuple. Tuples have no remove or pop method.  You can’t find elements in a tuple. Tuples have no index method.  You can however, check if an element exist in the tuple. 45. Creating Tuples:  Creating a Tuple is as simple assigning values separated with commas.  Optionally,you can put these comma-separated values between parentheses also.  Eg: # Zero-element tuple. a= ( ) # One-element tuple. b= (“one”,)
  • 22. # Two-element tuple. c= (“one”,”two”) 46. Updating Tuples:  Tuples are immutable.  An immutableobject cannot be changed once it is created it alwaysremain the same.  The values of Tuple element cannot be updatedor changed.  Portions of existing tuples can be used to create new tuples. 47. Deleting Tuples:  Removing individual Tupleelements is not possible.  “del” statement is used to remove an entire Tuples.  It is possible to merge two Tuples.  Tuples can be reassigned with different values.