Unit 8 - Logic and Languages Flashcards
(41 cards)
What does 1 in binary represent?
TRUE
What does 0 in binary represent?
FALSE
What are Boolean Functions?
A function that always produces a true or false (1 or 0) value, regardless of the input values.
What are the 3 examples of Boolean Functions?
AND
OR
NOT
What is a truth table?
Shows the output from all possible combinations of inputs from a Boolean function
IF there are 2 inputs (A and B), there are 4 possible combinations of TRUE and FALSE.
How does an AND gate function?
IF both inputs are TRUE, then the output is TRUE
ELSE, the output is FALSE
How does an OR gate function?
IF either input is TRUE, then the output is TRUE
ELSE, IF both are not TRUE, then the output is FALSE
How does a NOT gate function?
IF the input is TRUE, then the output is FALSE
IF the input is FALSE, then the output is TRUE
What does Input/Data Validation do?
Ensures that data is of the right type and meets certain rules (should be reasonable)
What are the types of validation checks?
Range check: A number or date is within a sensible range
Type check: Data is of the right type (e.g. integer, letter or text)
Length check: Text entered is not too long or too short
Presence check: Checks that data has been entered
Format check: Checks if the format is correct
What is Input/Data Verification?
Used to double check that the data has been typed in correctly
What are authentication routines used for?
Used to make sure a person is who they claim to be
What is anticipating misuse?
Preventing too many entries of a password to make it harder for hackers to guess
Why do programs need to be maintained?
To improve the code
Fix bugs
Add new features to the program
How should programs be written to be easily maintainable?
. The use of subprograms
. Using appropriate naming conventions
. Indentation
. Commenting
What is a subprogram?
Subprograms are small programs written within a larger main program. They perform a specific task, which may need to be done more than once at various points in the main program.
There are two types of subprograms:
Procedures
Functions
What are naming conventions?
Using good variables and sub program names to make the program easier to read
What is indentation?
Makes programs easier to read by making it possible to see easily which lines of code are part of different structures
What is commenting?
Helps programmers understand what a program does and how it does it. Normally it is in front of a function or procedure and explains what it does.
What is an IDE?
An integrated development environment is a suite of tools that helps a programmer write error-free, maintainable code.
-It may give tips on the syntax of the statement you are typing
-Keywords and text in each of the statements are in different colours
-Automatic indentation
What does an IDE typically provide you with?
. An editor (allows writing and correcting a program & helps in writing correct syntax
. A compiler/interpreter (to translate the program into machine code)
. Error Diagnostics (To point out syntax errors)
. Debug facilities ( going through the program line at a time to find logic errors)
. A runtime environment (to run the program)
What are logic errors?
A logic error is an error in the way a program works. The program simply does not do what it is expected to do.
We can use a trace table to find the purpose, outputs and errors in the algorithm (for logic errors)
What are syntax errors?
A syntax error occurs when code is written that does not follow the rules of the programming language.
Examples include:
.Misspelling a statement, e.g. writing pint instead of print
.Using a variable before it has been declared
.Missing brackets, e.g. opening a bracket but not closing it
What is test data?
Test data is data that is used to test whether or not a program is functioning correctly.