You are on page 1of 41

1

WWW.PENTALOG.COM
Data structures

WWW.PENTALOG.COM
● list [7, 15.3, True, ‘chars’]
● tuple (7, 15.3, True, ‘chars’)
● set set(1, 3, 5, 7, 9)
● dict {‘ana’: 20, ‘maria’: 23}

WWW.PENTALOG.COM
Lists

WWW.PENTALOG.COM
list
● items = []
● prices = list()

WWW.PENTALOG.COM
list
● items.append(‘jacket’)
● prices.append(129)

WWW.PENTALOG.COM
list
● items.append(‘jeans’)
● prices.append(59)
● items.append('shirt')
● prices.append(78)

WWW.PENTALOG.COM
list







WWW.PENTALOG.COM
Tuples

WWW.PENTALOG.COM
tuple
● record = ()
● other_record = tuple()
● point = (1.5, 2.5, 3.14)

10

WWW.PENTALOG.COM
Sets

11

WWW.PENTALOG.COM
set Unordered collection of unique elements

● empty_set = set()
● data_set = set([‘Ana’, ‘Adi’, ‘Adi’])

12

WWW.PENTALOG.COM
Dictionaries

13

WWW.PENTALOG.COM
dict Unordered set of key: value pairs, where the keys are unique

● empty_dict = dict()
● phone_book = {
'John': '+40631381680',
'Ana': '+40722369571'
}

14

WWW.PENTALOG.COM
The in keyword







15

WWW.PENTALOG.COM
More on data structures

16

WWW.PENTALOG.COM
Lists as Stacks

17

WWW.PENTALOG.COM
Lists as Queues

18

WWW.PENTALOG.COM
Lists as Queues

19

WWW.PENTALOG.COM
List comprehensions

20

WWW.PENTALOG.COM
Dictionaries: defaultdict

21

WWW.PENTALOG.COM
Dictionaries: OrderedDict

22

WWW.PENTALOG.COM
Dictionaries: Counter

23

WWW.PENTALOG.COM
Functions

24

WWW.PENTALOG.COM
Defining functions

25

WWW.PENTALOG.COM
Functions: default argument values

26

WWW.PENTALOG.COM
Functions: default argument values

27

WWW.PENTALOG.COM
Functions: default argument values

28

WWW.PENTALOG.COM
Functions: keyword arguments

29

WWW.PENTALOG.COM
Functions: keyword arguments

30

WWW.PENTALOG.COM
Functions: *args, **kwargs

31

WWW.PENTALOG.COM
Functions: Recursion

32

WWW.PENTALOG.COM
Functions: Recursion

33

WWW.PENTALOG.COM
Functions: as arguments

34

WWW.PENTALOG.COM
Functions: as return value

35

WWW.PENTALOG.COM
Functions: Lambda Expressions

36

WWW.PENTALOG.COM
Functions: Lambda Expressions




37

WWW.PENTALOG.COM
Functions: Functional programming
https://en.wikipedia.org/wiki/Functional_programming



38

WWW.PENTALOG.COM
Functions: Functional programming

39

WWW.PENTALOG.COM
Q&A

40

WWW.PENTALOG.COM
41

WWW.PENTALOG.COM

You might also like