SDD - Implementation Flashcards

1
Q

In a programming language of your choice write code to create a create a variable called score and save 0 in the variable

A

score = 0

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

In a programming language of your choice write code to set name to Mr Oliver

A

name = “Mr Oliver

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

What type of programing construct is being demonstrated below:
Set valid to True
Write code to carry out this action in programming language of your choice

A

Construct: Assignment
Python: valid = True

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

Using a programing language of your choice write code to create a variable called totalCost and assign the value 17.80 it the variable

A

totalCost = 17.80

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

Write pseudocode to create a variable called favShow and assign Ninjago to it

A

favShow = “Ninjago” or
Set favShow to Ninjago

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

What do the arithmetic operation constructs shown below below do?

  • /
A

+ Add
- Subtract
* Multiply
/ Divide
^ Exponent (power of)

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

What arithmetic operation constructs does this symbol ^ do?

A

^ Exponent (power of)

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

What is the result of the arithmetic operation constructs shown below :
**2^3 **

A

8
^ is exponent(power of)
2 3
2x2x2=8

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

Write the symbols for the arithmetic operation constructs shown below?
Add
Subtract
Multiply
Divide
Exponent

A

+ Add
- Subtract
* Multiply
/ Divide
^ Exponent (power of)

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

What type of programing construct is being demonstrated below:
add 5 to the total

A

arithmetic operation

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

A program has recorded the number of female and male students stored in variables called numFemale and numMale
Using a programming language of your choice: Calculated the total number of students and assign it to a variable called numStudents

A

numStudents = numFemale + numMale

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

Line 11 RECEIVE noTickets FROM (INTEGER) KEYBOARD
Line 12 set price to 25
Line 13 < calculate totalCost >

Using a programming language of your choice: Write the code for line 13

A

totalCost = noTickets x price

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

Code: totalPay = hoursWorked x rate + bonus
An employee has worked 10 hours, and has a rate of £12 per hour and a £30 pound bonus.
Caluate the totalPay

A

(12 x 10) + 30
120 + 30
150

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

What is Concatenation?

A

Concatenation means joining two or more strings together.

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

What is the name of the programing construct which joining two or more strings together.

A

Concatenation

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

A program stores the users name is a variable called name.

Using a programing language of your choice write code which would produce the following output if Lucy was stored in the variable name.
Output
Hello Lucy, how are you?

A

Python:
print(“Hello “ + name + “, how are you?”)

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

State the output after this program has been run.

Set subject to “Computer Science”
Set result to “pass”
Display “I can “ & result & “ “ & subject

A

I can pass Computer Science

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

Using a programming language of your choice write a program to do the following.

RECEIVE firstName FROM (STRING) KEYBOARD
RECEIVE surname FROM (STRING) KEYBOARD
SEND firstName & surname TO DISPLAY

A

Python:
firstName = input(“Enter First Name”)
surname = input(“Enter Surname”)
print(firstName + surname)

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

The total viewing figures for a show should be displayed as.
The show was watched by 1.2 million
Using a programming language of your choice and the variable numViewers
, write the code to produce the output above.

A

print(“The show was watched by” + numViewers + “million”)

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

What does the logical constructs < mean/do?

A

Less than

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

What does the logical constructs <= mean/do?

A

Less than or equal

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

What does the logical constructs >= mean/do?

A

Greater than or equal

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

What does the logical constructs != mean/do?

A

not equal

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

What does the logical constructs == mean/do?

A

equal to

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

What is the logical construct for less than?

A

<

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

What is the logical construct for less than or equal?

A

<=

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

What is the logical construct for greater than?

A

>

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

What is the logical construct for greater than or equals?

A

> =

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

What is the logical construct for not equal to?

A

!=

30
Q

What is the logical construct for equal to?

A

==

31
Q

What type of programing construct is demonstrated below?
if choice = “A”

A

Conditional statement/Selection statement

32
Q

What is the condition the Pseudocode below?
IF choice == “A” THEN
DISPLAY “You have ordered Chips”
END IF

A

choice == “A”

33
Q

What is the condition the Python below?
if exam_mark >= 70:
print(“Grade: A”)

A

exam_mark >= 70

34
Q

How many conditions are shown in the Python below?
if exam_mark >= 70:
print(“Grade: A”)
elif exam_mark >= 60:
print(“Grade: B”)
elif exam_mark >= 50:
print(“Grade: C”)

A

3
exam_mark >= 70
elif exam_mark >= 60:
elif exam_mark >= 60:

35
Q

A program should ask the user to enter their salary as an integer. If the salary is above 37,430 then a message should be displayed to say there salary above average

Using a design design techniques of your choice (pseudocode) write this program.

A

Get salary (integer) from user
If salary > 37430 then
Display “Salary above average”
End If
or
Get salary from user
If salary > 37430 then
________Send to screen “Your salary is above the national average”

Key points -
1) you must get the salary
2) you must have an If
3) it must have an the condition to check the salary is over 37430
4) you need to show scope of the if (end if or indented code)

___ used to show indent

36
Q

A program should ask the user to enter the 1st phase of the software development process. If the user enters ‘Analysis’, the program should display the message “Correct”, otherwise it should display the message “Incorrect”.

Using a programming language of your choice write this program.

A

answer = input(“What is the 1st phase of the software development process?”)
if answer == “Analysis”:
print(“Correct”)
else:
__print(“Incorrect”)

___ used to show indent

37
Q

The program shown below asks for a mark then works out the Grade the student should get.

1 Display ‘Enter Student Mark:’
2 Get Mark from User
3 if mark >= 70
4 __display ‘A’
5 if mark >= 60 and < 70
6 __display ‘B’
7 if mark >= 50 and < 60
8 __display ‘C’
9 if mark >= 40 and < 50
10 __display ‘D’
11if mark < 40
12 __display ‘Fail’

A programmer has noticed this code is not as efficient as it should be.
Why is the above code not efficient?
Using a programming language of your choice, rewrite line 3 - 12 to make the program more efficient.

A

1) The code uses multiple if statements when and elif statement should be used
2)
if mark >= 70:
__display ‘A’
elif mark >= 60:
__display ‘B’
elif mark >= 50:
__display ‘C’
elif mark >= 40:
__display ‘D’
else:
__display ‘Fail’

___ used to show indent

38
Q

A program is required to rate hotels. The user should be asked to enter a rating between 0 and 10 and then the hotel recommendation will be shown.

Input: 8 or above Output: Excellent
Input: 5 to 7 Output: Reasonable
Input: Below 5 Output: Poor

Using a programming language of your choice, write a program for the above

A

rating = int(input(“Enter a rating:”))
if rating >= 8 :
__display ‘Excellent’
elif rating >= 5:
__display ‘Reasonable’
else:
__display ‘Poor’

___ used to show indent.

note: int required to make the code work but probably not required for the marking sheme

39
Q

Name the 3 logical operators.

A

AND
OR
NOT

40
Q

Describe what the AND logical operator does

A

AND
The condition will be True if both statements are True

41
Q

Describe what the OR logical operator does

A

OR
The condition will be True if either one, or both of the statements are True

42
Q

Describe what the NOT logical operator does

A

NOT
Reverses the result - A True result would become false

43
Q

Which logical operator is described below?
The condition will be True if both statements are True

A

AND
The condition will be True if both statements are True

44
Q

Which logical operator is described below?
The condition will be True if either one, or both of the statements are True

A

OR
The condition will be True if either one, or both of the statements are True

45
Q

Which logical operator is described below?

Reverses the result

A

NOT
Reverses the result

46
Q

State the output of this program when the status is valid.

IF NOT status = “expired” THEN
__display ‘Offer 1’
ELSE
__display ‘Offer2’
END IF

A

Offer1

Explanation:
status = expired would be false
Not status = expired /Not false would be True.

47
Q

State the output of this program when the status is expired.

IF NOT status = “expired” THEN
__display ‘Offer 1’
ELSE
__display ‘Offer2’
END IF

A

Offer2

Explanation:
status = expired would be True
Not status = expired /Not True would be False.

48
Q

State the output of this program when the status is expired.

IF status = “expired” OR status = “trial” THEN
__display ‘Offer 1’
ELSE
__display ‘Offer2’
END IF

A

Offer1

Explanation:
status = expired would be TRUE
status = trial would be FALSE
OR only needs for one condition to be met

49
Q

State the output of this program when the status is Renewed.

IF status = “expired” OR status = “trial” THEN
__display ‘Offer 1’
ELSE
__display ‘Offer2’
END IF

A

Offer2

Explanation:
status = expired would be FALSE
status = trial would be FALSE
Both statements evaluate to FALSE
OR - at least one condition must be met

50
Q

State the output of this program when the status is valid and the age 22

IF status = “expired” OR age<16
THEN
__display ‘Offer 1’
ELSE
__display ‘Offer2’
END IF

A

Offer2

Explanation:
status = expired would be FALSE
age<16 would be FALSE
Both statements evaluate to FALSE
OR - at least one condition must be met

51
Q

State the output of this program when the status is expired and the age 14

IF status = “expired” OR age<16
THEN
__display ‘Offer 1’
ELSE
__display ‘Offer2’
END IF

A

Offer1

Explanation:
status = expired would be TRUE
age<16 would be TRUE
Both statements evaluate to TRUE
OR - at least one condition must be met (both being TRUE would met this requirement)

52
Q

State the output of this program when the status is expired and the age 14

IF status = “expired” AND age<16
THEN
__display ‘Offer 1’
ELSE
__display ‘Offer2’
END IF

A

Offer1

Explanation:
status = expired would be TRUE
age<16 would be TRUE
Both statements evaluate to TRUE
AND - Both conditions must be true which they are in this case.

53
Q

State the output of this program when the status is expired and the age 22

IF status = “expired” AND age<16
THEN
__display ‘Offer 1’
ELSE
__display ‘Offer2’
END IF

A

Offer2

Explanation:
status = expired would be TRUE
age<16 would be False
Only one statements evaluates to TRUE
AND - both conditions must be met, in this case they have not been

54
Q

A progrm is required for a shop to calculate the total bill to be charged to a customer. A 10% discount should be applied to any business customer who spends more than £1,000.
Algorithm
1. Get cost of Goods
2. Get accountType
3. Calculate Discount to be applied
4. Calculate total cost
Refine step 3. Using a programming language of your choice, write a program for the above.

A

IF type == “business” AND goodsCost > 1000:
__discount = goodsCost * 0.1
ELSE:
__discount = 0
or
discount = 0
IF type == “business” AND goodsCost > 1000:
__discount = goodsCost * 0.1

___ used to show indent.

n.b. variable name not given in question therefore any sensible variable name can be used.

55
Q

Name the 2 type of loops

A

Fixed Loop and Conditional Loop

56
Q

Describe a Fixed Loop

A

A fixed loop will always execute a set(fixed) number of times.
Note when you start running the loop you will know how many times it will run.

57
Q

Describe a Conditional Loop

A

conditional loop will execute while a specific condition is being met, or until a specific condition is met.

58
Q

What type of loop is this

Pseudocode
REPEAT WHILE number < 1
DISPLAY “Error, please enter number again”
END REPEAT

A

Conditional Loop

59
Q

What type of loop is this

Pseudocode
REPEAT WITH counter FROM 1 to 10
DISPLAY counter
END REPEAT

A

Fixed Loop

60
Q

What Type of Loop is this?
for counter in range(0, 10):
__print(counter)

A

fixed loop

61
Q

What type of loop is this?
guess = input(“Enter Guess”)
while guess != “bob”:
__print(“You are wrong guess again”)
__guess = input(“Enter Guess”)

A

conditional

62
Q

name the 3 predefined functions you need to know for Nat 5

A

random
round
length

63
Q

What does the random function do?

A

The random function returns a random number between two parameters.

64
Q

what does the round predefined function do?

A

The round function returns a decimal number rounded to a given number of places.

65
Q

what does the length predefined function do?

A

The length function returns the length of a string

66
Q

Using a programming language of your choice create a program to pick a number between 1 and 50 and assign it to a variable called pick.

A

import random

pick= random.randint(1, 50)

67
Q

Using a programming language of your choice, write a code to round the totalPrice to 2 decimal places and assign the value a variable called displayPrice

A

displayPrice = round(totalPrice,2)

68
Q

Using a programming language of your choice, write code to check a the length of a variable called password and save the result in a new variable called passwordLen

A

passwordLen = len(password)

69
Q

Name the 3 standard algorithms for National 5

A

running total
input validation
traversing an array

70
Q

Write the steps for the input validation standard algorithm

A

The steps of this algorithm are:
1. Ask the user to input something
2. Start a while loop, while the input does not meet the condition (e.g. while age < 15)
3. Show an error message
4. Ask the user to input (again)
5. End while loop

71
Q

Write the steps for the running total within a loop standard algorithm

A

Potenial Step: Set up the values in the array (this may not be required - as array may already be created or updated via user input)
1. Set total to 0
2. Start a for loop (for or while)
3. Add value from array/user input to total
4. End for loop
5. (possible step) You me be required to display to display the total at the end of the loop

72
Q

Write the steps for the traversing a 1-D array standard algorithm

A
  1. Start a for loop, for the number of elements in the array
  2. Use the array element[counter] to perform action on array element (e.g print)
  3. End the for loop