Python Flashcards

1
Q

What is <

A

Less than

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

What is <=

A

Less than or equal to

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

What is >

A

Greater than

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

What is >=

A

Greater than it equal to

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

What is ==

A

Equal to

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

What is !=

A

Not equal to

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

What is and

A

As well as

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

What is or

A

This or that

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

How would you write a line of code for a integer variable

A

Number = int(input(“”))

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

What do you need at the end of your ‘if’, ‘Elif’ and ‘else’ statement before your print command

A

A colon :

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

Which brackets do lists go into

A

[box brackets]

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

What number does a list assign to the first in the list

A

0

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

What does
list.append(item)
Do

A

Add an item to the end of the list

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

What does
list.insert(index, item)
Do

A

Insert an item at a given position

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

What does
list.pop(index)
Do

A

Removes the item at the given position in the list, and return it. If not index specified, remove and return the last item in the list

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

What does
list.remove(item)
Do

A

Remove the first item from the list with a particular value. Raises a ValueError if there is no such item

17
Q

What does
list.index(item)
Do

A

Search for the first occurrence of an item in the list and return its (zero-based) index. Raises a ValueError is there is no such item

18
Q

What does
list.count(item)
Do

A

Return the number of times an item appears in the list

19
Q

What does
list.reverse()
Do

A

Reverse the items of the list

20
Q

what does
list.sort()
Do

A

Sort the items if the list

21
Q

What does
list.sort(reverse = True)
Do

A

Use the reverse = True argument to sort in descending order

22
Q

When working with lists do the things in the brackets have speech marks?

A

Yes

23
Q

What is a list

A

A list is a kind of data structure, an organized collection of data

24
Q

What is the number given to the first value in a list

A

0

25
Q

When printing about lists what do you need to refer to

A

the name of the list

26
Q

what is len

A

A function that can show us the length of different data types

27
Q

how do you print len

A

print(len(name of list))

28
Q

what is necessary when printing a random number

A

that the ‘import random’ line goes at the beginning of the program to allow the function to work

29
Q

what does
random.randint(!,£)
mean

A

it gets the program to print any number between the two values

30
Q

what does
random.uniform(!,£)
mean

A

it gets the program to print any number but with a decimal between the two values

31
Q

what does
random.randrange(!,£,$)
mean

A

it gets the program to print a random number between the two values, but it has to be a multiple of $

32
Q

what does
random.choice([’%’],[‘&’])
mean

A

it gets the program to choose between the two values

33
Q

when printing a 2D list what setup do you need

A

variable = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]

34
Q

what code do you use to ask the user to enter the new figure (in the first column) into a 2D list

A

north = int(input(“Enter north figure: “))

35
Q

what code do you use to ask the user to enter the new figure (in the last column) into a 2D list

A

south = int(input(“Enter south figure: “))

36
Q

Why do we use variables

A

to keep track of counts and sums

37
Q

why do we use iteration (for statements)

A

to iterate over strings of characters

38
Q

write the base code for repetition of an action 5 times

A

for variable in 5: