2.2.1 Programming fundamentals Flashcards
What is a variable? [2]
A location in memory [1] that stores a value [1]
What is a constant? [1]
A variable that should not be changed while the program is running [1]
What are the 5 data types for variables? [5]
Character, Real, Integer, Boolean, String
What is the operator for equal to?
==
What is the operator for not equal to?
!=
What is the operator for less than or equal to?
<=
What is the operator for greater than or equal to?
> =
What does MOD do?
Divides and gives the remainder, e.g. 5 MOD 2 = 2
What does DIV do?
Divides and discards the remainder, e.g. 3 DIV 2 = 1
What does the ^ operator do?
Exponentiation, e.g. 2 ^ 3 is 8
What is 9 MOD 5?
4
What is 7 DIV 2?
3
How would you write this statement in Python? If the user’s age is greater than 12, but below 20.
if age > 12 and age < 20
How would you write this statement in Python? If the user’s name is ‘Dave’ or ‘Sarah’
if name == ‘Dave’ or name == ‘Sarah’
Assign the value “Dave” to the variable name
name = “Dave”