Unit 8 - Logic✔️ Flashcards

1
Q

define data validation?

A

is an automatic check to ensure that data entered is sensible and feasible however it can not ensure data is accurate but only check the data entered is reasonable

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

why is data validation important when programming?

A

stops unexpected or abnormal data from crashing your program

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

define what a range check does?

A

Checks the data falls between an acceptable upper and lower value, within a set range

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

define what a type check does?

A

Checks that the data entered is of an expected type, e.g. text or a number

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

define what a length check does?

A

Checks the number of characters meets expectations, e.g. an 8 character password

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

define what a presence check does?

A

Checks that the user has at least inputted something, stopping them from accidentally entering nothing

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

define what a format check is?

A

An extra digit added to a number which is calculated from the other digits, this ensures the rest of the number has been entered properly

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

define data verification?

A

is used to double-check that the data has been typed in correctly eg a user setting a new password may be asked to enter it twice

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

what are authentication routine used for?

A

used to make sure a person is who they claim to be eg being asked to enter a User ID

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

why do programs need to be maintained?

A

-improve the code
-fix bugs and add new features

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

how can programs be written so that they can be easily maintained?

A

-commenting
-indentation
-use of sub programs (functions and procedures)
-using appropriate naming conventions

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

what is the point of indentatin?

A

makes it possible to easily see which lines of the code are part of different structures

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

what is the point of commenting in your code?

A

-helps other programmers to understand your code
-helps with difficult to understand parts
-at the start of functions to explain what it does

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

what should naming conventions be?

A

it is important to use meaningful names for variable ,functions and procedure so they are easy to understand

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

Example of high-level programming language?

A

Python, Visual Basic, C#, Java, C++

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

Example of Markup languages?

A

HTML, XML

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

Example of a Low-level Programming languages?

A

Assembly language

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

Example of query language?

A

SQL

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

What is machine code?

A

In first computers,all programs were written in machine code - instructions were written in binary (101011001001) - each instruction did one very small task but writting programs was difficult and time -consuming

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

Features of assembly language?

A

• Assembly language is processor-specific
• It has to be translated into machine code before it can be executed
• As each instruction corresponds directly to a machine code instruction, it is known as a low-level language

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

What are high-level languages?

A

•High-level languages generally have statements that look a bit like English or Maths

• This makes these languages easier to learn and understand easy to learn
and understand

22
Q

Features of high-level languages?

A

• High-level languages also have data structures such as arrays and records

• Many high-level languages have been especially designed to make it as easy as possible to write programs to solve certain types of problem

• The translation is done by a program which may be either a compiler or an interpreter

23
Q

What is assembly language (low-level language)?

A

•Assembly language allows a programmer to create programs more easily then writing in machine code

• Each assembly language instruction maps directly to machine code

24
Q

How is the source code translated into machine code?

A

• A compiler or interpreter is used to translate the source code (written by the programmer) into object code (machine code) for that processor

25
Q

Advantages of high-level languages?

A

• A high-level language is easier to learn
• Programs can be written faster in a high-level language
• It is easier to understand and debug a high-level language

26
Q

Advantages of low level languages?

A

• A program written in a low-level language can run very quickly
• The code will usually require less RAM
• Statements in a low-level language can be used to control and manipulate specific hardware components
As a results this language is often used for programs such as device drivers

27
Q

Features of a interpreter?

A

• Unlike a compiler, no object code is produced
• It translates each line of code and executes it immediately
• If it reaches a line with a syntax error, it stops and displays an error message

28
Q

Features of a compiler?

A

•compiler translates a high-level language into object code(machine code)
• The code written by the programmer is called the source code
• The code produced by the compiler is called the object code
• The object code can be saved a storage drive and run whenever required

29
Q

Why are device drivers often written in low level language (assembly code)?

A

Because low-level language can run very quickly and the code will usually require less ram and statements in low-level language can be used to control and manipulate specific hardware components

30
Q

Order of high and low level languages?

A

High level language (eg java)→ low level language (for example assembly language) → machine code → harware

31
Q

Define what a syntax error is?

A

• A syntax error is one where the code written doesn’t conform to the rules of the language and the compiler doesnt know how to translate the profram into machine code - the program can not be run until all the syntax error are fixed

32
Q

What are logical errors?

A

• The program will run, but it won’t work as the programmer intended

33
Q

What will a test plan normaly test for? And why?

A

• Normal data
• Boundary data
• Invalid data
• Erroneous data

It is important that programs are fully tested to find logical errors

34
Q

What are trace tables?

A

A trace table is useful for tracing through a program in order to find a logic error
• The value of each variable is recorded as it change

35
Q

3 uses of trace tables?

A

• Determining the purpose of an algorithm
• Finding the output of an algorithm
• Finding errors in an algorithm

36
Q

Define iterative testing?

A

tests modules and parts of a program as the program is developed - the programmer will usually test the code with knowledge of how it works

37
Q

Define final testing?

A

• Final testing (also known as terminal testing) tests the whole program at the end of production - the end user wont necessarily know how it works

38
Q

3 examples of a syntax error?

A

print(“hello)
14 = age
remainder = 10 MD 3

39
Q

Name four types of test data?

A

Normal, boundary, invalid, erroneous

40
Q

What is a truth table?

A

Truth table shows the output from all possible combinations of inputs from a boolean expression (eg AND,OR and NOT)

41
Q

What does the AND logic gate do?

A

Both inputs must be true for outputs to be true (eg if inputs are 0 , 0 ouput is 0 but if inputs are 1, 0 ouput is 1) - if both inputs are 1 than the ouput is 1 otherwise the ouput is 0

42
Q

What does the OR logic gate do?

A

At least one input must be true for output to be true (eg if inputs are 1 , 0 output will be 1 but if input is 0 , 0 ouput is 0) - if either input is 1 then the output is 1

43
Q

What does the NOT logic gate do?

A

The output is opposite to the input (if the input is 1 the output is 0)

44
Q

What are IDEs?

A

Intergrated development enviorments - They have a number of tools and features that help programmers when they are programming

45
Q

example of some common IDEs?

A

-Visual studio
-IDLE

46
Q

What are 4 common features of IDEs?

A

-line numbers
-breakpoints
-code folding
-variable watching

47
Q

Why are line numbers useful?

A

• Line numbers allow a programmer to clearly see each new line of code
• When errors are found, the line number that they occur on will also be stat
• parts of the code that do not need to be seen can be folded

48
Q

Why is syntax highlighting useful?

A

• Syntax highlighting is where the colour of the text changes to show different parts of the program
• important keywords,strings and variables are diffrent colours - makes it easier for the programmer to identify them

49
Q

What is error dignostics and how is it helpful?

A

• Error diagnostics help a programmer to find where they have made a mistake
• Error are identified along with the line number they occur on
• code may also be underlined or highlighted to show the error

50
Q

What is the use of the run-time enviorment?

A

The run-time environment allows a programmer to test their program while it is running - if the program crashes the run-time enviorment can see what happened and give useful information to the programmer

51
Q

What are error diagnostics?

A

Comments from the IDE that help in finding the cause of syntax errors

52
Q

Why are breakpoints set by programmers?

A

Set so that the IDE stops the program mid-way through running