




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





The figure below shows an algorithm, represented using pseudo-code. The algorithm calculates the total cost of hiring a hotel for a wedding.
IF numberOfGuests > 50 THEN
ELSE IF numberOfGuests โฅ 25 THEN
ELSE
ENDIF ENDIF
IF totalCost < 1400 THEN
ENDIF OUTPUT totalCost Complete the table below using the algorithm in the figure above. Input value for numberOfGuests Input value for numberOfRooms Output (^50 30 ) (^20 10 ) (^500 5 ) (Total 3 marks)
Explain how the linear search algorithm works.
(Total 3 marks)
(a) Define the term abstraction.
(1) (b) State the name for the process of breaking a problem down into sub-problems.
(1) (Total 2 marks)
OUTPUT "Please guess a letter"
(a) Which pseudo-code statement assigns the length of the string film to a variable called value? Shade one lozenge.
(1) (b) The POSITION subroutine returns the position of the first occurrence of a character in a string. For example:
(1) (c) Which of the following would be the most suitable data type for the variable year? Shade one lozenge. A Boolean B character C integer D real (1) (Total 3 mark)
Describe what is meant by an assignment statement in a program.
(Total 1 mark)
Write a Python program that:
The figure shows an incomplete Python program for a number guessing game.
**(2)** (b) Complete the test plan in the table below to test the validation of userNumber in the program in the figure above. Test number Test type Test data Expected result 1 Erroneous 150 2 Boundary 3 Normal Valid number entered (2) (c) In an earlier version of the program in Figure 1 , line 5 contained one syntax error and one logic error: whil userNumber < 1 or userNumber >= 100:
Complete the table below to describe the errors in the program on line 5. Error type Description Syntax error Logic error (2) (Total 6 marks)