Lists, Tuples and Dictionaries Flashcards

1
Q

what are lists?

A

collection of different types of elements within square brackets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

list operators?

A

concatenation, repetition, membership

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

append()

A

adds new element to last in list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

extend()

A

extends existing list to another list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

insert()

A

Inserts element based on index number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

pop()

A

removes element based on index number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

reverse()

A

reverses a list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

sort()

A

sorts list in ascending order ( Looking at starting alphabets)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

sorted()

A

does the same thing as sort but wont change the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

min() and max()

A

gives maximum and minimum values in list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

sum()

A

sum of elements in list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

nested list?

A

list containing another list inside

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are tuples?

A

collection of different types of data within curved brackets they are immutable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

packing and unpacking tuple means?

A

T= (1,2,3,4) → packed
a,b,c,d= (1,2,3,4)→unpacked
print(a) #1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what are dictionaries?

A

key:value pair withiin flower brackets
keys cant be similar but values can

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

keys()

A

Marks{“maths”:100, “physics”:100, “chemistry”:100}

print(Marks.keys())
prints all keys

17
Q

values()

A

prints all values

18
Q

items()

A

prints all items in dictionary

19
Q

get()

A

gets specified value for key

20
Q

update()

A

merges a dictionary with another
print(D1.update(D2))
puts D2 in D1

21
Q

del()

A

deletes element with its key

22
Q

clear()

A

removes everything if you print then you will get empty dictionary