COURSE SECTION 06 OF 06

Tuples, Lists, Dictionaries and Sets

Lesson material assembled from the files you supplied.

Course notes

Content below is transcribed from the supplied course document. The original wording and terminology are retained.

Tuples , Lists , Dictionaries and Sets

Tuples:-

What is Tuple?

Ordered sequences of objects

Defined using parenthesis

Immutable sequence

Store different data types

container

Creating tuple

Creating tuple with items

Indexing of Tuple

Slicing of Tuple

print(tup1[start:end:step size])

default value of start is always zero

default value of step size always 1

Tuple Methods

count()

index()

Tuple Function

len()

max()

min()

Tuple Operations

Addition

Multiplication

In operator

Not in operator

Unpacking of Tuple

For loop with Tuple

Lists:-

What is List? – 1 & 2

Container like a tuple

Store different data types

Mutable data structure

Collection of arbitrary objects

Ordered sequences of arbitrary objects

Creating a list

Empty list

List with elements

Array of object references

List in Action - 2

List Iteration and Comprehensions – 1 & 2

List Comprehension is a concise way to create lists.

One-line codes to make a list with for loop, map() & lambda()

List Operation – 1 & 2

Accessing the item of a list

Updating list

Deleting list item

Addition of the lists

Multiplication of List

In operator

List with for loop

Indexing, Slicing and Matrixes - 2

Tuples , Lists , Dictionaries and Sets

Lists:-

List in Action - 2

List Iteration and Comprehensions – 1 & 2

List Comprehension is a concise way to create lists.

One-line codes to make a list with for loop, map() & lambda()

List Operation – 1 & 2

Accessing the item of a list

Updating list

Deleting list item

Addition of the lists

Multiplication of List

In operator

List with for loop

Indexing, Slicing and Matrixes - 2

Changing Lists in Place - 2

Index and slice assignments

List method calls

More on sorting lists

Other common list methods and operations

List functions – 1

len()

max()

min()

List methods – 1

Dir()

Insert methods

append()

insert()

Deletion methods

remove()

pop()

count()

index()

copy()

sort()

reverse()

sum()

extend()

clear()

Dictionaries:-

What is Dictionaries? – 2 & 3

{}

Creating a dictionary

Features

Dictionaries in Action - 2

Dictionary Operation – 2 & 3

Accessing the values of dictionary

Deleting item from dictionary

Updating and adding in dictionary

Adding item to dictionary

Changing Lists in Place - 2

Dictionary Methods – 2 & 3

copy()

get()

setdefault()

items()

keys()

values()

update()

Tuples , Lists , Dictionaries and Sets

Dictionaries:-

Dictionary Methods – 2 & 3

copy()

get()

setdefault()

items()

keys()

values()

update()

Other ways to make Dictionaries - 2

Dictionary Function – 3

len()

Max(dict)

Sets:- 3

With Item

Without Items

Set Methods:-

add(x)

update(x,y,z)

copy()

pop()

discard(i)

remove()

intersection()

difference()

Download the supplied Python examples

Topics identified in the course materials

← Previous section

← Back to course curriculum