Professional Documents
Culture Documents
ii) What would have happened if the above algorithm was executed?
iii) What is the expected output from the above algorithm after correction?
num1=2
num2=3
for index in range(1,3):
num1=num1*num2
num2=num2+num1
print(num1)
print (num2)
Page 1 of 7
ii) How many times will the loop be executed?
iii) What is type coercion?
c) Write a written description of an algorithm, to check whether the number centered is even or
odd. The algorithm should display the message accordingly.
a = 40
b = 20
c = 30
d = 10
x=0
x = (a + b) * c / d
print ("Value of (a + b) * c / d is ", x)
x= ((a - b) * c) / d
print ("Value of ((a + b) * c) / d is ", x)
x = (a + b) / d
print ("Value of (a + b) / d is ", x)
Output
Value of (a + b) * c / d is
Value of ((a - b) * c) / d is
Value of (a + b) / d is
2) Here is an algorithm expressed in pseudocode which calculates the pay of the employees
Page 1 of 7
3. SEND ‘Please enter the rate.’ TO DISPLAY
4. RECEIVE Rate FROM KEYBOARD
5. SET pay TO NumHour*Rate
6. SEND pay TO DISPLAY
a) List any two variables in the pseudocode.
b) Identify the line number which calculates the pay of the employees.
c) Draw a flowchart for the above algorithm.
Page 1 of 7
print ("Discount 10%")
elif (totalSpend > 0)
print ("No discount")
else:
print ("Invalid input")
Page 1 of 7
A
Page 1 of 7
5) a) List the types of computational model?
INPUT PROCESS
Tab
New line
Displays “
b) Computers store all data as patterns of 0's and 1's. Information systems using 0's and 1's are
collectively known as binary information systems.
i) State two types of data that can be represented in binary in a digital computer.
Page 1 of 7
7)a) Find the denary equivalent of the following binary numbers. Show your working.
i) 01011100
ii) 11001100
i) 75
27 26 25 24 23 22 21 20
Place values 128 64 32 16 8 4 2 1
ii)28
27 26 25 24 23 22 21 20
Place values 128 64 32 16 8 4 2 1
i) 10011111 + 00110000
d) Carry out an arithmetic shift right 3 places on the following binary numbers which is in two’s
compliment.
i) 10010101
Page 1 of 7
ii) 10101000
8) a) Show the stages of bubble sort when applied to the following list.
10 8 17 14 6
(b) (i) Calculate the file size of an image having a width of 2432 and height 4224 pixels
with a bit colour depth of 24.
Page 1 of 7