T4 Homework 4
T4 Homework 4
1 password = "EpCg3E4("
2 validPassword = False
3 while not validPassword:
4 userPass = input("Enter the password: ")
5 if userPass == password:
6 print "Valid password")
7 validPassword = True
8 else:
9 print("Invalid password")
(c) Explain one other type of error that a programmer could make when programming.
Logic errors are errors which produce an unexpected output due to a mistake made in the
logic of the programming.
However, this type of error does not stop the program from running.
1
Homework 4 Trace tables and errors
Unit 1 Computational thinking
Explain two reasons why the second algorithm is more efficient than the first.
There are no iterations in the second algorithm while the first algorithm has 3 iteration of its
Program.
This makes the second algorithm require less processing and more efficient,
The first algorithm uses 3 variables while the second algorithm uses 2 variables.
2
Homework 4 Trace tables and errors
Unit 1 Computational thinking
[Total 14 Marks]