331 likes | 1.32k Views
This Edureka Python tutorial will help you in learning various sequences in Python - Lists, Tuples, Strings, Sets, Dictionaries. It will also explain various operations possible on them. Below are the topics covered in this tutorial: <br><br>1. Python Sequences <br>2. Python Lists <br>3. Python Tuples <br>4. Python Sets <br>5. Python Dictionaries <br>6. Python Strings
E N D
EDUREKA PYTHON CERTIFICATION TRAINING Python Sequences www.edureka.co/python
Agenda ➢ What are sequences? ➢ Sequence Operations ➢ Types of Sequences in Python ➢ Lists ➢ Tuples ➢ Strings ➢ Sets ➢ Dictionaries www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
What are Sequences? www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
What Are Sequences? ➢ Sequences are containers with items that are accessible by indexing or slicing. ➢ The built-in len function takes any container as an argument and returns the number of items in the container. Sequence of Cars www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Sequences Operations www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Sequence Operations Repetition Membership Testing Slicing Indexing Concatenation Sequences of Cars www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Sequence Concatenation and Repetition Concatenation Repetition Sequence of Cars www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Sequence Membership Testing Membership Testing Sequence of Cars Not a member Is a member www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Sequence Indexing Indexing Sequence of Cars Index 6 Index 7 Index 0 Index 1 Index 2 Index 3 Index 4 Index 5 www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Sequence Slicing Slicing Sequence of Cars [ index 1 – index 4 ] www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Types of Sequences in Python www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Sequences In Python Lists Strings Dictionaries Tuples Sets www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Lists www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Lists The list is a most versatile datatype available in Python which can be written as a list of comma-separated values (items) between square brackets. Important thing about a list is that items in a list need not be of the same type. Append List.append(elem) Fruits = ['Mango', 'Apple', 'Grapes'] Insert List.insert(index,elem) List.extend(list2) Extend List.index(elem) Index Remove List.remove(elem) Sort List.sort() Reverse List.reverse() www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Tuples www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Tuples ➢ A tuple is a sequence of immutable Python objects. ➢ Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses. Fruits = ('Mango', 'Apple', 'Grapes‘) Tuple.index(elem) Index Tuple[range] Slicing Tuple1+Tuple2 Concatenation Tuple * x Repetition Tuple.count(elem) Count www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Strings www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Strings ➢ We can create them simply by enclosing characters in quotes. ➢ Python treats single quotes the same as double quotes. Fruits = 'Mango Apple Grapes' Slicing String[range] String[range] + ‘x’ Updating String 1 + String 2 Concatenation String 1 * x Repetition Membership In, not in String [:-1] Reverse www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Sets www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Sets ➢ A set contains an unordered collection of unique and immutable objects. ➢ The set data type is, as the name implies, a Python implementation of the sets as they are known from mathematics. Fruits = {'Mango', 'Apple', 'Grapes‘} B A A B A B C Difference Slicing (A C) / B (B C) / A Add Element Discard C Clear Remove Copy Intersection www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Dictionaries www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Dictionaries ➢ Dictionary is an unordered collection of key-value pairs. ➢ It is generally used when we have a huge amount of data. Length Value Example: del d [K] Membership Testing Key www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Session In A Minute Tuples Lists What are Sequences? Dictionaries Strings Sets www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Thank You … Questions/Queries/Feedback www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING