2- Programming Flashcards

To yeet and skeet

1
Q

Variable

A

A named space in memory, large enough to store a single piece of data. Each variable has a data type.

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

Constant

A

A named space in memory with a value that can never change while the program is running. Useful for pi(which will never change) or VAT (which seldom changes). The Python language does not allow for constants, but some other languages do

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

Boolean

A

Can be either true or false

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

Character

A

A single letter, number, punctuation mark, space, etc.

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

Integer

A

Whole numbers - positive, negative or zero

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

Real

A

Decimal numbers - positive or negative (zero can also be stored in a ‘real’ variable

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

String

A

A collection of characters, used to store names, addresses, phone numbers, etc.

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

Declaration

A

Code that causes a variable to exist. Once a variable has been declared, it can be used. Trying to use a variable before it has been declared will cause an error

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

Assignment

A

The process of putting a value into a variable. Most languages use a single equals ‘=’ to do this. In the instruction i = 5, the value ‘5’ has been assigned to the variable ‘i’

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

Sequence

A

Means that instructions will always execute in the order in which they were written. Every line will be executed once and only once

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

Iteration

A

Means ‘looping’. Code that is iterative might be executed multiple times, even though it is only written once

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

Nesting

A

This involves placing one programming structure inside another one. The code above contains an IF structure (on the penultimate line) that is nested within the WHILE structure. There is no limit to the number of levels of nesting; that IF structure could have contained another WHILE structure, which itself contained another WHILE structure

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

Operation

A

An operation is an action that is performed on one or more pieces of data in order to produce additional data. There are arithmetic operations, relational operations and Boolean operations

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

Arithmetic operations

A

A process performed on one or more numbers. Examples include: + - * /

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

Relational operation

A

A comparison between two values to check, for example, whether they are equal or whether one is less than or greater than the other. Relational operations are found in IF statements and as part of loops (><=)

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

Logic operation

A

A logic operation can have one of only two outcomes - true or false. A logic operator connects together logic expressions to produce more complex logic expressions. AND, NOT and OR are the most commonly used logic operators

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

Data Structure

A

A structured (organised) means of storing related data. While a variable can only store a single piece of data, a data structure can contain many

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

One dimensional array

A

A data structure for storing multiple data items of the same data type. Think of a one-dimensional array as a row of variables. Instead of each one having a name, the whole array has a single name, while each element in the array has an index number.
The first element is always numbered ‘0’

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

Two-dimensional array

A

A data structure for storing multiple data items of the same data type. Like a one-D array but can be considered as a grid rather than a row

Elements are referred to with two numbers, much like ‘x’ and ‘y’ coordinates

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

Record

A

A data structure that can accept multiple data items. that do not need to be of the same data type. As far as Python is concerned, there is no difference between array and records, so they are managed in the same way. One record might store a student’s name, year group and average test score

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

Input

A

The process of introducing data into a computer system. An example of an input device is a keyboard

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

Output

A

The process of communicating data beyond the system, typically to a human user. An example of an output device is a monitor

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

File

A

A store of data, used by a program, that continues to exist when the program, and even the computer itself, is no longer running. Many file formats exist, and the practical aspects of this chapter deal with text (.txt) files, typically associated with a program called ‘Notepad’

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

Casting

A

Converting a piece of data to a specific data type. E.g: a user might enter a string, and the program might convert it to an integer in order to allow certain calculations

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

Random

A

A random number has been selected from a range of numbers if every number in that range had an equal chance of being selected

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

Subroutine

A

A small subsection of the whole program that performs a specific, well-defined task. If a library program were to be broken into subroutines, one subroutine might issue a book, one might handle returning a book, one might add a new member, etc.

27
Q

Benefits of a subroutine

A
  • Each subroutine can be given to a different programmer, so working as a team is straightforward
  • Subroutines can each be separately tested, without waiting for the whole program to be finished
  • Subroutines that are commonly used, such as to sort a data set, can be reused in other programs, saving time and reducing errors
28
Q

Parameter

A

A piece of data that is passed into a subroutine in order for that subroutine to do its job. Multiple parameters can be managed using commas, e.g: def displayTotals(total1, total2, total3)

29
Q

Calling

A

A process where an instruction in one part of the code tells another named part of the code to run. If you have a subroutine called ‘promptUser’, the code within that subroutine will never run without that subroutine being called

30
Q

Python subroutine calling

A

In Python you have to call a subroutine after the code for that subroutine has been added. If the code on line 18 appeared before the code on line 1, the program would not run

31
Q

Return

A

A command in which a subroutine passes a piece of data back to the line of code from which it was called. This is effectively parameter passing, but in reverse. A function is a subroutine that returns a value; a procedure is a subroutine that does not

32
Q

Difference between a function and a procedure

A
  • A function is a subroutine that returns a value

- A procedure is a subroutine that does NOT return a value

33
Q

Modularisation

A

The process of breaking a program into smaller parts called modules. A subroutine is a type of module, and the advantage of dividing a program into either subroutines or modules are the same

34
Q

Scope

A

Refers to the visibility of a variable, and can either be local or global

35
Q

Local variables

A

Local variables, along with parameters and return values, are usually a better choice than global variables. Another programmer working on another subroutine could modify global variables and make them behave unpredictably. This is not true for local variables

36
Q

A robust program

A

A robust program continues to function even when confronted with unexpected events, such as a lost network connection or a user inputting data of the wrong data type

37
Q

A secure program

A

A secure program prevents users from accessing or altering data that they should not access or alter. Usernames and passwords make up one approach for keeping a program secure

38
Q

Validation

A

Ensuring that data entered into the computer is reasonable and sensible. E.g: checking that a person’s DOB isn’t in the future. Validation does not ensure that the data is correct/true

39
Q

Range check

A

Ensures data is within a specified range e.g: ensuring race times for 100m are between 0 and 30 seconds, or ensuring a person’s birthday is not after today’s date

40
Q

Type check

A

Ensures that the correct data type has been entered (e.g. integer or Boolean)

41
Q

Length check

A

Ensures that a string contains a valid number of characters, such as in a postcode or a phone number

42
Q

Lookup check

A

Checks that what the user has entered exists on a list, such as a list of postcodes or days of the week. For shorter lists, the user can select the item from a list themselves (such as a dropdown)

43
Q

Presence check

A

Simply checks that the user has entered something. This is essentially a length check that ensures that the length is greater than zero

44
Q

Authentication

A

The software process of ensuring that the person accessing a system is the person who is supposed to access that system

45
Q

Possible methods of authentication

A
  • Usernames and passwords
  • Memorable info - prompting for something only the real user should know, e.g: a fav place or name of 1st pet
  • Checking that the user is using their usual computer, by logging the IP address
46
Q

Test Data: Normal (typical)

A

Data that is valid and that represents how the program would be used

47
Q

Test Data: Boundary (extreme)

A

Data that is just barely valid, to check that the extreme ranges of normal input work correctly. It’s also good practise to test just outside the acceptable range

48
Q

Test Data: Erroneous

A

Data that should not be accepted by the system. This is included to test whether a program’s validation and error messages work correctly

49
Q

What is high level language (HLL)

A

High-level languages are more understandable to humans than low-level languages, so high-level languages are far more popular

50
Q

Examples of HLL

A
  • Java
  • VB
  • Python
  • C#
51
Q

What do you need in order to run code written in a HLL

A

Either an interpreter or a compiler to enable the code that is typed to be translated into machine code so that the computer can run it

52
Q

What does code in a HLL look like

A

One line of code might do several things, e.g.:

A = B + C

This instruction finds out the values of B and C, adds them together, then stores the result in B.As one line of code can do several things, one line of a high-level language often translates into several lines of machine code

53
Q

HLL Suitability

A
  • More appropriate if the program is to be used on a variety of different computer builds
  • Far more people are proficient in high-level than low-level languages, and this may dictate the language type used
54
Q

What is low level language (LLL)

A

More difficult to understand but can often be executed very quickly by computers

55
Q

Examples of LLL

A
  • Machine code (which consists of ‘1’s and ‘0’)
  • Assembly code, which is a way of making machine code slightly more readable by using mnemonics. For instance, the command 0110 1010 makes no sense, whereas a command like ADD 34, 32 gives a slightly better clue as to what is going on
56
Q

What do you need in order to run code written in a LL

A

Machine code does not need to be translated -it is machine ready. Assembly language requires an assembler

57
Q

What does LLL code look like

A

One line of code performs a single task. In assembly language:

LDA B
ADD C
STA A

These instructions would perform the same task as ‘A = B+ C’. Machine code, to most people, would be a sequence of unintelligible ‘1’s and ‘0’s, but each line of assembly code translates to one line of machine code.

58
Q

LLL suitability

A
  • Likely to be used within embedded systems, where specific memory locations and processor functions can be addressed directly
  • Suited to time-critical applications, where execution must take place as quickly as possible
59
Q

Machine code

A

Machine code is machine-specific, meaning a machine code program written for one computer will not necessarily work on another. This is because different computers sometimes have different internal layouts and components, which can affect the way that machine code is run

60
Q

Translator

A

A program that translates source code (which is written by the programmer) into machine code (which can be executed by the comp)

61
Q

Types of translator

A
  • Assemblers: Translate assembly language
  • Interpreters: Translate then execute high level code, one line at a time
  • Compilers: Translate an entire high level program before executing it

Computers can only execute machine code. If a program is written using any other language, it must be translated to machine code before it can be executed

62
Q

An interpreter

A

Adv:

  • A program that contains errors can still be run, up to where the error exists
  • Debugging is easier as the problematic line can be more easily pinpointed

Dis:

  • Every time you run the program, it needs to be interpreted, which is time consuming
  • It is easier for unauthorised people to access your source code
63
Q

A compiler

A

Adv:

  • A compiled object code file will run more quickly then re-interpreting a source code file
  • It is more difficult for unauthorised people to modify a compiled object code file

Dis:

  • More memory is needed for the compilation process than for interpretation
  • The entire program needs to be error free in order for it to compile