Slides badge

Evaluation

Starter

A program is designed to take in ID numbers and store them in a database. The IDs cannot be longer than ten characters but must be longer than three characters. For example, an ID could be 561A4 or 9D3JKL3. Fill in the test plan below with just two examples.

Type Examples Expected result
Normal
Extreme
Exceptional

Learning Intentions

  • To describe and exemplify evaluation of a solution in terms of: fitness for purpose, efficiency, robustness and readability.

Success Criteria

  • Be able to describe the terms of:
  • - fitness for purpose
  • - efficiency
  • - robustness
  • - readability
  • and how these relate to software development

Fitness for purpose

  • Fitness for purpose is how well a program fulfils it original functional requirements. 
  • The functional requirements were agreed at the analysis stage by both the developer and the client. 
  • If any of these requirements are not met, the software is considered to not be fit-for-purpose.

A program is written to take in 20 numbers. It must then ensure that the numbers are between 0 and 100 (inclusive). The program then displays the average of these numbers. Is this program fit-for-purpose?

Try it yourself

total = 0

for i in range(20):
  print("Please insert number", (i + 1))
  n = int(input())
  total = total + n

average = total / 20

Fit for purpose

Not fit for purpose

A program is written to take in 20 numbers. It must then ensure that the numbers are between 0 and 100 (inclusive). The program then displays the average of these numbers. Is this program fit-for-purpose?

Try it yourself

total = 0

for i in range(20):
  print("Please insert number", (i + 1))
  n = int(input())
  total = total + n

average = total / 20

Efficiency

  • Efficiency is, without any doubt, the most crucial component of large-scale software development.
  • Any software that is inefficient needs improved to improve efficiency and ensure that the software doesn't waste time and resources.
  • Additionally, efficient software should make good use of the developers' time, not wasting it typing repetitive code.
  • Think about something like Windows where time is very important.
  • Think about when you use Python. We always want a loop to complete in as little time as possible.

Efficiency

largest = 0
for i in range(len(numbers)):
    for j in range(len(numbers)):
        if numbers[j] > largest:
            largest = numbers[j]

print("The largest number is", largest)
  • Imagine that numbers has ten elements in it. What is the minimum number of times this will loop?

10 times

20 times

100 times

Efficiency

largest = 0
for i in range(len(numbers)):
    for j in range(len(numbers)):
        if numbers[j] > largest:
            largest = numbers[j]

print("The largest number is", largest)
  • Imagine that numbers has ten elements in it. What is the minimum number of times this will loop?

This is inefficient!

Efficiency

largest = 0
for i in range(len(numbers)):
  if numbers[i] > largest:
    largest = numbers[i]

print("The largest number is", largest)
  • Imagine that numbers has ten elements in it. What is the minimum number of times this will loop?

10 times

20 times

100 times

This is inefficient!

Efficiency

largest = 0
for i in range(len(numbers)):
  if numbers[i] > largest:
    largest = numbers[i]

print("The largest number is", largest)
  • Imagine that numbers has ten elements in it. What is the minimum number of times this will loop?

This solution is much more efficient

Efficiency

  • Inefficiency in code can normally be identified as:
    • Not using loops to repeat something over and over again
    • Where an algorithm such as a running total could be used to make the code easier to implement
    • Using a fixed loop where a conditional loop may have been better
    • Not using an array where appropriate

inefficiency - example 1

  • A program is expected to take in a range of numbers and store them in an array. It will loop until the user types in -1.
#A big array
numbers = [0] * 1000
position = 0
user_num = 0

while user_num != -1:
  user_num = int(intput("Please insert a number or -1 to exit"))
  numbers[position] = user_num
  position = position + 1

 print(numbers)
  • What happens if the user types in 5 separate numbers, then -1? There are still 995 spaces left in the array that are not needed.

inefficiency - example 2

A program is expected to display the total of 5 numbers in an array.

numbers = [31, 63, 32, 74, 32, 12, 94]

for i in range(0, 5):
  print(numbers[i])

Then what is the point in having seven numbers in the array?

Making it more efficient 1

number1 = int(input())
number2 = int(input())
number3 = int(input())
number4 = int(input())
number5 = int(input())

total = number1 + number2 + number3 + number4 + number5
print(total)

Using an array 

Using predefined functions

This can be made more efficient by:

Using a conditional loop

Using a fixed loop

Making it more efficient 2

print(0)
print(2)
print(4)
print(6)
print(8)
print(10)

Using an array 

Using predefined functions

This can be made more efficient by:

Using a conditional loop

Using a fixed loop

Making it more efficient 3

total = 0
numbers = [1, 2, 3, 5, 8, 13, 21, 34, 55]

for n in numbers:
  total = total + 1

print("There are " + str(total) +  " numbers.")

Using an array 

Using predefined functions

This can be made more efficient by:

Using a conditional loop

Using a fixed loop

for i in range(0, 30):
  n = input("Please insert a number")
  if n > 50:
    print("You gave me a number > 50")
    break

Robustness

  • Robustness is another way of evaluating software.
  • A robust program should be able to cope with errors (or exceptions) during runtime.
  • Input validation allows us to check that the value the user has inserted is within the range and is also valid. This adds robustness to a program.
  • For example, imagine a program that takes in two numbers. The user then types their name for the first number. What would happen as a result of this?

Other ways of dealing with exceptions

  • Try and Except can be used to deal with exceptional data too. 
  • Whilst it is beyond the scope of the National 5 course, it is useful to know that the industrial standard of using try and except to stop errors (exceptions) interfering with the running of the program. 
try:
  x = int(input())
  print(x + 5)
except:
  print("Cannot add the numbers together. Are you sure you provided an integer?")

Readability

  • Readability is all about how easy the code is to understand.
  • There are four ways discussed at National 5:
    • Comments
    • Meaningful identifiers
    • Indentation
    • White space

Readability : Comments

  • Comments are something you should all be doing at National 5.
  • The most important comment that should be in every program that you write is the first comment which describes what the program does.
  • To comment your code you use the # sign at the start of a comment.
#Program to calculate the average
#Written by J Balfour 2020

Readability : Meaningful identifiers

  • Identifiers are names given to variables and subprograms (both known as first-class citizens)
  • A meaningful identifier is one that describes the purpose of it through it's name. For example, if a variable is to contain a forename, call it forename.
  • You can use underscore case or camelCase when you are writing variable names or subprogram names (subprograms are Higher only)
  • Variable names and subprogram names cannot be keywords in Python.
def john:
  alice = 10
  bob = 20

  zelda = alice + bob
  return zelda

Readability : iNDENTATION

  • Indentation is used to show the structure of a program. 
  • Python enforces indentation and is one of the only languages to do this. 
  • When you write an if statement, you'll notice the lines after are indented. 





if c > 10:
  print("This line is indented")

Readability : White space

  • White space is another way of making code more readable. 
  • White space involves creating sections of the code with no content. For example, spacing out lines by adding a blank line after each line.
  • White space is employed in website design to make a website more readable, too.
x = 10
y = 20
z = x * y
print(z)
x = 10
y = 20

z = x * y

print(z)

Readability : White space

  • White space is another way of making code more readable. 
  • White space involves creating sections of the code with no content. For example, spacing out lines by adding a blank line after each line.
  • White space is employed in website design to make a website more readable, too. 
x = 10
y = 20
z = x * y
print(z)
x = 10
y = 20

z = x * y

print(z)

Answer the questions on software evaluation

 

 

Lookup the rules for identifiers in Python. For example, can they start with underscores? (It's also a good idea to write these down so that you remember them for the future, e.g. for the coursework)

 

 

If you finish all of that, you can go straight on to past papers on this topic on Achieve and then revise for the end of topic test.

Task

Drag and drop task

Past Paper Questions

Customers who spend £50 or more on tickets qualify for a number of food vouchers. Step 5 of the algorithm has been implemented below.

Line 23 IF totalCost < 50 THEN

Line 24     SEND "Sorry, no food voucher" TO DISPLAY

Line 25 ELSE

Line 26     IF totalCost >100 THEN

Line 27         SEND "You have been awarded 2 food vouchers" TO DISPLAY

Line 28     ELSE

Line 29         SEND "You have been awarded 1 food voucher" TO DISPLAY

Line 30     END IF

Line 31 END IF

When the completed code is tested, a user enters 2.5 for the number of adult tickets. The program continues to run and calculates the total cost.

 

Explain how the program could be made fit for purpose.

2018 Q21 (b) (ii)

ensure only integers are accepted
input validation with appropriate explanation.

Past Paper Questions

The following pseudocode design shows how an available seat is allocated.


1 generate a random seat number
2 loop while the generated seat is unavailable
3     generate another random seat number
4 end loop
5 change seat to unavailable

 

Explain why the above design becomes less efficient as more passengers
are allocated seats.

2022 Q8 (c) (iii)

a number/seat generated is more likely to be allocated already

demonstrating an understanding that the above will cause the program to repeat/loop again

Presentation Overview
Close
JB
Evaluation
© 2020 - 2025 J Balfour
22:50 | 12-12-2025
Join Live Session
Go Live
Start Remote
Save Progress
Slideshow Outline
Presenter Mode
Bullet Only Mode
Generate Quiz
Generate Lesson Plan
Widget Screen
Canvas Controls
Fullscreen
Random Selector
Timer
Volume Meter
Binary Converter
Python Editor
Show Knox 90
Provide Feedback
Help
!
Keywords
    DragonDocs Management
    Random selector
    Set a timer for how long?
    10:00
    5:00
    3:00
    2:30
    2:00
    1:00
    ...
    Sections
      Binary conversion
      Denary to binary conversion
      Binary to denary conversion
      Feedback 👍
      Accessibility

      Apply a filter:

      Apply theme

      Blue theme
      White theme

      More effects:

      ×
      Loading
      All slideshow files