0% found this document useful (0 votes)
13 views2 pages

Python Lists, Tuples, and Dictionaries Guide

The document provides an overview of Python data structures: lists, tuples, and dictionaries. It explains the characteristics of each structure, including methods for manipulating them, such as append, remove, and update. Examples are provided for clarity on how to use these data structures in Python.

Uploaded by

sk770700862
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Python Lists, Tuples, and Dictionaries Guide

The document provides an overview of Python data structures: lists, tuples, and dictionaries. It explains the characteristics of each structure, including methods for manipulating them, such as append, remove, and update. Examples are provided for clarity on how to use these data structures in Python.

Uploaded by

sk770700862
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python List, Tuple, and Dictionary – Exam Notes

1. Python List

A list is a collection of items. It is changeable and uses [ ].

Example:

numbers = [10, 20, 30]

fruits = ["apple", "banana"]

2. List Methods

append() – adds an item

[Link](4)

remove() – removes an item

[Link]("apple")

insert() – adds item at specific index

[Link](1, "orange")

pop() – removes last item

[Link]()

3. Python Tuple

A tuple is like a list but unchangeable. Uses ( ).

Example:

days = ("Mon", "Tue", "Wed")

4. Tuple Methods

count() – counts occurrences

[Link](2)
index() – returns position of value

[Link](3)

5. Dictionary

Stores data in key : value pairs using { }.

Example:

student = {"name": "Ahmad", "age": 20}

6. Dictionary Methods

get() – get a value

[Link]("age")

keys() – all keys

[Link]()

values() – all values

[Link]()

update() – update values

[Link]({"age": 21})

pop() – remove key

[Link]("age")

You might also like