Professional Documents
Culture Documents
Week 1
Lesson 1 Solutions
Activity 1.1.1
What is a computer network?
Activity 1.1.3
Write a list of the activities computer networks make possible:
For example:
Sharing data
etc.
Lesson 2 Solutions
Activity 1.2.1
Lists and for loops revisited.
The command stores the country names in a data structure called a list. A list
stores things at index locations within the list.
The command in the ‘for’ loop is repeated for each item in the list. Each time
through the loop, the variable ‘name’ is assigned the next value in the list.
The program prints out the name of each item in the list a line at a time.
The program uses list comprehension, which is a short way of creating a list
where all the elements contain the same value. This program creates a list
with ten elements all filled with the number 43.
Activity 1.2.3
The program creates and displays a two-dimensional array with each element
set to zero (0). The array consists of four ‘rows’, each made up of six
‘columns’:
[[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]
A different size of array has been created with nine rows with five columns in
each row. All the elements of the array are set to zero.
[[0, 0, 0, 0, 99], [0, 0, 0, 0, 0], [0, 0, 0, 74, 0], [0, 0, 0, 0, 0], [0, 0, 0,
0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
0 0 0 0 99
0 0 0 0 0
0 0 0 74 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
A ‘for’ loop is used to iterate over the number of rows and each row listed in
the array is printed out.
Activity 1.2.4
How to use two-dimensional arrays in Python (nested lists which start from zero)
Task Example
Activity 1.2.5
Activity 1.2.6
‘One’ player Battleships game program:
Simple implementation
import random
#check co-ordinates
if board[x][y] == 1:
print("Direct hit!")
score += 1 #increase score by 1
board[x][y] = 0 #stop player hitting same place again!
else:
print("Missed!")
# display score
print("You scored ",score, "hits!")
Week 2
Lesson 1 Solutions
Activity 2.1.1
An explanation of the client-server model.
A client makes a request from the server. The server then fulfils the request.
A peer-to-peer system doesn’t have any servers (as in computers that just
provide services).
Lesson 2 Solutions
Activity 2.2.1
presence Checks that data has been entered. An email address must
be entered.
range Checks that the value entered falls Marks for an exam
within a given range. should be between 0 and
100.
Activity 2.2.2
Validation: length check
length=False
while length == False:
ans=input("Please enter password:" )
if len(ans) >= 8:
length=True
else:
print("Your password must be at least 8 characters long.")
print("Thank you for entering your password")
Activity 2.2.3
Validation: presence check
present=False
while present == False:
ans=input("Please enter your name; " )
if len(ans) > 0:
present=True
else:
print("I’m waiting!")
print("Thank you for entering your name")
Activity 2.2.4
Validation: type check
try:
ans=int(input("Please enter your age: "))
except:
print("Age must be a whole number please try again")
else:
print("Thank you for entering your age")
Activity 2.2.5
Validation: look-up check
containvalue=False
while containvalue == False:
ans=input("Please enter email address: " )
for i in range(len(ans)):
if ans[i]=="@":
containvalue=True
print("Thank you for entering an email address which includes an @
symbol")
Activity 2.2.6
Validation: range check
inRange=False
while inRange == False:
ans=int(input("Please enter the % charge of your phone: "))
if ans >= 0 and ans <= 100:
inRange=True
print("Thank you for entering your phone charge level")
Activity 2.2.7
Try command: divide by zero error check
Week 3
Lesson 1 Solutions
Activity 3.1.1
Acronym Meaning
Activity 3.1.2
Calculate the times to download the following files on a 10 Mbps network
connection.
Lesson 2 Solutions
Activity 3.2.1
Activity 3.2.3
Example:
Activity 3.2.4
Example:
def square(side):
area = side * side
print("The square has an area of",area,"cm squared")
Activity 3.2.5
Example:
Activity 3.2.6
Appropriate comments added to the program.
# outputs a number:
def display(number, answer, type):
print("This number {0} has been {2} the answer is
{1}".format(number, answer, type))
# squares a number
def square(number):
answer = number * number
return(answer)
# main program
amount = int (input("Please enter number : "))
for next in range(1,amount):
ans = square(next)
display(next, ans, "squared")
Amended program:
# outputs a number
def display(number, answer, type, answer2, type2):
print("This number {0} {2} is {1} and {4} is
{3}".format(number,answer,type,answer2,type2))
# squares a number
def square(number):
answer = number * number
return(answer)
def cube(number):
answer = number * number * number
return(answer)
# main program
amount = int (input("Please enter number : "))
for next in range(1, amount):
ans = square(next)
ansCube = cube(next)
display(next,ans,"squared",ansCube,"cubed")
Activity 3.2.7
Advantages of subprograms:
code is easier to test thoroughly
code can be reused
code is easier to read
code is easier to maintain
program is easier to understand, reducing the chance or errors.
Week 4
Lesson 1 Solutions
Activity 4.1.1
Bus Ring
Advantages Advantages
Star Mesh
Example of a full connected mesh network
Advantages Advantages
Lesson 2 Solutions
Activity 4.2.1
Local and global variables
Activity 4.2.2
This is what happens:
>>>print(number1)
Traceback (most recent call last):
File "<pyshell#35>", line 1, in <module>
print(number1)
NameError: name 'number1' is not defined
>>>print(number2)
Traceback (most recent call last):
File "<pyshell#36>", line 1, in <module>
print(number2)
NameError: name 'number2' is not defined
>>>print(answer)
21.666666666666668
This shows that only the variable answer is known outside of the function. It is
the only global variable. The other two variables (number1 and number2) are
local within the function and their values are only known within the function.
Week 5
Lesson 1 Solutions
Activity 5.1
Protocol definition:
Characteristic Details
Error checking Each protocol could use a different type of error checking,
for example parity. Error checking allows errors to be
detected so that the corrupted data is rejected.
Routing information How will data get to its destination on the network.
Week 6
Lesson 1 Solutions
Activity 6.1.1
FTP File Transfer Protocol. This protocol is used to transfer files over
a network.
POP3 Post Office Protocol, Version 3. Used for retrieving email from
an email server.
IMAP Internet Message Access Protocol. Used for email retrieval and
storage. Allows multiple email clients to access an email account
and keep changes synchronised.
Lesson 2 Solutions
Activity 6.2.1
The negative impact of computers on the environment.
Activity 6.2.2
Ways in which computers are helping to safeguard the environment
Week 7
Lesson 1 Solutions
Activity 7.1.1
What is a protocol and why are protocols needed?
Activity 7.1.3
What is a protocol suite?
Activity 7.1.4
TCP/IP
Activity 7.1.5
What is a network packet?
Data sent across a network can be broken up into packets. A packet will
contain a small amount of data and a packet header. The header will contain
details such as the sending address, recipient’s address, packet number etc.
Actual contents depend on the protocol and version of the protocol.
Week 8
Lesson 1 Solutions
Activity 8.1.1
AND GATE
P Q R
0 0 0
0 1 0
1 0 0
1 1 1
An AND gate will only output true if both of its inputs are true.
Activity 8.1.2
OR GATE
P Q R
0 0 0
0 1 1
1 0 1
1 1 1
An OR gate will output true if either or both of its inputs are true.
Lesson 2 Solutions
Activity 8.2.1
Types of errors
Activity 8.2.2
Trace tables
1 1 1 0.5
3 3 9 1.5
5 5 25 2.5
7 7 49 3.5
9 9 81 4.5
Week 9
Lesson 1 Solutions
Activity 9.1.1
NOT GATE
Input Output
0 1
1 0
A NOT gate reverses its input, from false to true and true to false.
Activity 9.1.2
Truth table to reverse the state of the blue light
R NOT(R)
0 1
1 0
R B NOT R S
0 0 1 0
0 1 1 1
1 0 0 0
1 1 0 0
The speaker sounds is the red light is off and the blue light is on.
Week 10
Lesson 1 Solutions
Activity 10.1.1
Truth Table A
OR gate
Truth Table B
AND gate
Truth Table C
NOT gate
Activity 10.1.2
S AND D AND W
Activity 10.1.3
(P AND L) OR (P AND O)
P AND (L OR O)
Lesson 2 Solutions
Activity 10.2.1
Stephen Waddington’s blog post: ‘My mobile phone knows more about me than
my family’.
How might advertisers make Companies may want to lure mobile phone users
use of location information? with details of shops, restaurants and special
offers.
What are the drawbacks? Location might be intercepted – people you don’t
want knowing your location might know exactly
where you are at all times, for example parents,
stalker, employer and so on.
Your future locations might be predictable from
past locations.
You may get adverts that are related to where you
are.
Activity 10.2.2
James Ball’s article: ‘Me and my data: how much do the internet giants really
know?’
What personal information His logins in the past month, including countries,
does Google hold about James? browsers, platforms and how much he has used the
services.
That he is a member of a few internal Google
groups, and has a blogger account used to
collaborate with some researchers on Twitter riot
data.
His work Gmail account has 877 contacts and a list
of the 398 Google docs he has opened. It also
knows the contents of all emails he has sent and
received.
His chat history, logging 500 conversations with
177 colleagues.
The link to his Youtube account – showing his
viewing history.
His search results – every search he has done
whilst logged into his personal google account.
What other information is there login IPs and other anonymised non-logged-in data
about James that he can’t find
out about?
Google uses cookies to A text file placed on your computer when you visit
determine which adverts to a website. A cookie is unique and can be used to
display. What is a cookie? identify you/your browsing habits.
Week 11
Lesson 1 Solutions
Activity 11.1.1
How could text be stored within a computer system?
1. Each letter would need to be stored twice – one code for lowercase,
another code for uppercase.
Activity 11.1.2
Sending data or opening files from one computer on another wouldn’t work –
some kind of converter would need to be implemented on each computer.
Also, there is the same issue for any data sent by network – web pages/email
wouldn’t display correctly.
Activity 11.1.3
1. American Standard Code for Information Interchange
2. A commonly used format for text stored within computers where each
character/number/control code has a unique associated number
b 01100010 98
c 01100011 99
A 01000001 65
B 01000010 66
C 01000011 67
1 00110001 49
2 00110010 50
3 00110011 51
Lesson 2 Solutions
Activity 11.2.1
https://www.enisa.europa.eu/ac
tivities/Resilience-and-
CIIP/critical-
applications/smartphone-
security-1/top-ten-
risks/network-spoofing-attacks
https://en.wikipedia.org/wiki/IP
_address_spoofing
Mail bombing Sending of a massive This is difficult to prevent! See:
amount of email to a
person or organisation.
Possible to use as a DoS
attack. http://www.cert.org/historical/tech
_tips/email_bombing_spamming.cf
m - III.C
Macro viruses A virus written in a Macro Educate users about opening
language. Many applications unexpected file.
have a macro language to Ensure anti-virus software is
aid automation of repetitive installed and up to date.
tasks. (MS Office has Visual Ensure that the 3security level
Basic for Applications). It configured within applications is
can be used for many of the suitable.
same purposes as a
“normal” virus.