Python 2 Flashcards
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?
print(9 % 2)
This type of calculation is called ‘Modulo’
What does a NAMEERROR indicate?
A NAMEERROR indicates that a variable hasn’t been defined or it has been mis-typed.
What is squared in maths?
Squared is the power of 2
5 squared is 5 ** 2= 25
What is cubed in maths?
Cubed is the power of 3
5 cubed is 5 * 5 * 5 = 125
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
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
What do Programmers call the process of updating a program so that it no longer contains unexpected errors?
Debugging
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?
+=
What is a boolean expression?
A boolean expression is a statement that can either be true or false.
How do we write the ‘equals to’ and ‘not equals to’ operators in Python?
equals to ==
not equals to !=
What command would you use to display the data type of a variable?
In your example use a variable called instrument
print(type(instrument))