Unit 1 - Fundamentals of Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is an algorithm?

A

An algorithm is a sequence of steps, which if followed, can successfully solve a problem.

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

Define pseudocode.

A

Pseudocode is a form of code somewhere in the middle of plain English and programming language code. It uses similar statements to code and mathematical terms, and acts as an aid to help plan out the code before you actually start to code.

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

Give an advantage of pseudocode.

A

As pseudocode is in the middle of a programming language and English, it is generally easy to use as the programmer won’t need to worry about getting the exact programming syntax.

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

What is an identifier?

A

An identifier is a name which points to a specific memory location.

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

What is assignment?

A

An assignment is where a value is assigned to a memory location/identifier.

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

Give the names of common data types used in code.

A
  • String
  • Character
  • Integer (whole number)
  • Boolean value
  • Decimal (float)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define a variable.

A

A variable is a memory location holding a data value in a computer program. It can be referenced or changed in a program from time to time.

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

What is a constant?

A

A constant is a fixed data value which stays the same throughout the whole program and can only be changed in the source code, but the whole program would have to be recompiled for that change in value.

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

Why use a constant?

A

A constant is useful because if you have a program which is quite number heavy, than instead of changing each individual data value, by changing the value of the constant, all the values in program instantly are updated, saving a significant amount of time.

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

What is the modulus (mod for short) operator?

A

The mod operator is an operator which returns the remainder of integer division.

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

What is the div operator?

A

The div operator is an operator which returns only the integer part of integer division.

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

Give examples of string handling functions.

A

Examples of string-handling functions include the len function which returns the length of a string and the .find function which helps find a certain part of the string, returning the position of the first character of the phrase requested.

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

Define program flow.

A

Program flow is the sequence of execution of instructions in a program.

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

What do selection statements such as the if statement do?

A

Selection statements help maintain this program flow throughout the whole program.

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

What is iteration?

A

Iteration is the repetition of a sequence of instructions in a program. It is very efficient and significantly reduce unnecessarily rewriting lines of code.

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

State the three types of iteration.

A
  • While … ENDWHILE loop
  • REPEAT … UNTIL loop
  • FOR loop
17
Q

Describe the WHILE loop.

A

The WHILE loop is an iteration loop where the instructions within the loop will only be executed if the entry conditions are true. This loop is used if the user doesn’t know how many times they will iterate.

18
Q

Describe the REPEAT … UNTIL loop.

A

The REPEAT … UNTIL loop is an iteration loop where the contents of the loop are executed first then the entry condition is evaluated.

19
Q

What is a range check?

A

A range check is where the loop will continuously prompt the user for input until a correct value is input.

20
Q

Define an infinite loop.

A

An infinite loop is a constantly repeating loop of code which arises from an error in a while loop.

21
Q

Give a use of an infinite loop.

A

Infinite loops are commonly used within computational control and data sensing devices; upon execution of setup code, an infinite loop will help the device constantly check the value of sensors.

22
Q

Give another use of an infinite loop.

A

Another common use of infinite loops are in 2D games where fast infinite loops are executed to help the sprite catch up with the player’s actions, ensuring a smooth animation.

23
Q

What is a FOR … NEXT loop?

A

A FOR … NEXT loop is an iteration loop where definite iteration is implemented; this is where the number of repetitions is specified beforehand. A counter variable within the loop will constantly be incremented automatically.

24
Q

What is a subroutine?

A

A subroutine is a set of instructions with a name appropriate to its role.

25
Q

What is a function?

A

A function is a subroutine which typically returns one or two values.

26
Q

Describe a local variable.

A

The local variable is variables which are declared within the subroutine.

27
Q

Describe a global variable.

A

A global variable is a variable declared within the main program where the subroutine is called.

28
Q

Define the scope of a local variable.

A

As a local variable is declared within a subroutine, the scope of this type of variable will simply be the subroutine it is in.

29
Q

What is modular programming?

A

Modular programming is a form of programming where the program is broken down in several subtasks and the subtasks can be further broken down into modules

30
Q

What is the difference between a parameter and an argument?

A

A parameter is data included in the parentheses of a subroutine/function while an argument is the data included in the calling of a subroutine in the main program.

31
Q

State an advantage of local variable.

A

The subroutine is independent so the subroutine and its local variable(s) can be reused.

32
Q

Give another advantage of a local variable.

A

When calling a subroutine in the main program, there is little to no chance of accidentally changing the variable as it is defined already in the subroutine.

33
Q

Describe an advantage of modular programming.

A

By breaking down a large program into simpler subtasks and modules, it becomes much easier to manage and complete.

34
Q

Give another benefit of modular programming.

A

Modules can be re-used many times in a program.