2.2 - Programming fundamentals Flashcards

1
Q

What does + do?

A

Adds two variables

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

What does - do?

A

Subtracts two variables

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

What does * do?

A

Multiplies 2 variables

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

What does / do?

A

Divides 2 variables

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

What does % (MOD) do?

A

Outputs the remainder of the division

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

What does // (DIV) do?

A

Divides 2 variables but only shows the integer value (integer division)

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

What does == do?

A

Shows 2 strings are equal to each other

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

What does != do?

A

Shows 2 strings are not equal to each other

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

The 3 basic programming constructs

A
  • Selection - the path a program takes when running based on a decision
  • Sequence - executing one instruction after the other
  • Iteration - the repeated execution of a section of code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a variable

A

A named memory location which stores a value that may change during the execution of the program

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

What is a constant

A

A value that cannot change when the program is run and is assigned when the program is made

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

What is assignment

A

Giving a variable or constant a value. This is done by an “=” sign

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

What is an identifier and rules that an identifier must follow

A
  • The name of the variable
  • It must start with a letter
  • Cannot contain special characters
  • Cannot have spaces
  • NAme should be meaningful
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Advantages of constants

A
  • Make a program easier to read as they are declared at the start
  • Can be changed in one single place instead of changing in multiple places meaning errors are reduced
  • Compiler can optimise the code meaning it can be run more quickly when using constants
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a case statement

A
  • Where a program can branch off in several different paths depending on the value of a variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Two forms of iteration and when are they needed

The 3 types of statements fall into these 2 categories

A
  • Count controlled loop (for loop) - when the number of iterations is known ahead of time
  • Condition controlled loop (do…until and while loops) - used when the number of iterations is notknown as the variable controlling the iteration changes within the loop itself
17
Q

Difference between a do…until loop and a while loop

A
  • While - Condition is checked AT THE TOP. In a while loop, if the condition is met before the loop, the while loop will never run
  • Do…until - the code will execute AT LEAST ONCE as the exit condition is checked AT THE END.
18
Q

What coomand must be used to stop a while loop

A
  • BREAK in python
  • ENDWHILE in exam question langauge
19
Q

What is nesting, why is it needed and different types of it

A
  • Including one program construct within another e.g. loop in a loop reducing the amount of code needed making it easier to edit and debug
  • Nested selection - increases the number of paths at a decision point
  • Nested iteration
20
Q

What is casting and why is it needed

A
  • Changing a data type of a variable from one type to another
  • It allows numbers to be manipulated as strings can be