Python 2 Flashcards

1
Q

What python command will calculate the remainder of a division?

For example if we want to know the remainder of 9 divided by 2.

What is this type of calculation called?

A

print(9 % 2)

This type of calculation is called ‘Modulo’

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

What does a NAMEERROR indicate?

A

A NAMEERROR indicates that a variable hasn’t been defined or it has been mis-typed.

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

What is squared in maths?

A

Squared is the power of 2

5 squared is 5 ** 2= 25

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

What is cubed in maths?

A

Cubed is the power of 3

5 cubed is 5 * 5 * 5 = 125

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

What combination of brackets, quotes used in the following commands?

print a string
create a variable as a string, as an integer and as a float
print calculations

A
Print  a string use ("")
print a variable use ()
Create a text variable uses ""
create an integer or float variable use no quotes and no quotation marks
print calculations uses ()

single or double quotes can be used

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

What do Programmers call the process of updating a program so that it no longer contains unexpected errors?

A

Debugging

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

When you have a number saved as a variable and you wanrt to increase to reflect the new value of the variable, what operator would you use?

A

+=

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

What is a boolean expression?

A

A boolean expression is a statement that can either be true or false.

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

How do we write the ‘equals to’ and ‘not equals to’ operators in Python?

A

equals to ==

not equals to !=

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

What command would you use to display the data type of a variable?

In your example use a variable called instrument

A

print(type(instrument))

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