2.2.1 Programming fundamentals Flashcards

1
Q

What is a variable? [2]

A

A location in memory [1] that stores a value [1]

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

What is a constant? [1]

A

A variable that should not be changed while the program is running [1]

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

What are the 5 data types for variables? [5]

A

Character, Real, Integer, Boolean, String

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

What is the operator for equal to?

A

==

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

What is the operator for not equal to?

A

!=

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

What is the operator for less than or equal to?

A

<=

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

What is the operator for greater than or equal to?

A

> =

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

What does MOD do?

A

Divides and gives the remainder, e.g. 5 MOD 2 = 1

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

What does DIV do?

A

Divides and discards the remainder, e.g. 3 DIV 2 = 2

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

What does the ^ operator do?

A

Exponentiation, e.g. 2 ^ 3 is 8

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

What is 9 MOD 5?

A

4

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

What is 7 DIV 2?

A

3

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

How would you write this statement in Python? If the user’s age is greater than 12, but below 20.

A

if age > 12 and age < 20

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

How would you write this statement in Python? If the user’s name is ‘Dave’ or ‘Sarah’

A

if name == ‘Dave’ or name == ‘Sarah’

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

Assign the value “Dave” to the variable name

A

name = “Dave”

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

Take a user’s name as an input and assign it to the variable name.

A

name = input(“Enter your name”)

17
Q

What is a count controlled loop? [3]

A

A loop that repeats [1] until a count is reached [1] a for loop. [1]

18
Q

What is a condition controlled loop? [3]

A

A loop that repeats [1] while a condition is met [1] a while loop [1]

19
Q

Is this code selection or iteration?

while name != “Dave”:
name = input(“Enter your name”)

A

Iteration