Programming Y10 Assessment Flashcards

1
Q

Describe what is meant by ‘data type’

A

The data type determines what type of value the variable will hold.

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

Define ‘integer’, ‘real’, ‘Boolean’, ‘character’ and ‘string’ data types

A

INT - 2/4 bytes - whole number,

REAL - 4/8 bytes - decimal numbers,

BOOL - 1 bit needed but 1 byte usually used - TRUE/FALSE,

CHAR - 1 byte - a single alphanumerical character

STRING - 1 byte per character - One or more alphanumeric characters

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

Declare and assign constants and variables

A

Constant) CONSTANT PRESSURE

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

Describe ‘iteration’

A

There are times when a program needs to repeat certain steps until told otherwise, or until a condition has been met. This process is known as iteration

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

Describe ‘Selection’ + example with multiple selections

A

Selection is a programming construct where a section of code is run only if a condition is met.

IF \_\_ THEN
     OUTPUT ‘_’
ELSE IF _ THEN
	OUTPUT ‘_’
ELSE
	OUTPUT ‘_’
ENDIF
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Use and explain definite (count-controlled) iteration

A

When a program needs to iterate a set number of times, this is known as definite iteration and makes use of a FOR loop.
FOR k

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

Use and explain indefinite (condition-controlled) iteration:

A

• Indefinite iteration repeatedly executes a section of code until a condition is met - or no longer met. There are two types of indefinite iteration:
• WHILE loops - uses the statements WHILE and ENDWHILE
WHILE total < cost
coinValue

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

Use and explain nested structure

A

Including one programming construct within another.
• FOR x ← 1 TO 10
FOR y ← 1 TO 10
result ← y * x
OUTPUT y + “ * “ + x + “ = “ + result
ENDFOR
ENDFOR

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

Explain the need for meaningful identifiers

A

Making sure you use variable names that describe what the variable contains is very important. Poor variable names can make it difficult to work out what is going on in your program

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

Write code that accepts keyboard input

A

name ← USERINPUT

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

Write code to display output on a screen

A

OUTPUT “Hello” + name

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

Write code to perform string operations ‘length’, ‘position’, ‘substring’ and ‘concatenation’

A
  • LEN(string)
    * POSITION(string, character)
    * SUBSTRING(x, y, string)
    * Concatenation - multiple strings joined together : newString
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Write code to cast one data type as another

A
  • STRING_TO_INT(‘1)
    * STRING_TO_REAL(‘1.0’)
    * INT_TO_STRING(1)
    * REAL_TO_STRING(1.0)
    * INTs and REALs have quote marks, strings don’t!
      • CHAR_TO_CODE(‘b’)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Write code that performs arithmetic operations (addition, subtraction, division, multiplication)

A
  • +
    * -
    * *
    * /
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Write code that performs relational operations (combinations of less than, equal to, not equal to and greater than)

A
  • =
    * ≠
    * <
    * >
    * ≤
    * ≥
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Distinguish between low-level and high-level languages - examples and definitions

A

• Machine code is the set of instructions that a CPU understands directly and can act upon. A program written in machine code would consist of only 0s and 1s - binary. This is very difficult to write and debug. Even a very simple program could have thousands of 0s and 1s in it.
• Assembly language sits between machine code and high-level language in terms of ease of use. While high-level languages use statements to form instructions, assembly language uses mnemonics - short abbreviations. Each mnemonic directly corresponds with a machine code instruction.
High level - These languages are close to natural language - the spoken and written language of humans

17
Q

Distinguish between interpreters, compilers and assemblers for program translation

A

• An interpreter translates source code into machine code one instruction at a time. It is similar to a human translator translating what a person says into another language, sentence by sentence, as they speak. The resulting machine code is then executed immediately. The process is called interpretation..
• A compiler takes the source code as a whole and translates it into machine code all in one go. Once converted, the object code can be run unassisted at any time. This process is called compilation.
The purpose of an assembler is to translate assembly language into machine code.Whereas compilers and interpreters generate many machine code instructions for each high-level instruction, assemblers create one machine code instruction for each assembly instruction

18
Q

When is low-level language more suitable?

A

Low level languages are used to write programs that relate to the specific architecture and hardware of a particular type of computer.

19
Q

2 Benefits of using programming language that is interpreted rather than compiled?

A
  • Instructions are executed as soon as they are translated.
    * Errors can be quickly spotted - once an error is found, the program stops running and the user is notified at which part of the program the interpretation has failed. This makes interpreters extremely useful when developing programs.
20
Q

3 Benefits of using a programming language that is compiled instead of interpreted?

A
  • Compiled programs run quickly, since they have already been translated.
    * A compiled program can be supplied as an executable file. An executable file is a file that is ready to run. Since an executable file cannot be easily modified, programmers prefer to supply executables rather than source code.
    * Compilers optimise code. Optimised code can run quicker and take up less memory