Python Flashcards

(16 cards)

1
Q

append()

A

Adds element to end of list

mylist.append(“Apple”)

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

clear()

A

Removes all elements from list

mylist.clear()

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

count()

A

Counts elements in list

mylist.count()

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

index()

A

Returns first index number of element in a list or string

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

remove()

A

Removes 1st item of specified value

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

pop()

A

Removes element from the specified position from a list or dictionary.

List.pop(2)

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

insert()

A

Inserts at a specified position in a list

mylist.insert(2, “Apple”)

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

reverse()

A

Reverses the list in place

mylist.reverse()

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

len()

A

Gives length

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

sort()

A

Sorts lists alphabetically in place

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

split(), in a string. Separates by what? What is the whole command string

A

Puts elements into a list. Separates by spaces or what is put in parentheses. List = “this is a string”
List.split()

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

Print every other starts on which element

A

The first element

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

Sort and reverse commands issue

A

Does it in place so you can’t assign to a new name because they only return none

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

range () options

A

One number, or a range of numbers with steps. Ex…for n in range(start_num, end_number,steps)

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

Sorted()

A

To sort a list not in place. Will not change the original list. This allows a new list to be saved.

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

Reversed ()

A

Reverses but doesn’t change original. Can be used to create a new list.