Computer (2nd Quarter) Flashcards

1
Q

Making a list called “list” with the items: “Item1”, “Item2”, and “Item3”

A

list = [“Item1”, “Item2”, “Item3”];

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

List items are indexed, the first item has index:

A

0

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

Make the result “green”

colorlist = [ “red”, “blue”, “green”]

A

print(colorlist [ 2 ])

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

Adds an element at the end of the list

A

append( )

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

Adds an element at the specified position

A

insert( )

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

Removes the item with the specified value

A

remove( )

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

Removes all the elements from the list

A

clear( )

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

Add “black” to the end of the list “colorlist”

A

colorlist.append(“black”)

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

Add “white” to the beginning of the list “colorlist”

A

colorlist.insert(0, “white”)

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

Remove “blue” from the list “colorlist”

A

colorlist.remove(“blue”)

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

Clear the “colorlist”

A

colorlist.clear( )

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

Remove the element at the third position from the list “colorlist”

A

colorlist.pop(3)

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

Print “colorlist”

A

print(colorlist);

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

Add the elements of a list, to the end of the current list

A

extend( )

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

Extend “colorlist” by adding the list “numberlist”

A

colorlist.extend(numberlist)

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

Removes the element at the specified position

A

pop( )

17
Q

Returns the index of the first element with the specified value

A

index( )

18
Q

Print the index of “violet” in the list “colorlist”

A

print(colorlist.index(“violet”))

19
Q

Returns the number of elements with the specified value

A

count( )

20
Q

Print the number of times “violet” is in the list “colorlist”

A

print(colorlist.count(“violet”))

21
Q

Sorts the list

A

sort( )

22
Q

Sort the list “colorlist”

A

colorlist.sort( )

23
Q

Reverses the list

A

reverse( )

24
Q

Reverse the list “colorlist”

A

colorlist.reverse( )

25
Q

Returns a copy of the list

A

copy( )

26
Q

Make the list “colorlist2” a copy of the list “colorlist”

A

colorlist2 = colorlist.copy( )

27
Q

While (one <= two), print (one) then add 1 to one

A

while (one<=two):
print(one);
one=one+1;