Term pack
Grade 9 Computer Science
Name: ________________________
Skills in this pack
- How strong a password is
- Spotting a phishing message
- The trail you leave online
- Working out a file size
- Making a file smaller
- Lists and their positions
- Looping over a list
- Building a list as you go
- Text inside a program
- Repeating while something is true
- Searching a list
- Putting a list in order
Free at www.arenapublications.com/learn — no account, no ads, ever.
Grade 9 Computer Science · 1 of 12
How strong a password is
Work out how many different passwords a rule allows, and use that count to say which of two rules is harder to guess your way through.
1.A door keypad takes a code of exactly 4 characters, and each character is one of its 5 buttons. How many different codes are there for somebody to get through?
2.Put these rules in order of how many different passwords each one allows, fewest first.
- 5 characters from 4
- 3 characters from 9
- 3 characters from 6
- 2 characters from 25
3.One website's rule allows passwords 6 characters long, with 10 characters allowed in each position. Another website's rule allows passwords 4 characters long, with 30 characters allowed in each position. Which rule allows more passwords?
- a) The rule with 4 characters and 30 choices
- b) There is not enough here to tell
- c) The rule with 6 characters and 10 choices
- d) The two rules allow exactly the same number
4.A rule allows 3 characters taken from a set of 20, and a guessing machine gets through 1000 passwords a second. How many seconds does the machine need before it has tried the lot?
5.Sort each of these rules by how many different passwords it allows.
Groups: Fewer than 1000 · More than 1000
- 3 characters, each one of 11
- 2 characters, each one of 30
- 4 characters, each one of 7
- 3 characters, each one of 9
- 2 characters, each one of 45
- 2 characters, each one of 12
6.Each of these rules allows some number of different passwords. Match each rule to that number.
- 2 characters from 15
- 3 characters from 5
- 2 characters from 21
- 4 characters from 4
- 3 characters from 12
- 256
- 441
- 125
- 225
- 1728
7.A student has 9 accounts and has used the same password on all but 3 of them. One of the websites is attacked and that password is taken. How many of the nine accounts can the attacker now open?
8.A badge code is exactly 2 characters long, and each character is one of the 5 shapes printed on the badge. How many different badge codes does that rule allow?
How strong a password is · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 2 of 12
Spotting a phishing message
Check a message against the five signs of a phishing attempt, working out for yourself whether the link in it belongs to whoever the message says it is from.
1.Each of these messages shows exactly one of the five signs. Match each message to the sign it shows.
- Opens “Dear User”, from the right site, no time limit, about a bill you really do owe
- Uses your name, about your own order, no time limit, asks for the code just sent to your phone
- Uses your name, about your own order, links to the shop's own site, says you have until noon
- Uses your name, no time limit, no link at all, thanks you for a payment you never made
- Uses your name, no time limit, about a delivery you are expecting, links to a site name that is not the courier's
- It does not use your name
- The link goes to somebody else's site
- It asks for a secret
- It is about something you never did
- It sets a deadline
2.You have ordered nothing at all. A message reads “Dear Customer, your order cannot be sent. Send us the code that has just arrived on your phone within two hours or the order is canceled.” It links to “https://orders.parcelpost.com.claim-it.net/fix”, and the courier's own site name is parcelpost.com. How many of the five signs does it show?
3.Here is a much shorter one, and you have entered no competition of any kind. It reads “Hello Friend, you have won a tablet. Reply to claim it.” There is no link in it and no time limit. How many of the five signs is that?
4.Sort each of these messages by whether it sets a deadline, which is the second of the five signs.
Groups: Sets a deadline · Sets no deadline
- Your account will be closed in 24 hours unless you act.
- Here is the reading list for next term.
- Pay by the end of the day or the charge doubles.
- Your parcel is out for delivery today.
- Your password was changed on Tuesday.
- Confirm within one hour or your prize is given away.
5.A school's own site name is “oakfield-school.com”. Sort each of these links by whose site it really belongs to.
Groups: The school's own site · Somebody else's site
- https://library.oakfield-school.com/books
- https://oakfield-school.net/term-dates
- https://oakfieldschool.com/term-dates
- https://parents.oakfield-school.com/forms
- https://oakfield-school.com/term-dates
- https://oakfield-school.com.sign-in.net/account
6.One of the five signs settles the matter on its own, however innocent the other four look. Which sign is it?
- a) It is about something you never did
- b) It sets a deadline
- c) It asks for a secret
- d) It does not use your name
7.A link inside a message reads “https://secure.orchard-clinic.com.verify-id.net/login”. Write the site name this link really belongs to.
8.Put these messages in order of how many of the five signs each one shows, fewest first.
- Uses your name, right site, no time limit, about your own order, asks nothing secret
- Opens “Dear Customer”, wrong site, one hour to act, about a prize you never entered for, asks nothing secret
- Opens “Dear Customer”, right site, no time limit, about your own order, asks nothing secret
- Opens “Dear Customer”, right site, one hour to act, about your own order, asks nothing secret
Spotting a phishing message · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 3 of 12
The trail you leave online
Work out how few harmless-looking facts it takes to narrow a crowd down to one person, and tell what a website is handed by you from what it is handed anyway.
1.A club has 600 members. Put these facts in order of how many members each one leaves, fewest first.
- Plays the cello, which one member in every twenty-five does
- Born in the same week as you, which one member in every hundred is
- Travels by bus, which one member in every five does
- Is in the same year group as you, which one member in every two is
2.You post a photograph, and three friends save a copy of it before you delete yours. Each of those three then sends it on to four other people, and every one of those people saves a copy too. Once you have deleted your own, how many copies of the photograph are there?
3.You visit a website and type nothing into it at all. Which of these does the website learn anyway?
- a) The time you arrived
- b) The name of your school
- c) Your date of birth
- d) The password to your email
4.Sort each of these by whether a website is told it even when you type nothing into the page.
Groups: Told even if you type nothing · Told only if you type it in
- Your date of birth
- The time you arrived
- Your full name
- The address your computer is using
- The name of your school
- Which browser you are using
5.A club has 720 members. Half of them are in the same year group as you. Of those, one in six has a birthday in the same month as you. Of those, one in twelve plays the flute. How many members share all three of those facts with you?
6.Three facts about you are handed to three different websites, one fact each, and not one of the three is ever told your name. Each fact on its own would fit thousands of people. What has to happen before those three facts can pick out one single person?
- a) All three facts have to be about the same day
- b) Nothing at all: three facts can never name one person
- c) One of the three websites has to be told your name
- d) Somebody has to put the three facts side by side
7.A swimming pool has 1800 members. One in five of them swims before school, and one in three of those is in the same year group as you. How many members fit both of those facts?
8.One fact leaves 900 people who could be the person meant. A second fact cuts that down by a factor of 30, and a third cuts what is left by a factor of 6. How many people are still left?
The trail you leave online · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 4 of 12
Working out a file size
Work out how many bytes a picture, a piece of text or a recording takes up, from how many things are in it and how many bytes one of those things needs.
1.A recording stores 16000 samples every second, each sample taking 2 bytes, and it lasts 3 seconds. How many bytes does the recording take?
2.One picture is 100 pixels by 80 pixels with 1 byte per pixel. Another is 50 pixels by 40 pixels with 3 bytes per pixel. Which is larger, and by how much?
- a) The first, by 4000 bytes
- b) The first, by 2000 bytes
- c) The two are exactly the same size
- d) The second, by 2000 bytes
3.A picture is 40 pixels wide and 30 pixels tall, and 1 byte is stored for every pixel. How many bytes does the picture take?
4.Match each file to the number of bytes it takes.
- 24 pixels by 25 pixels, 1 byte per pixel
- 1500 characters, 1 byte each
- 30 pixels by 30 pixels, 2 bytes per pixel
- 400 samples a second for 6 seconds, 1 byte each
- 20 pixels by 15 pixels, 3 bytes per pixel
- 1500
- 900
- 600
- 1800
- 2400
5.A picture is 64 pixels wide and 32 pixels tall, with 1 byte per pixel, and one kilobyte is 1024 bytes. How many kilobytes is the picture?
6.Put these files in order of size, smallest first.
- 500 samples a second for 5 seconds, 1 byte each
- 20 pixels by 20 pixels, 3 bytes per pixel
- 45 pixels by 40 pixels, 1 byte per pixel
- 800 characters, 1 byte each
7.A color picture is 200 pixels wide and 150 pixels tall, and 3 bytes are stored for every pixel. How many bytes does it take?
8.A picture takes 7200 bytes altogether and stores 2 bytes for every pixel. How many pixels does the picture have?
Working out a file size · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 5 of 12
Making a file smaller
Squeeze a run of repeated values into a count and a value, work out what that saves, and recognize the rows where it costs more than it saves.
1.A picture is 20 pixels wide and 15 pixels tall. Every row of it is a single color the whole way across, and a run is never allowed to carry on from one row into the next. How many runs does the whole picture have?
2.A counted row reads “4W2B5W”. How many pixels long is the row it stands for?
3.Another row reads “WWWWWBBRRRR”. Write this one in counted form.
4.A row of 90 pixels has 12 runs. Written out pixel by pixel it costs one thing per pixel; written as runs it costs two things per run. How many things does writing it as runs save?
5.A row of pixels reads “RRRRRRRGGG”. Write it in counted form, using a number and then the letter for each run.
6.Two photographs have exactly the same number of pixels. One is of a clear sky and the other is of a crowd of people. Counting runs makes one of them much smaller than the other. Which one, and why?
- a) The sky, because it has fewer pixels in it
- b) Neither: counting runs saves the same amount on any picture
- c) The sky, because long stretches of it are the same color
- d) The crowd, because there are more colors in it altogether
7.A row of 96 pixels has 8 runs, and writing it as runs costs two things per run. How many times smaller than the pixel-by-pixel form is the counted form?
8.Put these rows of pixels in order of how many runs each one has, fewest first.
- RGBRGBR
- RRWWBBGG
- GGGGGGGG
- RRRRWWWW
Making a file smaller · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 6 of 12
Lists and their positions
Read a value out of a list by its position, count how many values a list holds, and work out which position the last value sits at.
1.A list can hold a single value and still be a list. What does this program print?
only = [17] print(len(only) + only[0])
2.Put these lines in order of the value each one gives, smallest first.
items = [40, 10, 30, 20]
- items[3]
- items[0]
- items[1]
- items[2]
3.Two values are read out of this list and added together. What does it print?
nums = [5, 12, 7, 3] print(nums[1] + nums[3])
4.How many values does the list in this program hold?
counts = [5, 2, 9, 4, 7, 1] print(len(counts))
5.A list called xs holds 8 values. Which one of these reads the last of them?
- a) xs[len(xs)]
- b) xs[7]
- c) xs[9]
- d) xs[8]
6.This program reads the very first value out of a list. What does it print?
marks = [6, 1, 8, 3] print(marks[0])
7.A value is copied from one position into another before anything is printed. What does this program print?
row = [1, 2, 3, 4] row[0] = row[3] print(row[0] + row[3])
8.The list is the same for all of these. Match each line to the number it prints.
values = [7, 4, 9, 2, 8, 3]
- print(values[0])
- print(values[2])
- print(values[5])
- print(len(values))
- print(values[len(values) - 2])
- 6
- 3
- 9
- 7
- 8
Lists and their positions · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 7 of 12
Looping over a list
Follow a loop that takes each value of a list in turn, and work out the total, the count or the largest value it leaves behind.
1.The program below is run again with each of these lists written into its first line. Match each list to the number the loop counts.
values = [4, 5] count = 0 for n in values: if n > 10: count = count + 1- [11, 2, 14, 3]
- [1, 2, 3]
- [12, 13, 14, 15]
- [30]
- [11, 12, 13, 1, 2]
- 3
- 0
- 2
- 4
- 1
2.This one keeps hold of the smallest value instead, and so it starts from something large. What does it print?
times = [34, 28, 41, 30] best = 100 for t in times: if t < best: best = t print(best)3.This one multiplies rather than adds, so what it starts from matters. What does it print?
sizes = [2, 3, 4] product = 1 for s in sizes: product = product * s print(product)4.Every value in this list has ten added to it before printing. What is the last number the program prints?
nums = [6, 1, 8, 5] for n in nums: print(n + 10)5.How many numbers does this program print?
values = [11, 4, 9] for v in values: print(v * 2)6.One line of this program is inside the loop and one is outside it. How many numbers does it print altogether?
prices = [3, 6, 2] total = 0 for p in prices: total = total + p print(p) print(total)7.This loop keeps hold of the largest value it has met so far. What does it print?
temps = [17, 23, 19, 25, 21] best = 0 for t in temps: if t > best: best = t print(best)- a) 21
- b) 105
- c) 25
- d) 17
8.This loop does not add the values up. It counts how many of them pass a test. What does it print?
scores = [3, 8, 2, 9, 6] count = 0 for s in scores: if s > 5: count = count + 1 print(count)
Looping over a list · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 8 of 12
Building a list as you go
Start from an empty list and add to it inside a loop, and work out how many values end up in it and what sits at each position.
1.Look hard at the range before working anything else out. How many values does this list end up with?
empty = [] for n in range(5, 5): empty.append(n) print(len(empty))2.A running total is appended each time round here, so the list holds the totals rather than the values. What does the program print?
totals = [] running = 0 for n in range(1, 5): running = running + n totals.append(running) print(totals[3])3.The test in this one is about the counter doubled rather than the counter itself. How many values does the list end up with?
evens = [] for n in range(0, 12): if n * 2 < 10: evens.append(n) print(len(evens))4.This program starts with an empty list and puts one value into it each time round. How many values does it end up with?
squares = [] for n in range(1, 5): squares.append(n * n) print(len(squares))5.One loop sits inside another here, and the appending is in the deeper of the two. What does the program print?
pairs = [] for a in range(0, 3): for b in range(0, 4): pairs.append(a + b) print(len(pairs))- a) 4
- b) 3
- c) 7
- d) 12
6.Work out what this program prints. The values are not the counter itself this time.
doubles = [] for n in range(3, 7): doubles.append(n * 2) print(doubles[2])7.There are two appends inside this loop rather than one. How many values does the list end up with?
names = [] for n in range(1, 4): names.append(n) names.append(n * 10) print(len(names))8.Only some of the counter's values get into this list. What does the program print?
found = [] for n in range(1, 8): if n * n > 20: found.append(n) print(found[0])- a) 25
- b) 4
- c) 6
- d) 5
Building a list as you go · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 9 of 12
Text inside a program
Work out how many characters a piece of text holds, which character sits at a given position, and what joining two pieces of text end to end gives.
1.Two pieces of text are joined end to end here and the result is printed. What does the program print?
first = "sun" second = "rise" print(first + second)
2.A character is read out of the joined text rather than out of either of the two pieces. What does this program print?
left = "top" right = "most" joined = left + right print(joined[3])
3.The text is the same for all of these. Match each line to what it prints.
word = "network"
- print(word[0])
- print(word[3])
- print(word[6])
- print(len(word))
- print(word[len(word) - 2])
- k
- n
- 7
- w
- r
4.This program reads a single character out of a piece of text. What does it print?
word = "computer" print(word[0])
5.How many characters does the text in this program hold?
word = "keyboard" print(len(word))
6.Sort each of these words by how many characters it has.
Groups: Four characters · Six characters
- file
- folder
- loop
- binary
- byte
- switch
7.Two pieces of text are joined and the length of the result is printed. What does this program print?
a = "web" b = "page" print(len(a + b))
- a) 8
- b) 7
- c) 2
- d) 4
8.A loop can take a piece of text one character at a time, in the same way it takes a list one value at a time. What does this program print?
word = "data" count = 0 for c in word: count = count + 1 print(count)
Text inside a program · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 10 of 12
Repeating while something is true
Follow a loop that keeps going while a condition holds, working out what it leaves behind and how many times it went round.
1.In each of these a variable is changed as described and the loop keeps going while the variable is below 40. Put them in order of the value the variable is left holding, smallest first.
- Starts at 6 and has 15 added each time
- Starts at 2 and is multiplied by 3 each time
- Starts at 10 and has 9 added each time
- Starts at 1 and is doubled each time
2.This loop doubles a number until the condition stops holding. What does the program print?
n = 1 while n < 20: n = n * 2 print(n)3.In each of these a variable starts at 1 and is multiplied by the number shown every time round, and the loop keeps going while the variable is below 100. Match each multiplier to the value the variable is left holding.
- Multiplied by 2 each time
- Multiplied by 3 each time
- Multiplied by 5 each time
- Multiplied by 10 each time
- Multiplied by 4 each time
- 256
- 128
- 125
- 100
- 243
4.Look at the condition before you follow anything. What does this program print?
n = 5 while n > 10: n = n + 1 print(n)- a) 5
- b) 10
- c) 6
- d) 11
5.This one comes down rather than up. What does the program print?
n = 100 steps = 0 while n > 1: n = n - 30 steps = steps + 1 print(steps)6.This loop is left holding a value the condition would not have allowed it to start from. What does the program print?
n = 64 steps = 0 while n > 5: n = n - 12 steps = steps + 1 print(n)7.Both variables change every time round here, and only one of them is in the condition. What does the program print?
total = 0 n = 1 while total < 20: total = total + n n = n + 1 print(n)8.The subtraction here takes the variable past the condition and keeps going. What does the program print?
n = 27 while n > 0: n = n - 4 print(n)
Repeating while something is true · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 11 of 12
Searching a list
Follow a search that goes through a list from the front until it finds what it wants, and work out where it stops and how many values it had to look at.
1.A search that stops as soon as it finds what it wants is run on a list. Sort each of these by how many values the search looks at.
Groups: Looks at 3 values · Looks at 6 values
- The value is five steps along from the front
- The value is at position 2
- The value is the third one in the list
- The value is two steps along from the front
- The value is at position 5
- The value is the sixth one in the list
2.This one does not stop when it finds a match. It carries on and counts them. What does the program print?
values = [4, 9, 4, 2, 4, 7] count = 0 for v in values: if v == 4: count = count + 1 print(count)3.Why does a search have to look at every value in a list before it can say that the value it wants is not there?
- a) Because the value it has not looked at yet could be the one
- b) Because a search cannot count how many values it has looked at
- c) Because a list has no way of saying how long it is
- d) Because the search always begins at the last value
4.A search that stops as soon as it finds what it wants is run on a list of 30 values, and the value it is looking for is not in the list at all. How many values does it look at before it can say so?
- a) 15
- b) 29
- c) 30
- d) 1
5.Two searches are run, each stopping as soon as it finds what it wants. The first is on a list of 18 values and finds what it wants at position 4. The second is on a list of 40 values and what it wants is not there at all. How many values are looked at altogether?
6.Every value of one list is compared against every value of another here. What does the program print?
found = 0 for n in [3, 6, 9]: for m in [6, 12]: if n == m: found = found + 1 print(found)7.This search does not stop early. It goes through the whole list and remembers where the match was. What does it print?
values = [8, 3, 9, 5, 2] at = 0 for i in range(0, len(values)): if values[i] == 9: at = i print(at)8.The value being looked for appears twice in this list. What does the program print?
values = [5, 8, 5, 8] i = 0 while values[i] != 8: i = i + 1 print(i)
Searching a list · Grade 9 Computer Science · www.arenapublications.com/learn
Grade 9 Computer Science · 12 of 12
Putting a list in order
Take a list along once, swapping neighbors that are the wrong way round, and count the comparisons, the swaps and the passes that putting a whole list in order takes.
1.The list 6, 3, 9, 1 is taken along once in the same way. Put the values in the order they sit in once that pass is finished, the front of the list first.
- 1
- 6
- 9
- 3
2.The list 9, 1, 8, 7 is taken along once in the same way. What value is sitting at position 0 when the pass is finished?
3.This program does one pass along its list, using a spare variable to hold a value while the swap happens. What does it print?
values = [7, 4, 9, 2] for i in range(0, 3): if values[i] > values[i + 1]: left = values[i] values[i] = values[i + 1] values[i + 1] = left print(values[3])4.A list has 7 values in it. At most how many passes could putting it in order ever need?
- a) 5
- b) 6
- c) 7
- d) 21
5.A list of 6 values is put in order by making 5 passes along it, and every one of those passes makes 5 comparisons. How many comparisons is that altogether?
6.Each of these lists is taken along once, swapping neighbors that are the wrong way round. Match each list to the number of swaps that single pass makes.
- [2, 1, 4, 3]
- [1, 2, 3]
- [5, 4, 3, 2]
- [1, 2, 3, 4, 5, 9, 6]
- [8, 7, 6, 5, 4]
- 4
- 3
- 2
- 0
- 1
7.This program counts its own swaps as it makes them. What does it print?
values = [3, 1, 4, 2] swaps = 0 for i in range(0, 3): if values[i] > values[i + 1]: left = values[i] values[i] = values[i + 1] values[i + 1] = left swaps = swaps + 1 print(swaps)8.After one whole pass along a list, one value is certain to be in its final place. Which one?
- a) Nothing can be said for certain after only one pass
- b) The smallest value in the list
- c) The largest value in the list
- d) Whichever value started at position 0
Putting a list in order · Grade 9 Computer Science · www.arenapublications.com/learn
Answer keys — Grade 9 Computer Science
In the same order as the worksheets.
How strong a password is
- 1. 625
- 2. 1. 3 characters from 6 2. 2 characters from 25 3. 3 characters from 9 4. 5 characters from 4
- 3. c) The rule with 6 characters and 10 choices
- 4. 8
- 5. 2 characters, each one of 12 → Fewer than 1000; 3 characters, each one of 9 → Fewer than 1000; 2 characters, each one of 30 → Fewer than 1000; 3 characters, each one of 11 → More than 1000; 4 characters, each one of 7 → More than 1000; 2 characters, each one of 45 → More than 1000
- 6. 2 characters from 15 → 225; 3 characters from 5 → 125; 2 characters from 21 → 441; 4 characters from 4 → 256; 3 characters from 12 → 1728
- 7. 6
- 8. 25
Spotting a phishing message
- 1. Opens “Dear User”, from the right site, no time limit, about a bill you really do owe → It does not use your name; Uses your name, about your own order, no time limit, asks for the code just sent to your phone → It asks for a secret; Uses your name, about your own order, links to the shop's own site, says you have until noon → It sets a deadline; Uses your name, no time limit, no link at all, thanks you for a payment you never made → It is about something you never did; Uses your name, no time limit, about a delivery you are expecting, links to a site name that is not the courier's → The link goes to somebody else's site
- 2. 5
- 3. 2
- 4. Your account will be closed in 24 hours unless you act. → Sets a deadline; Your parcel is out for delivery today. → Sets no deadline; Confirm within one hour or your prize is given away. → Sets a deadline; Here is the reading list for next term. → Sets no deadline; Pay by the end of the day or the charge doubles. → Sets a deadline; Your password was changed on Tuesday. → Sets no deadline
- 5. https://oakfield-school.com/term-dates → The school's own site; https://oakfield-school.com.sign-in.net/account → Somebody else's site; https://parents.oakfield-school.com/forms → The school's own site; https://oakfield-school.net/term-dates → Somebody else's site; https://library.oakfield-school.com/books → The school's own site; https://oakfieldschool.com/term-dates → Somebody else's site
- 6. c) It asks for a secret
- 7. verify-id.net
- 8. 1. Uses your name, right site, no time limit, about your own order, asks nothing secret 2. Opens “Dear Customer”, right site, no time limit, about your own order, asks nothing secret 3. Opens “Dear Customer”, right site, one hour to act, about your own order, asks nothing secret 4. Opens “Dear Customer”, wrong site, one hour to act, about a prize you never entered for, asks nothing secret
The trail you leave online
- 1. 1. Born in the same week as you, which one member in every hundred is 2. Plays the cello, which one member in every twenty-five does 3. Travels by bus, which one member in every five does 4. Is in the same year group as you, which one member in every two is
- 2. 15
- 3. a) The time you arrived
- 4. The time you arrived → Told even if you type nothing; Which browser you are using → Told even if you type nothing; The address your computer is using → Told even if you type nothing; Your full name → Told only if you type it in; The name of your school → Told only if you type it in; Your date of birth → Told only if you type it in
- 5. 5
- 6. d) Somebody has to put the three facts side by side
- 7. 120
- 8. 5
Working out a file size
- 1. 96000
- 2. b) The first, by 2000 bytes
- 3. 1200
- 4. 24 pixels by 25 pixels, 1 byte per pixel → 600; 1500 characters, 1 byte each → 1500; 30 pixels by 30 pixels, 2 bytes per pixel → 1800; 400 samples a second for 6 seconds, 1 byte each → 2400; 20 pixels by 15 pixels, 3 bytes per pixel → 900
- 5. 2
- 6. 1. 800 characters, 1 byte each 2. 20 pixels by 20 pixels, 3 bytes per pixel 3. 45 pixels by 40 pixels, 1 byte per pixel 4. 500 samples a second for 5 seconds, 1 byte each
- 7. 90000
- 8. 3600
Making a file smaller
- 1. 15
- 2. 11
- 3.
- 5W2B4R
- 5W 2B 4R
- 4. 66
- 5.
- 7R3G
- 7R 3G
- 6. c) The sky, because long stretches of it are the same color
- 7. 6
- 8. 1. GGGGGGGG 2. RRRRWWWW 3. RRWWBBGG 4. RGBRGBR
Lists and their positions
- 1. 18
- 2. 1. items[1] 2. items[3] 3. items[2] 4. items[0]
- 3. 15
- 4. 6
- 5. b) xs[7]
- 6. 6
- 7. 8
- 8. print(values[0]) → 7; print(values[2]) → 9; print(values[5]) → 3; print(len(values)) → 6; print(values[len(values) - 2]) → 8
Looping over a list
- 1. [11, 2, 14, 3] → 2; [1, 2, 3] → 0; [12, 13, 14, 15] → 4; [30] → 1; [11, 12, 13, 1, 2] → 3
- 2. 28
- 3. 24
- 4. 15
- 5. 3
- 6. 4
- 7. c) 25
- 8. 3
Building a list as you go
- 1.
- 0
- none
- nought
- 2. 10
- 3. 5
- 4. 4
- 5. d) 12
- 6. 10
- 7. 6
- 8. d) 5
Text inside a program
- 1. sunrise
- 2. m
- 3. print(word[0]) → n; print(word[3]) → w; print(word[6]) → k; print(len(word)) → 7; print(word[len(word) - 2]) → r
- 4. c
- 5. 8
- 6. file → Four characters; folder → Six characters; byte → Four characters; binary → Six characters; loop → Four characters; switch → Six characters
- 7. b) 7
- 8. 4
Repeating while something is true
- 1. 1. Starts at 10 and has 9 added each time 2. Starts at 6 and has 15 added each time 3. Starts at 2 and is multiplied by 3 each time 4. Starts at 1 and is doubled each time
- 2. 32
- 3. Multiplied by 2 each time → 128; Multiplied by 3 each time → 243; Multiplied by 5 each time → 125; Multiplied by 10 each time → 100; Multiplied by 4 each time → 256
- 4. a) 5
- 5. 4
- 6. 4
- 7. 7
- 8. -1
Searching a list
- 1. The value is at position 2 → Looks at 3 values; The value is at position 5 → Looks at 6 values; The value is the third one in the list → Looks at 3 values; The value is the sixth one in the list → Looks at 6 values; The value is two steps along from the front → Looks at 3 values; The value is five steps along from the front → Looks at 6 values
- 2. 3
- 3. a) Because the value it has not looked at yet could be the one
- 4. c) 30
- 5. 45
- 6. 1
- 7. 2
- 8. 1
Putting a list in order
- 1. 1. 3 2. 6 3. 1 4. 9
- 2. 1
- 3. 9
- 4. b) 6
- 5. 25
- 6. [2, 1, 4, 3] → 2; [1, 2, 3] → 0; [5, 4, 3, 2] → 3; [1, 2, 3, 4, 5, 9, 6] → 1; [8, 7, 6, 5, 4] → 4
- 7. 2
- 8. c) The largest value in the list
Grade 9 Computer Science · www.arenapublications.com/learn