DATA STRUCTURES Flashcards

1
Q

How to insert and item

A

list.insert(i, x)
where i is the Index x is the value

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

how to remove first item

A

list.remove(x)
where x must math first item

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

how to remove any item from any position given

A

list.pop(i)
whre i is the index

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

how to remove the last item of a list with pop function

A

list.pop()
empty function

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

How to return the index value of an item

A

list.index(x)

x is the value of the item

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

How to count how many values are the same

A

list.count(x)
where X is the value to count, must have a value

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

How to reverse the list

A

list.reverse()
list will be reverse

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

How to sort a list

A

list.sort()

ascending = default
decending = reverse = True

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

Dictionaries - what is the syntax

A

dic = { key : value , key: value}

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

How to remove an entry from a dictionary

A

dic.pop( ‘Key’ )
only the key is needed

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

How to add an entry to a dictionary

A

dic.update( { Key : value})

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

How to sort dictionary by Keys - ascending and descending

A

sorted( dic ) – ascending
sorted( dic , reverse=True) –descending

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

What is a TUPLE

A

a data structure that can contain multiple data types, but cannot be edited

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

What is TUPLE syntax

A

mytup = ( value, value, value)

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

What is a SET

A

a data structure that holds UNIQUE VALUES
any type of data but must be equal

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

What is the syntax of a SET

A

my_set = { value, value)

it can hold different types of data

17
Q

Another way of do a SET

A

my_set = set( value, calue)

must be the dame data

18
Q

sytax for a SET union

A

set1.union(set2)

19
Q

syntax for a SET difference

A

set1.difference(set2)

it plot what values are in set 1 that are not in set 2 and viceversa

20
Q

syntax for a SET intersection

A

set1.instersection(set2)