Previous Module
Next Module

COMPUTER SYSTEMS: Encoding and compression

COMPUTER SYSTEMS: Network topologies

COMPUTER SYSTEMS: Wired and wireless networks, protocols, and layers

COMPUTER SYSTEMS: Threats to computer systems and networks

COMPUTER SYSTEMS: Operating systems and utility software

ALGORITHMS AND PROGRAMMING: Types of data

ALGORITHMS AND PROGRAMMING: Producing robust programs

ALGORITHMS AND PROGRAMMING: Designing, creating, and refining algorithms

  • On the right is an example of a program to identify whether a user’s test score is above a threshold of 50%.

# Original algorithm

score = int(input(“Enter score:”))

 
 

if score < 0 or score > 100:

print(“Invalid score”)

elif score > = 50:

print(“Pass”)

else:

print(“Fail”)

  • If we needed to amend this algorithm to account for a new requirement, such as checking for scores above 90 to be awarded a distinction, then we could add the following

# Amended algorithm

score = int(input(“Enter score:”))

 
 

if score < 0 or score > 100:

print(“Invalid score”)

elif score > = 70:

print(“Distinction”)

elif score > = 50:

print(“Pass”)

else:

print(“Fail”)

Unlock Amending algorithms

Subscribe to SnapRevise+ to get immediate access to the rest of this resource.

Premium accounts get immediate access to this resource.

Previous Module
Next Module