Software Design and Development - Implementation Flashcards Preview

National 5 Computing Science > Software Design and Development - Implementation > Flashcards

Flashcards in Software Design and Development - Implementation Deck (18):
1

How do you assign a value to a variable?

Assigning a value to a variable e.g.
In reference language
SET score TO 20
In Livecode
put 20 into score

2

How do you use Arithmetic in a program?

Using arithmetic (+, -, /, *, ^) e.g.
In reference language
SET total TO total + score
In Livecode
put total + score itno total

3

What is concatenation?

Joining two or more strings or substrings
For example in Livecode:
put firstname & “ “ & surname into fullname
Would join first name and surname and include a space between both
In Reference language:
SET fullname TO firstname + “ “ + surname

4

What selection constrcuts can be used?

< Less than
> Greater than
≤ Less than or equal to
≥ Greater than or equal to
= Equals
≠ Does not equal

5

What is an IF statement?

An If statement IS NOT A LOOP. IF statements allow
the program to make decisions. Conditions, such as
score <10 are used within IF statements.
IF score < 10 OR score >50
SEND ‘Try Again’ TO DISPLAY
END IF
This IF statements checks to see if a score is less than 10 or higher than 50

6

What is a nested IF statement?

Nested IFs are IF statements inside IF statements.
The nested parts only run if needed.
IF score < 100 THEN
SEND “Low Score” to DISPLAY
ELSE
IF score < 150 THEN
SEND “Mid level score” TO DISPLAY
ELSE
SEND “High score” TO DISPLAY
END IF
END IF

7

What are Logical Operators?

Logical operators can be used in
IF statements and conditional loops.

AND – Both conditions must be true

OR – One condition must be true

NOT – The opposite outcome to what would logically apply (negation)

8

What is a simple condition?

A simple condition has only one condition e.g.
IF firstname = “Betty”
The condition is = “Betty”

9

What is a complex condition?

A complex condition has two or more conditions e.g.

IF firstname = “Betty” OR firstname = “Trevor”

The two conditions are = “Betty” , = “Trevor”

AND /OR are used as part of complex conditions

10

What is repetition / iteration?

Repetition and iteration are technical terms for
loops. Repetition repeats a task set number of times. Iteration is the same but usually involves checking
over the contents of an array until you achieve what you want to achieve e.g. find a number or get to the end of the array list
.

11

What is a fixed loop?

A fixed loop will repeat all code held within the loop a
set number of times only. E.g.
For loop = 0 to 9

Next loop
The above loop would repeat 10 times

12

What is a conditional loop?

A conditional loop repeats until a condition is met e.g.
WHILE score < 10

END WHILE
This loop will repeat the code inside as long as the score variable holds a value that is less than 10

13

What is the ROUND function?

ROUND is a pre-defined function, meaning the code
to make it work already exists. If you use
the ROUND function, the computer will round a value to a certain number of decimal places:

SET size TO ROUND (measurement, 1)

This takes the value of the measurement variable and rounds it to one decimal place. It then returns this new value to the size variable

14

What is the RANDOM function?

RANDOM is a pre-defined function, meaning the
code to make it work already exists. If you use the RANDOM function, the computer will generate a random number:
SET bonusBall TO RANDOM(1, 59)
This would generate a random number between
1 and 59 and returns this number to the bonusBall variable.

15

What is the LENGTH function?

LENGTHis a pre-defined function, meaning the code to
make it work already exists. If you use the LENGTH function, the computer will calculate the number of characters held in a string variable:
SET numberOfCharacters TO LENGTH (firstname)
This would take the value in the first name variable, calculate its length and returnsit to the numberOfCharacters variable. E.g. Jane would return
4

16

Describe the INPUT VALIDATION algorithm

This algorithm checks that input is valid:
Line 1 SEND “Enter a score between 1 and 99” TO DISPLAY
Line 2 RECEIVE score FROM (INTEGER) KEYBOARD
Line 3 WHILE score ˂1 OR score ˃99 DO
Line 4 SEND "Error, enter valid number" TO DISPLAY
Line 5 RECEIVE score FROM (INTEGER) KEYBOARD
Line 6 END WHILE

17

Describe the RUNNING TOTAL algorithm

This algorithm keeps a running total:
Line 1 DECLARE total INITIALLY 0
Line 2 FOR loop FROM 0 TO 4 DO
Line 3 RECEIVE number FROM (INTEGER) KEYBOARD
Line 4 SET total TO total + number
Line 5 END FOR
It asks for and keeps a running total of 5 values.

18

Describe how to traverse a one dimesional array

To traverse an array means to use a loop to go
through the array one item at a time.

DECLARE allGrades INITIALLY [A, B, B, D, F]
FOR EACH grade FROM allGrades DO
IF grade = 'A' THEN
SET a_total TO a_total +1
END IF
END FOR EACH

In the above example, each item in the all Grades array is checked one after another, with a running total also
calculated.