Paper 2 Programming Techniques Flashcards

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

What is a variable?

A

Variables are data values that can change when the user is asked a question, for example, their age. Variables may change during program execution.

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

What is a constant?

A

Data values that stay the same every time a program is executed are known as constants

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

State the ‘data types’ required for the following variables: student_name

A

Text / String

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

State the ‘data types’ required for the following variables: student_age

A

Float i.e. 16.5 years
Integer i.e. 16 years
Date - Date of Birth (can work out a persons age by calculation)

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

State the ‘data types’ required for the following variables: student_sex

A

Boolean (m/f)

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

State the ‘data types’ required for the following variables: student_height

A

Float i.e. - 5ft 10 inches

Integer i.e. - 178 cms

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

State the ‘data types’ required for the following variables: student_first_initial

A

Char (only one letter)

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

Name the 3 constructs of a programming language

A
  • sequence is the order in which instructions occur and are processed.
  • selection determines which path a program takes when it is running.
  • iteration is the repeated execution of a section of code when a program is running.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain the difference between how FOR loops and WHILE loops control the flow of instructions during the running of a program.

A

For loop contains only a single condition whereas while loop may contain a set of commands to be executed together.
In for loop, initialization of command is done only once but in while loop initialization of command is needed each time the iteration of command is done

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

An operator is something which will perform an action on some data. What does an arithmetic operator do?

A

Arithmetic operators allow arithmetic to be performed on values such as + - / *

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

An operator is something which will perform an action on some data. What does a relational operator do?

A

Relational operators allow for assignment and enable comparisons to be made. They are used in condition testing such as ==, >, < , <=, >=

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

An operator is something which will perform an action on some data. What does a Boolean operator do?

A

Logical operators are used to combine relational operators to give more complex decisions such as AND, OR, NOT

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

What is an array (or list in Python)?

A

An array is a data structure that holds similar, related data. An array is like a collection of boxes, each of which is called an element . Each element has a position in the array, and can hold a value. The data in an array must all be of the same data type .

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

For the given array:
my_array = [“train”, “walk”, “car”, “bus”, “cycle”]
…how would you access the 3rd item?

A

my_array[2]

Arrays (or lists in Python) always has the first element as 0

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

What is the difference between a 1-dimensional array and a 2-dimensional array?

A

The main difference between 1D and 2D array is that the 1D array represents multiple data items as a list while 2D array represents multiple data items as a table consisting of rows and columns. … The elements in the array are in subsequent memory locations.

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

Explain the difference between a static and dynamic data structure.

A

A static data structure is one that has a fixed size and cannot change at run time A dynamic list is able to adapt to accommodate the data inside it and so it does not waste as much space.

17
Q

Why is file handling an important aspect of programming?

A

Programs process and use data. When the program finishes, or is closed, any data it held is lost. To prevent loss, data can be stored in a file so that it can be accessed again at a later date.

18
Q

What two modes of operations do Files have?

A

Files have two modes of operation - read from and write to.

19
Q

What is the difference between a ‘Local’ and ‘Global’ variable?

A

The main difference between Global and local variables is that global variables can be accessed globally in the entire program, whereas local variables can be accessed only within the function or block in which they are defined.

20
Q

What is the difference between a ‘Procedure’ and a ‘Function’?

A

A function returns a value and a procedure just executes commands.
The name function comes from math. It is used to calculate a value based on input.
A procedure is a set of commands which can be executed in order.