0% found this document useful (0 votes)
21 views

Data Structures

Uploaded by

chauloan200303
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Data Structures

Uploaded by

chauloan200303
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

4.

4.2

4.3

4.4

2
Lists

Accessing
Elements of a
List []

3
List’s Length len

Accessing
Elements

Lists Are
Mutable

4
Some
Sequences
Are
TypeError
Immutable

5
Access a
Nonexistent IndexError
Element

List Elements
in Expressions

6
Appending to
a List TypeError
+=

7
Concatenating
Lists +

TypeError

8
Accessing List
[]
range(len(concatenated_list))

concatenated_list

9
Comparison
Operators

10
Tuples

Creating
Tuples

11
Accessing
Tuple
Elements TypeError

Adding Items +=

12
Appending
Tuples to Lists

Unpacking
Sequences

13
Swapping
Values

Accessing
Safely with enumerate
enumerate

14
Sequence
Slicing

15
Slicing with
Steps

Slicing with
Negative
Indices and
Steps

Modifying
Lists Via
Slices

16
Creating a
Dictionary {}

{}

17
Empty len
Dictionary

True
False

clear

18
Iterating
through a items
Dictionary

19
Accessing the
Value
Associated
with a Key

Adding a New
Key-Value Pair

20
Removing a
Key-Value Pair

Attempting to
Access a
Nonexistent
Key

21
Dictionary
Methods keys
and values

Converting
Dictionary to
Lists

22
Sets

ints floats

[]

Creating a Set

23
Determining a
Set’s Length
Checking
Whether a
Value Is in a
Set

Iterating
Through a Set

set Function

24
Union

Intersection

Difference

Symetric
Difference

25
Union
Augmented
Assignment

update

add

remove

26
Introduction

27
End of File

Standard File • sys.stdin


Objects • sys.stdout
• sys.stderr

28
Writing to a
Text File

Reading from a Text File

29

You might also like