← Back to Class 9 Computer Science

Term pack

Class 9 Computer Science

Name: ________________________

Skills in this pack

  • ☐How strong a password is
  • ☐Spotting a phishing message
  • ☐The trail you leave online
  • ☐Staying safe with other people 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.

Class 9 Computer Science · 1 of 13

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. 1.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?

  2. 2.A rule allows passwords of 4 characters with 20 characters allowed in each position. It can be made stronger in one of two ways: one more character can be added to the length, or twenty more characters can be allowed in each position. Which change allows more passwords?

    • a) Neither change makes any difference to the count
    • b) Adding one more character to the length
    • c) The two changes allow exactly the same number
    • d) Allowing twenty more characters in each position
  3. 3.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?

  4. 4.A password on one website is 3 characters long, and each character may be any of 20 letters. How many passwords does the website's rule allow?

  5. 5.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?

  6. 6.A guessing machine gets through 200 passwords every second, and the rule it is working against allows 8400 different passwords. How many seconds does it need to try every one of them?

  7. 7.A rule allows passwords of exactly 2 characters taken from a set of 30. It is changed to allow 4 characters, taken from that same set of 30. How many times more passwords does the new rule allow than the old one?

  8. 8.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
    • 225
    • 441
    • 125
    • 1728
    • 256

How strong a password is · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 2 of 13

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. 1.Put these messages in order of how many of the five signs each one shows, fewest first.

    • 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
    • Uses your name, 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
  2. 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 cancelled.” 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. 3.A sports club's own site name is “riverside-club.com”. Which one of these links belongs to the club itself?

    • a) https://members.riverside-club.net/join
    • b) https://riverside-club.com.members-login.net/join
    • c) https://riversideclub.com/members
    • d) https://riverside-club.com/members
  4. 4.A link inside a message reads “https://secure.orchard-clinic.com.verify-id.net/login”. Write the site name this link really belongs to.

  5. 5.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?

  6. 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 asks for a secret
    • c) It does not use your name
    • d) It sets a deadline
  7. 7.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 password was changed on Tuesday.
    • Confirm within one hour or your prize is given away.
    • Your account will be closed in 24 hours unless you act.
    • Pay by the end of the day or the charge doubles.
    • Your parcel is out for delivery today.
    • Here is the reading list for next term.
  8. 8.The link “https://library-account.check-now.net/renew” has been cut into its four pieces below. Which piece says whose site the link really belongs to?

    • a) /renew
    • b) library-account.
    • c) https://
    • d) check-now.net

Spotting a phishing message · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 3 of 13

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. 1.In a group of 60 people, each year group is shared by 30 of them, each birth month by 5, each admission number by 1, each favourite sport by 12, each pairing of shoe size with birth month by 2, and each email address by 1. Sort each fact by how many people are left once you know it about somebody.

    Groups: Leaves exactly one person · Leaves more than one person

    • Their admission number
    • Their shoe size and birth month together
    • Their birth month
    • Their year group
    • Their favourite sport
    • Their email address
  2. 2.A club has 40 members. Knowing somebody's year group leaves 8 of them. Knowing their birth month as well leaves a quarter of those 8. Mark how many members are left.

    Mark the line with an X.

    012345678910
  3. 3.You visit a website and type nothing into it at all. Which of these does the website learn anyway?

    • a) The name of your school
    • b) The password to your email
    • c) Your date of birth
    • d) The time you arrived
  4. 4.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?

  5. 5.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?

  6. 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) Nothing at all: three facts can never name one person
    • b) Somebody has to put the three facts side by side
    • c) One of the three websites has to be told your name
    • d) All three facts have to be about the same day
  7. 7.In a group of 200 people, each year group is shared by 50 people; inside any one year group each birth month is shared by 5; and inside any one birth month each first initial is shared by 1. Match each set of facts to how many people could still be the person described.

    • Nothing at all is known
    • The year group
    • The birth month, without the year group
    • The year group and the birth month
    • The year group, the birth month and the first initial
    • 20
    • 1
    • 5
    • 50
    • 200
  8. 8.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?

The trail you leave online · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 4 of 13

Staying safe with other people online

Work out how far something you post really travels once other people pass it on, and follow a fixed set of steps when a message is meant to hurt.

  1. 1.A message was sent to some number of people to begin with, and every one of them sent it on to 6 more. Altogether 91 people besides the sender have seen it. How many people was it sent to at the start?

  2. 2.A message arrives that was written to hurt you. Sort each of these by whether the four steps allow it.

    Groups: The four steps allow this · The four steps do not allow this

    • Tell a teacher you trust
    • Block the sender once a copy has been kept
    • Reply to say that it was unfair
    • Pass the message on to your friends to see what they think
    • Delete the message straight away so you do not have to see it
    • Take a picture of the message before doing anything else
  3. 3.In the four steps, keeping a copy comes before blocking the sender. Why that way round?

    • a) Because blocking can take the message away with it
    • b) Because blocking somebody tells them that you have kept a copy
    • c) Because blocking the sender also blocks the adult you are going to tell
    • d) Because the copy has to be made on the same day as the message arrived
  4. 4.You post something to 60 people. One in every 4 of them passes it on to 8 people each. How many people besides you have seen it?

  5. 5.There are two things another person online can do that a computer on its own cannot. One is passing your words on to people you never chose. What is the other?

    • a) Storing a copy of a message for years
    • b) Sending the same message to many people at once
    • c) Reading a message faster than it was typed
    • d) Being somebody other than who they say they are
  6. 6.In each of these, you send something to a group and every person in that group sends it on to some number of others. Match each one to how many people besides you have seen it.

    • Sent to 6, each sending it to 5
    • Sent to 10, each sending it to 3
    • Sent to 7, each sending it to 3
    • Sent to 5, each sending it to 11
    • Sent to 15, each sending it to 4
    • 40
    • 28
    • 60
    • 75
    • 36
  7. 7.A message goes to 9 people. Every one of the 9 sends it to 4 more, and every one of those sends it to 3 more. How many people besides you have seen the message by then?

  8. 8.In each of these you send a post to a group and every person in that group passes it on. Put them in order of how many people besides you end up seeing the post, fewest first.

    • To 8 people, each passing it to 4
    • To 5 people, each passing it to 3
    • To 30 people, none of them passing it on
    • To 3 people, each passing it to 20

Staying safe with other people online · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 5 of 13

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. 1.A recording stores 8000 samples every second, and each sample takes 2 bytes. How many bytes does 5 seconds of it take?

  2. 2.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?

  3. 3.Put these files in order of size, smallest first.

    • 20 pixels by 20 pixels, 3 bytes per pixel
    • 500 samples a second for 5 seconds, 1 byte each
    • 800 characters, 1 byte each
    • 45 pixels by 40 pixels, 1 byte per pixel
  4. 4.A picture's width and its height are both doubled, and the number of bytes per pixel is left exactly as it was. How many times larger does the picture become?

    • a) Six times larger
    • b) Eight times larger
    • c) Four times larger
    • d) Two times larger
  5. 5.A colour picture is 200 pixels wide and 150 pixels tall, and 3 bytes are stored for every pixel. How many bytes does it take?

  6. 6.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?

  7. 7.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
    • 1800
    • 600
    • 1500
    • 2400
    • 900
  8. 8.Sort each of these files by whether it takes more than 10000 bytes.

    Groups: More than 10000 bytes · Fewer than 10000 bytes

    • 3000 characters, 1 byte each
    • 2000 samples a second for 8 seconds, 1 byte each
    • 120 pixels by 90 pixels, 1 byte per pixel
    • 50 pixels by 40 pixels, 3 bytes per pixel
    • 70 pixels by 70 pixels, 3 bytes per pixel
    • 60 pixels by 80 pixels, 1 byte per pixel

Working out a file size · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 6 of 13

Making a file smaller

Squeeze a run of repeated values into a count and a value, work out what that saves, and recognise the rows where it costs more than it saves.

  1. 1.Writing a row out pixel by pixel costs one thing per pixel; writing it as runs costs two things per run. Sort each row by which of the two costs less.

    Groups: Runs cost fewer things · Runs cost more things

    • 24 pixels, 3 runs
    • 18 pixels, 11 runs
    • 60 pixels, 4 runs
    • 50 pixels, 9 runs
    • 16 pixels, 10 runs
    • 30 pixels, 20 runs
  2. 2.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?

  3. 3.Match each row of pixels to the number of runs it has.

    • BBBWWBB
    • RRRRRRRR
    • RGRGRG
    • WWWWBB
    • RRGGBBRRG
    • 3
    • 6
    • 1
    • 2
    • 5
  4. 4.A row of 20 pixels changes colour at every single pixel along it. Writing it as runs costs two things per run. What does counting the runs do to the size of this row?

    • a) It doubles it, from 20 things to 40
    • b) It brings it down to 2 things
    • c) It leaves it at exactly 20 things
    • d) It halves it, from 20 things to 10
  5. 5.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) The crowd, because there are more colours in it altogether
    • c) The sky, because long stretches of it are the same colour
    • d) Neither: counting runs saves the same amount on any picture
  6. 6.A row of 40 pixels has 5 runs in it. Writing the row as runs costs two things for every run — a count and a letter. How many things does that come to?

  7. 7.Another row reads “WWWWWBBRRRR”. Write this one in counted form.

  8. 8.A row of pixels reads “RRRRRRRGGG”. Write it in counted form, using a number and then the letter for each run.

Making a file smaller · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 7 of 13

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. 1.In the list below, which position does the value 4 sit at?

    ages = [3, 11, 4, 8]
    • a) 3
    • b) 1
    • c) 0
    • d) 2
  2. 2.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])
    • 9
    • 6
    • 7
    • 3
    • 8
  3. 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. 4.A list can hold a single value and still be a list. What does this program print?

    only = [17]
    print(len(only) + only[0])
  5. 5.This one reads a value from further along the same kind of list. What does it print?

    heights = [12, 15, 11, 19, 14]
    print(heights[3])
  6. 6.The list in this program holds five values. Sort each of these lines by whether it can be run at all.

    xs = [3, 8, 1, 6, 2]

    Groups: Reads a value out of the list · Falls off the end of the list

    • xs[0]
    • xs[2]
    • xs[5]
    • xs[4]
    • xs[len(xs)]
    • xs[len(xs) - 1]
  7. 7.This program prints the position the last value sits at, rather than the value itself. What does it print?

    days = [2, 8, 5, 6, 9]
    print(len(days) - 1)
  8. 8.A list called xs holds 8 values. Which one of these reads the last of them?

    • a) xs[len(xs)]
    • b) xs[8]
    • c) xs[7]
    • d) xs[9]

Lists and their positions · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 8 of 13

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. 1.Each of these loop headings has a single print inside it. Put them in order of how many numbers each one prints, fewest first.

    • for n in [4, 9]:
    • for n in [5, 5, 5, 5]:
    • for n in [1, 2, 3]:
    • for n in [2, 4, 6, 8, 10]:
  2. 2.The list this loop is given has nothing in it at all. What does the program print?

    readings = []
    total = 0
    for r in readings:
        total = total + r
    print(total)
    • a) 0
    • b) 1
    • c) Nothing at all
    • d) There is no way to tell
  3. 3.Two counters are kept at once here, and the last line compares them. What does the program print?

    marks = [7, 3, 9, 2, 6]
    passes = 0
    fails = 0
    for m in marks:
        if m > 5:
            passes = passes + 1
        else:
            fails = fails + 1
    print(passes - fails)
  4. 4.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)
  5. 5.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]
    • 4
    • 3
    • 2
    • 0
    • 1
  6. 6.The program below is run again with each of these lists written into its first line. Sort each list by the total the loop leaves behind.

    values = [6, 6]
    total = 0
    for n in values:
        total = total + n

    Groups: A total of more than 20 · A total of less than 20

    • [5, 5, 5]
    • [4, 3, 2]
    • [12, 11]
    • [7, 8, 9]
    • [1, 1, 1, 1]
    • [10, 9, 6]
  7. 7.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)
  8. 8.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)

Looping over a list · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 9 of 13

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. 1.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) 5
    • b) 6
    • c) 25
    • d) 4
  2. 2.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) 3
    • b) 4
    • c) 12
    • d) 7
  3. 3.This program appends four values. Put them in the order they end up sitting in the list, the front of the list first.

    made = []
    for n in range(2, 6):
        made.append(n * n)
    • 9
    • 25
    • 16
    • 4
  4. 4.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))
  5. 5.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))
  6. 6.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])
  7. 7.This one prints the value that ended up at the front of the list. What does it print?

    squares = []
    for n in range(1, 6):
        squares.append(n * n)
    print(squares[0])
  8. 8.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))

Building a list as you go · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 10 of 13

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. 1.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) 4
    • b) 8
    • c) 2
    • d) 7
  2. 2.This one works out the last position for itself before reading a character from it. What does it print?

    word = "screen"
    print(word[len(word) - 1])
  3. 3.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)
  4. 4.Sort each of these words by how many characters it has.

    Groups: Four characters · Six characters

    • loop
    • file
    • switch
    • byte
    • folder
    • binary
  5. 5.The text is the same for all of these. Put them in order of the number each one gives, smallest first.

    word = "printer"
    • len(word) - 5
    • len(word) - 3
    • len(word)
    • len(word) + 4
  6. 6.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)
  7. 7.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])
    • 7
    • k
    • w
    • r
    • n
  8. 8.How many characters does the text in this program hold?

    word = "keyboard"
    print(len(word))

Text inside a program · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 11 of 13

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. 1.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) 11
    • c) 10
    • d) 6
  2. 2.Money is put by each week until there is enough. What does this program print?

    money = 50
    weeks = 0
    while money < 200:
        money = money + 25
        weeks = weeks + 1
    print(weeks)
  3. 3.A second variable here does nothing but count the trips. What does the program print?

    count = 0
    total = 0
    while total < 30:
        total = total + 7
        count = count + 1
    print(count)
  4. 4.In each of these a variable starts at 0 and the body adds 1 to it every time round. Sort each condition by how many times the body runs.

    Groups: The body runs 4 times · The body runs 7 times

    • while n < 3 + 4:
    • while n < 7:
    • while n <= 3:
    • while n <= 6:
    • while n < 4:
    • while n < 2 + 2:
  5. 5.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)
  6. 6.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 1 and is doubled each time
    • Starts at 2 and is multiplied by 3 each time
    • Starts at 6 and has 15 added each time
    • Starts at 10 and has 9 added each time
  7. 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. 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 · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 12 of 13

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. 1.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)
  2. 2.A search that stops as soon as it finds what it wants is run on a list of 9 values, and it finds what it wants at position 6. Mark how many values it looked at.

    Mark the line with an X.

    012345678910
  3. 3.A search that stops as soon as it finds what it wants is run on the list below. Match each value being looked for to the position the search stops at.

    values = [12, 7, 19, 4, 15, 3]
    • Looking for 12
    • Looking for 7
    • Looking for 4
    • Looking for 15
    • Looking for 3
    • 4
    • 5
    • 1
    • 0
    • 3
  4. 4.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)
  5. 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. 6.This search moves along the list until it meets the value it is looking for. What does the program print?

    values = [7, 4, 6, 1, 9]
    i = 0
    while values[i] != 6:
        i = i + 1
    print(i)
  7. 7.The same kind of search, but the last line adds one to the position before printing it. What does this program print?

    values = [5, 8, 2, 9, 3, 1]
    i = 0
    while values[i] != 9:
        i = i + 1
    print(i + 1)
  8. 8.A search that stops as soon as it finds what it wants is run four times. Put the four runs in order of how many values each one looks at, fewest first.

    • Found at position 3
    • Found at position 0
    • Found at position 7
    • Not in the list of 10 at all

Searching a list · Class 9 Computer Science · www.arenapublications.com/learn

Class 9 Computer Science · 13 of 13

Putting a list in order

Take a list along once, swapping neighbours that are the wrong way round, and count the comparisons, the swaps and the passes that putting a whole list in order takes.

  1. 1.After one whole pass along a list, one value is certain to be in its final place. Which one?

    • a) Whichever value started at position 0
    • b) The smallest value in the list
    • c) The largest value in the list
    • d) Nothing can be said for certain after only one pass
  2. 2.A list has 9 values in it. How many comparisons does a single pass along it make?

  3. 3.A list has 7 values in it. At most how many passes could putting it in order ever need?

    • a) 21
    • b) 6
    • c) 5
    • d) 7
  4. 4.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)
  5. 5.A list has 5 values in it. Mark how many comparisons a single pass along it makes.

    Mark the line with an X.

    012345678910
  6. 6.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.

    • 3
    • 6
    • 1
    • 9
  7. 7.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?

  8. 8.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?

Putting a list in order · Class 9 Computer Science · www.arenapublications.com/learn

Answer keys — Class 9 Computer Science

In the same order as the worksheets.

How strong a password is

  1. 1. 8
  2. 2. b) Adding one more character to the length
  3. 3. 25
  4. 4. 8000
  5. 5. 625
  6. 6. 42
  7. 7. 900
  8. 8. 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

Spotting a phishing message

  1. 1. 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
  2. 2. 5
  3. 3. d) https://riverside-club.com/members
  4. 4. verify-id.net
  5. 5. 2
  6. 6. b) It asks for a secret
  7. 7. 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
  8. 8. d) check-now.net

The trail you leave online

  1. 1. Their year group → Leaves more than one person; Their birth month → Leaves more than one person; Their admission number → Leaves exactly one person; Their favourite sport → Leaves more than one person; Their shoe size and birth month together → Leaves more than one person; Their email address → Leaves exactly one person
  2. 2. 2
  3. 3. d) The time you arrived
  4. 4. 5
  5. 5. 15
  6. 6. b) Somebody has to put the three facts side by side
  7. 7. Nothing at all is known → 200; The year group → 50; The birth month, without the year group → 20; The year group and the birth month → 5; The year group, the birth month and the first initial → 1
  8. 8. 120

Staying safe with other people online

  1. 1. 13
  2. 2. Take a picture of the message before doing anything else → The four steps allow this; Reply to say that it was unfair → The four steps do not allow this; Block the sender once a copy has been kept → The four steps allow this; Pass the message on to your friends to see what they think → The four steps do not allow this; Tell a teacher you trust → The four steps allow this; Delete the message straight away so you do not have to see it → The four steps do not allow this
  3. 3. a) Because blocking can take the message away with it
  4. 4. 180
  5. 5. d) Being somebody other than who they say they are
  6. 6. Sent to 6, each sending it to 5 → 36; Sent to 10, each sending it to 3 → 40; Sent to 7, each sending it to 3 → 28; Sent to 5, each sending it to 11 → 60; Sent to 15, each sending it to 4 → 75
  7. 7. 153
  8. 8. 1. To 5 people, each passing it to 3 2. To 30 people, none of them passing it on 3. To 8 people, each passing it to 4 4. To 3 people, each passing it to 20

Working out a file size

  1. 1. 80000
  2. 2. 2
  3. 3. 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
  4. 4. c) Four times larger
  5. 5. 90000
  6. 6. 1200
  7. 7. 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
  8. 8. 60 pixels by 80 pixels, 1 byte per pixel → Fewer than 10000 bytes; 120 pixels by 90 pixels, 1 byte per pixel → More than 10000 bytes; 3000 characters, 1 byte each → Fewer than 10000 bytes; 50 pixels by 40 pixels, 3 bytes per pixel → Fewer than 10000 bytes; 2000 samples a second for 8 seconds, 1 byte each → More than 10000 bytes; 70 pixels by 70 pixels, 3 bytes per pixel → More than 10000 bytes

Making a file smaller

  1. 1. 60 pixels, 4 runs → Runs cost fewer things; 30 pixels, 20 runs → Runs cost more things; 50 pixels, 9 runs → Runs cost fewer things; 16 pixels, 10 runs → Runs cost more things; 24 pixels, 3 runs → Runs cost fewer things; 18 pixels, 11 runs → Runs cost more things
  2. 2. 6
  3. 3. BBBWWBB → 3; RRRRRRRR → 1; RGRGRG → 6; WWWWBB → 2; RRGGBBRRG → 5
  4. 4. a) It doubles it, from 20 things to 40
  5. 5. c) The sky, because long stretches of it are the same colour
  6. 6. 10
  7. 7.
    • 5W2B4R
    • 5W 2B 4R
  8. 8.
    • 7R3G
    • 7R 3G

Lists and their positions

  1. 1. d) 2
  2. 2. print(values[0]) → 7; print(values[2]) → 9; print(values[5]) → 3; print(len(values)) → 6; print(values[len(values) - 2]) → 8
  3. 3. 15
  4. 4. 18
  5. 5. 19
  6. 6. xs[0] → Reads a value out of the list; xs[4] → Reads a value out of the list; xs[5] → Falls off the end of the list; xs[len(xs) - 1] → Reads a value out of the list; xs[len(xs)] → Falls off the end of the list; xs[2] → Reads a value out of the list
  7. 7. 4
  8. 8. c) xs[7]

Looping over a list

  1. 1. 1. for n in [4, 9]: 2. for n in [1, 2, 3]: 3. for n in [5, 5, 5, 5]: 4. for n in [2, 4, 6, 8, 10]:
  2. 2. a) 0
  3. 3. 1
  4. 4. 4
  5. 5. [11, 2, 14, 3] → 2; [1, 2, 3] → 0; [12, 13, 14, 15] → 4; [30] → 1; [11, 12, 13, 1, 2] → 3
  6. 6. [4, 3, 2] → A total of less than 20; [10, 9, 6] → A total of more than 20; [1, 1, 1, 1] → A total of less than 20; [7, 8, 9] → A total of more than 20; [5, 5, 5] → A total of less than 20; [12, 11] → A total of more than 20
  7. 7. 3
  8. 8. 24

Building a list as you go

  1. 1. a) 5
  2. 2. c) 12
  3. 3. 1. 4 2. 9 3. 16 4. 25
  4. 4.
    • 0
    • none
    • nought
  5. 5. 4
  6. 6. 10
  7. 7. 1
  8. 8. 6

Text inside a program

  1. 1. d) 7
  2. 2. n
  3. 3. 4
  4. 4. file → Four characters; folder → Six characters; byte → Four characters; binary → Six characters; loop → Four characters; switch → Six characters
  5. 5. 1. len(word) - 5 2. len(word) - 3 3. len(word) 4. len(word) + 4
  6. 6. sunrise
  7. 7. print(word[0]) → n; print(word[3]) → w; print(word[6]) → k; print(len(word)) → 7; print(word[len(word) - 2]) → r
  8. 8. 8

Repeating while something is true

  1. 1. a) 5
  2. 2. 6
  3. 3. 5
  4. 4. while n < 4: → The body runs 4 times; while n < 7: → The body runs 7 times; while n <= 3: → The body runs 4 times; while n <= 6: → The body runs 7 times; while n < 2 + 2: → The body runs 4 times; while n < 3 + 4: → The body runs 7 times
  5. 5. 32
  6. 6. 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
  7. 7. 7
  8. 8. -1

Searching a list

  1. 1. 3
  2. 2. 7
  3. 3. Looking for 12 → 0; Looking for 7 → 1; Looking for 4 → 3; Looking for 15 → 4; Looking for 3 → 5
  4. 4. 1
  5. 5. 45
  6. 6. 2
  7. 7. 4
  8. 8. 1. Found at position 0 2. Found at position 3 3. Found at position 7 4. Not in the list of 10 at all

Putting a list in order

  1. 1. c) The largest value in the list
  2. 2. 8
  3. 3. b) 6
  4. 4. 2
  5. 5. 4
  6. 6. 1. 3 2. 6 3. 1 4. 9
  7. 7. 1
  8. 8. 25

Class 9 Computer Science · www.arenapublications.com/learn