year 11 computer science easter revision pack
TRANSCRIPT
Year 11 Computer Science
Easter Revision Pack
Pick a section: Foundation, Core or Mastery.
You should complete Foundation if you are working at Grade 3 or
below; Core if WAG is Grade 4-6; Mastery if Grade 7 or above.
Answer on the booklet printed, or clearly in exercise books.
You MUST pick three questions to type up on Google Docs and
submit on Google Classroom. For how to do this, see here: https://www.youtube.com/watch?v=l16NiVuydig&feature=youtu.be
Email [email protected] with questions.
Programming and algorithms
Foundation
Activity – assignment
Write Pseudo-code statements to:
1) Assign the value 11 to the variable year_group.
2) Assign the boolean value false to the variable game_over.
3) Assign the text value BLUE to the variable colour.
4) Increase the number_rooms variable by 4.
5) Assign the multiplication of variables class_size and number_rooms to
total_children.
6) Assign the value 7 to the constant days_in_week.
7) Assign the value 24 to the constant hours_in_day.
Data types
4. Julie is writing a computer game that simulates a 100 m race. Each time the space bar is pressed, the position of the player moves up by 1. When the
position reaches 100, the player has won. Here is Julie's algorithm for the program
State what is meant by selection and iteration using examples from Julie's algorithm.
Selection
Example
Iteration
Example
[4]
Core
1. Joseph is an author and programmer, and he needs to estimate how many pages his new book will have. Each page has an average of 300 words. Each chapter starts with a chapter title page. The number of pages is estimated by;
• dividing the number of words by 300 • ignoring the decimal part of the division • adding the number of chapters to this total.
Joseph uses the algorithm below to estimate the number of pages, but his
algorithm does not give the correct result.
01 INPUT numberOfWords
02 INPUT numberOfChapters
03 CONST wordsPerPage = 300
04 numberOfPages = RoundDown(numberOfWords / wordsPerPage)
05 numberOfPages = numberOfWords + numberOfChapters
06 OUTPUT numberOfPages
Joseph has used a RoundDown function to remove the decimal part of the
division, e.g. RoundDown(6.2) would return 6, RoundDown(7.8) would
return 7.
State whether this algorithm uses selection, sequence or iteration.
[1]
2(a).
For each of the pseudocode algorithms shown below, tick the appropriate box to show whether they will loop infinitely or not.
Pseudocode Will loop infinitely Will not loop infinitely
01 x = 0
02 while True
03 print x
04 endwhile
01 x = 0
02 while x < 10
03 print x
04 endwhile
01 x = 0
02 while x < 10
03 print x
04 x = x + 1
04 endwhile
01 y = 5
02 for x = 1 to y
03 print x
04 next
[4]
(b). Using pseudocode, write an algorithm that will use a count-controlled loop to print out the numbers 1 to 10 in ascending order.
[3]
3(a). A game on a computer shows six players around a table on seats. They are numbered 1 to 6 as shown below.
The names of the players are stored in an array with six elements called
PlayerName. The index position of the array is used to indicate the seat number.
For example, the value of PlayerName(1) is “Helen”.
State the value of PlayerName(3).
[1]
(b). Describe what will happen if the code for the game includes an instruction to print the value of PlayerName(7).
[2]
11. * A free drinks machine in an office provides 20 different drinks.
The machine has a small keypad with keys 0 to 9, OK and CANCEL. It also has a small
LCD screen, which can display a short message.
To get a drink, users select an item number between 1 and 20 with the keypad and
confirm their choice by pressing OK. If they make a mistake they can press the
CANCEL button and start again. If the selection is valid and the drink is available it
dispenses the drink. The display screen is used to show suitable short messages
throughout the process.
Write an algorithm for the process described above.
The quality of written communication will be assessed in your answer.
[6]
12. OCR town are holding an election with three candidates (A, B and C). An electronic
voting booth will be used to allow people to vote.
Write an algorithm that:
• Allows voters to enter either A, B or C.
• Keeps track of how many times each candidate has been voted for.
• As soon as one person has finished voting, allows the next person to vote.
• At any point allows the official to type in “END”, which will print out the number of
votes for each candidate and the total number of votes overall.
[6]
Mastery 8. There is a subroutine, HEX(), that takes a denary number between 10 and 15
and returns the corresponding hexadecimal number. E.g. HEX(10) would return “A”, HEX(15) would return “F”. Write an algorithm, using the subroutine HEX(), to convert any whole decimal number between 0 and 255 into a 2 digit hexadecimal number.
[4]
10(a). Heath is researching how long, to the nearest minute, each student in his class spends playing computer games in one week (Monday to Friday). He is storing the data in a 2D array. Fig. 2 shows part of the array, with 4 students.
For example, student 1, on Monday (day 0), played 30 minutes of computer
games.
Heath wants to output the number of minutes student 3 played computer games
on Wednesday (day 2). He writes the code:
print (hoursPlayed[3,2])
The output is 20.
i. Write the code to output the number of minutes student 0 played computer games on Wednesday.
[1]
ii. State the output if Heath runs the code:
print (hoursPlayed[2,1])
[1]
iii. State the output if Heath runs the code:
print (hoursPlayed[3,1] + hoursPlayed[3,2])
[1]
iv. Write an algorithm to output the total number of minutes student 0 played computer games from Monday (day 0) to Friday (day 4).
[3]
(b). Heath has the day of the week stored as a number e.g. 0 = Monday, 1 = Tuesday. Write a sub-program that takes the number as a parameter and returns the day of the week as a string.
[5]
(c). Heath needs to work out the average number of minutes spent playing computer games each day for the class, which contains 30 students. Write an algorithm to output the average number of minutes the whole class spends playing computer games each day.
[8]