Head office, Rana Pratap Bagh, Delhi011 2721 1512+91 97116 99511

A free printable book

Computers and coding for classes 9 and 10

6 lessons, each with worked examples, a try-at-home activity and a practice sheet. The practice sheets are together after the lessons, and the answer keys are at the very back.

  • Computers and coding
  • Classes 9-10
  • 6 lessons
  • 61 practice questions
  • Free to print

Contents

Free learning for kids, Gurukul Technicals Institute. Printed from engineergurukul.com/resources/kids/books/computers-9-10/

Contents

What is in this book

  1. 1How the internet worksSee how the internet connects devices: clients, servers, routers, IP addresses, domain names and data packets.4 min
  2. 2Functions: reusing stepsA function is a named block of steps you define once and call many times, with parameters going in and a return value coming out.5 min
  3. 3Lists and arraysA list or array stores many values under one name; learn about index numbers starting at 0, and loop through a list to add or find things.5 min
  4. 4Sorting and searchingTrace bubble sort on paper, then compare linear search with binary search and see why a sorted list can be searched in far fewer steps.5 min
  5. 5How the web works: URL, HTTP, browser and serverRead the parts of a URL, see how a browser sends an HTTP request to a server and gets a response, and learn what HTTPS and status codes mean.5 min
  6. 6Passwords, encryption basics and two-factorMake strong passwords, see how a Caesar cipher scrambles a message and why a key matters, and learn how two-factor login adds a second lock.6 min

Every lesson here can also be read on its own page, with links to related lessons. All printable books.

Lesson 1 of 6

How the internet works

See how the internet connects devices: clients, servers, routers, IP addresses, domain names and data packets.

Let us begin

The big idea

When you open a web page, it appears in a moment. Behind that moment, many machines in different places pass messages to each other. Let us see how it works, step by step.

The internet is a huge network of networks. Millions of computers, phones and other machines are linked by cables, radio waves and satellites. A router connects the devices in your home to the wider network.

Your device is the client. It asks for something, such as a web page. A server is a powerful computer that stores web pages and sends them when asked. This is the client-server model.

Every device on the internet has an address called an IP address. People prefer names, so we use domain names such as the name of a school website. A system called DNS works like a phone book: it turns the name into the number address.

Data does not travel in one piece. It is cut into small parts called packets. Each packet has the sender, the receiver and its number. Packets may take different routes and are put back in order at the end.

The web (websites) is only one service that runs on the internet, just as shops run on roads. Email and video calls also use the internet. A padlock in the address bar means the connection is encrypted, so others cannot read your data on the way.

A request and a replyOn the left a box called Your device, in the middle a cloud called Internet, and on the right a box called Web server. Arrows pointing right carry a request, and arrows pointing left carry the reply. Your device Internet Web server Request: please send the page Reply: here is the page
Your device asks and the server answers.

Worked examples

See how it works

  1. Opening a web page

    Step 1: you type the website name. Step 2: DNS finds the IP address. Step 3: your device sends a request to that server. Step 4: the server sends back the page in packets. Step 5: your browser puts them together and shows the page.

  2. Counting packets

    A file of 1,000 KB is sent in packets of 250 KB each. Number of packets = 1,000 / 250 = 4. If one packet goes missing, the receiver can ask for just that one again.

  3. Internet or web?

    Sending an email uses the internet but is not a web page. A news website is on the web, and the web runs on the internet. So the internet is the roads and the web is one kind of shop on those roads.

Try it at home

Packet post game

You will need

  • a sheet of paper
  • pencil
  • a friend or family member

What to do

  1. Write a short message of about 12 words on the paper.

  2. Tear the paper into 4 pieces, with about 3 words on each. Number the pieces 1 to 4.

  3. Shuffle the pieces and give them to your friend without telling the order.

  4. Your friend puts the pieces in order using the numbers and reads the message.

  5. Now remove one piece. Can your friend tell which number is missing? That is why packets are numbered.

Ask a grown-up

This is a paper-only game. No device or internet is needed. An adult can help tear the paper evenly.

Fun fact

Most of the internet traffic between countries travels through cables under the sea, where data moves as flashes of light in glass fibres.

Lesson 2 of 6

Functions: reusing steps

A function is a named block of steps you define once and call many times, with parameters going in and a return value coming out.

Let us begin

The big idea

If you need the same five steps in three places, you could write them three times. Programmers do better: they write the steps once, give the block a name, and call it whenever they need it. That named block is a function.

A function has a name, a list of parameters (the values it needs), a body (the steps) and often a return value (the answer it gives back). In pseudocode: FUNCTION square(n): RETURN n * n. The name is square, the parameter is n, and the body returns n times n.

Defining a function does nothing by itself. The steps run only when the function is called, for example square(7). The value 7 is called the argument; inside the function, n becomes 7, the body runs, and 49 is returned to the place where it was called.

Functions can take more than one parameter, such as FUNCTION area(length, breadth): RETURN length * breadth. Each call can pass different arguments: area(3, 4) returns 12 and area(10, 2) returns 20. Variables made inside a function belong to that function only; this is called local scope.

Why bother? Three reasons. Reuse: write once, call many times. Fewer mistakes: fix a bug in one place and every call is fixed. Readability: a line like total = average(marks) says what it does without showing how.

Calling a function and getting a value backOn the left, a main program box lists a = 5 and b = square(a). An arrow labelled argument 5 goes to a function box on the right that contains FUNCTION square(n) and RETURN n * n. A second arrow labelled returns 25 goes back to the main program, where b = 25 is written. Main program a = 5 b = square(a) OUTPUT b b becomes 25 FUNCTION square(n) n is the parameter here n = 5 RETURN n * n 5 * 5 = 25 argument 5 returns 25 Define once, call many times The function has its own variable n; it is local to the function.
The argument travels into the function, the body runs, and the return value travels back to where the call was made.

Worked examples

See how it works

  1. Tracing a call

    FUNCTION double(x): RETURN x * 2. Main program: a = 5, b = double(a), c = double(b). Trace: a = 5. Call double(5): x is 5, returns 10, so b = 10. Call double(10): x is 10, returns 20, so c = 20.

  2. A function with two parameters

    FUNCTION perimeter(l, b): RETURN 2 * (l + b). Call perimeter(7, 3): l is 7, b is 3, 7 + 3 = 10, 2 * 10 = 20. The function returns 20.

  3. A function that calls another

    FUNCTION circleArea(r): RETURN 3.14 * square(r). Call circleArea(10): square(10) returns 100, then 3.14 * 100 = 314. Reusing square keeps circleArea short.

  4. Why reuse matters

    A shop program works out a bill with tax in six places. If the tax rate changes and the sum is copied six times, you must change six lines and might miss one. With one function withTax(price), you change one line.

Try it at home

Function cards

You will need

  • Index cards or paper cut into cards
  • A pencil
  • A bowl of small coins or beans for values

What to do

  1. On one card write FUNCTION addFive(n): RETURN n + 5. On another write FUNCTION triple(n): RETURN n * 3. These are your function definitions.

  2. A friend writes a main program on paper: a = 2, b = addFive(a), c = triple(b), OUTPUT c.

  3. Act it out. When the program calls addFive(2), hand the addFive card 2 beans; the card holder adds 5 beans and hands back 7. Write b = 7.

  4. Continue: triple(7) returns 21, so c = 21. Say the output aloud.

  5. Write a new function card of your own, such as half(n), and run a program that uses it twice.

Lesson 3 of 6

Lists and arrays

A list or array stores many values under one name; learn about index numbers starting at 0, and loop through a list to add or find things.

Let us begin

The big idea

A class has 40 students. Making 40 separate variables for their marks would be painful. Instead, a program keeps all the marks in one list, also called an array. Each value sits in a numbered slot so the program can reach any of them.

A list is a row of values stored under one name. We write it with square brackets: marks = [72, 85, 90, 64]. This list has four items. Its length is 4.

Each slot has an index number. In most programming languages the first slot is index 0, not 1. So marks[0] is 72, marks[1] is 85, marks[2] is 90 and marks[3] is 64. The last index is always one less than the length. Asking for marks[4] is an error because there is no such slot.

You can change one slot: marks[1] = 88 replaces 85 with 88. You can add to the end: append 70 makes the list [72, 88, 90, 64, 70] with length 5.

The real power comes from loops. To add all the marks: total = 0, then FOR i FROM 0 TO length - 1: total = total + marks[i]. To find the largest: biggest = marks[0], then for each item, IF item > biggest THEN biggest = item. The same short loop works for a list of 4 or 4,000.

An array of four marks with index numbersFour boxes in a row hold the values 72, 85, 90 and 64. Above each box its index 0, 1, 2 and 3 is written. The whole row is labelled marks, length 4. Below, a note shows marks[2] is 90 and that marks[4] does not exist.marks length = 4 index 0 index 1 index 2 index 3 72 85 90 64 marks[2] is 90 marks[4] does not exist: the last index is 3, one less than the length. One name, many values, each with an index
Index numbers start at 0. The last index is one less than the length.

Worked examples

See how it works

  1. Reading by index

    fruits = ["mango", "apple", "banana", "guava"]. fruits[0] is "mango", fruits[2] is "banana", and fruits[3] is "guava". The length is 4 and the highest valid index is 3.

  2. Adding up a list

    marks = [72, 85, 90, 64]. Trace total: start 0; i = 0, total = 72; i = 1, total = 157; i = 2, total = 247; i = 3, total = 311. The sum is 311, and the average is 311 divided by 4 = 77.75.

  3. Finding the largest

    nums = [14, 3, 27, 9]. biggest = 14. Compare 3: not bigger. Compare 27: bigger, so biggest = 27. Compare 9: not bigger. Final answer 27.

  4. Counting matches

    temps = [31, 35, 29, 36, 33]. Count the days above 32: count = 0; 31 no; 35 yes, count 1; 29 no; 36 yes, count 2; 33 yes, count 3. Three hot days.

Try it at home

An egg-tray array

You will need

  • An empty egg tray or a row of six cups
  • Small slips of paper or beans
  • A pencil and paper

What to do

  1. Write the index numbers 0, 1, 2, 3, 4, 5 on paper slips and place one in front of each cup. The first cup is 0.

  2. Put a different number of beans in each cup, for example 3, 7, 2, 5, 1, 4. This is your list: beans = [3, 7, 2, 5, 1, 4].

  3. Ask: what is beans[2]? Count the beans in the cup labelled 2 (answer 2). What is beans[5]? (answer 4).

  4. Now find the largest by looping: start with cup 0 as biggest and compare each next cup in turn, saying aloud whether you change your answer.

  5. Add up all the cups one at a time, writing the running total after each cup.

Lesson 4 of 6

Sorting and searching

Trace bubble sort on paper, then compare linear search with binary search and see why a sorted list can be searched in far fewer steps.

Let us begin

The big idea

Computers spend a lot of their time putting things in order and finding things. A phone contact list, a leaderboard and a dictionary all depend on sorting and searching. You can learn the classic methods with nothing but a pencil and a row of numbers.

Bubble sort puts a list in order by comparing neighbours. Go along the list; whenever the left item is bigger than the right item, swap them. After one full pass, the largest value has "bubbled" to the end. Repeat the passes until a whole pass makes no swaps; then the list is sorted.

Linear search finds a value by checking the items one by one from the start until it is found or the list ends. It works on any list, sorted or not, but in the worst case it looks at every item: 1,000 items could mean 1,000 checks.

Binary search works only on a sorted list, but it is much faster. Look at the middle item. If it is the one you want, stop. If the item you want is smaller, throw away the right half; if bigger, throw away the left half. Repeat on the remaining half. Each step halves the list, so 1,000 items need at most about 10 checks, and 1,000,000 need about 20.

This is why sorting matters: a dictionary is sorted so you can open it near the middle and jump, instead of reading from page one. The number of steps a method needs as the list grows is called its efficiency, and choosing an efficient method is a big part of computer science.

Bubble sort: the first pass on 5, 2, 4, 1Four rows show the list after each comparison in the first pass of bubble sort. Row one: 5, 2, 4, 1 with 5 and 2 highlighted and the note swap. Row two: 2, 5, 4, 1 with 5 and 4 highlighted, swap. Row three: 2, 4, 5, 1 with 5 and 1 highlighted, swap. Row four: 2, 4, 1, 5 with the note that 5 has reached the end.Pass 1 of bubble sort step 1 5 2 4 1 5 > 2, swap step 2 2 5 4 1 5 > 4, swap step 3 2 4 5 1 5 > 1, swap result 2 4 1 5 5 is at the end Next passes: [2, 1, 4, 5] then [1, 2, 4, 5]. A pass with no swaps means sorted.
One pass of bubble sort: each pair of neighbours is compared and swapped if out of order. The largest value reaches the end.

Worked examples

See how it works

  1. Bubble sort trace

    Sort [5, 2, 4, 1]. Pass 1: compare 5,2 swap to [2, 5, 4, 1]; compare 5,4 swap to [2, 4, 5, 1]; compare 5,1 swap to [2, 4, 1, 5]. Pass 2: 2,4 no swap; 4,1 swap to [2, 1, 4, 5]; 4,5 no swap. Pass 3: 2,1 swap to [1, 2, 4, 5]; then no more swaps. Pass 4 makes no swaps, so the list is sorted.

  2. Linear search

    Find 7 in [3, 9, 7, 1, 8]. Check 3: no. Check 9: no. Check 7: yes, found at index 2 after 3 checks. To find 8 would take 5 checks; to find 4, which is absent, also takes 5 checks before giving up.

  3. Binary search

    Find 23 in the sorted list [4, 8, 15, 16, 23, 42, 50]. Middle is index 3, value 16. 23 is bigger, so keep the right half [23, 42, 50]. Middle is 42. 23 is smaller, so keep [23]. Middle is 23: found in 3 checks. Linear search would have needed 5.

Try it at home

Sort and search with cards

You will need

  • Eight small pieces of paper
  • A pencil
  • A table or floor to lay the cards in a row

What to do

  1. Write a different number from 1 to 50 on each card and lay them face up in a random row.

  2. Bubble sort them: compare the first two cards and swap if the left is bigger; move one step right and repeat to the end. Count your swaps. Repeat passes until a pass has no swaps.

  3. Turn all cards face down. Ask a friend to name one of the numbers. Find it by linear search, turning cards from the left one at a time, and count the checks.

  4. Turn them face down again (still in sorted order). Find another number by binary search: turn over the middle card, decide which half to keep, and repeat. Count the checks.

  5. Compare the counts. Try with sixteen cards and see how little the binary search count grows.

Lesson 5 of 6

How the web works: URL, HTTP, browser and server

Read the parts of a URL, see how a browser sends an HTTP request to a server and gets a response, and learn what HTTPS and status codes mean.

Let us begin

The big idea

When you type an address and a page appears, a short conversation has happened between two computers: your browser (the client) and a server somewhere else. This lesson follows that conversation, from the URL you type to the page you see.

A URL (Uniform Resource Locator) is the address of a page. Take the address www.example.in/science/water-cycle.html with https written in front of it. The scheme, https, says which rules to use; it is followed by a colon and two slashes. The domain name, www.example.in, names the server. The path, /science/water-cycle.html, names the page on that server. Some URLs add a query after a question mark, such as ?q=rain, to pass extra information.

The browser first asks the DNS (Domain Name System) to turn the domain name into an IP address, because computers find each other by number, not by name. Then it sends an HTTP request to that server. HTTP (HyperText Transfer Protocol) is the agreed set of rules for asking for and sending web pages. The most common request is GET, which means "please send me this page".

The server finds or builds the page and sends back an HTTP response: a status code and the content. Code 200 means OK, here it is. Code 404 means not found. Code 500 means the server had an error. The content is usually HTML, the language that describes the page structure, along with images, styles and scripts the browser then fetches with more requests.

HTTPS is HTTP with encryption. The data between you and the server is scrambled so no one in between can read or change it. The padlock in the address bar shows the connection is encrypted. Always prefer https pages, especially when logging in.

Client and server exchanging an HTTP request and responseA laptop labelled browser (client) on the left and a server box on the right. An arrow from client to server carries GET /water-cycle.html. An arrow from server back to client carries 200 OK plus the HTML page. Above, a URL is split into scheme, domain and path with labels.https: www.example.in /science/water-cycle.html scheme domain (server) path (page on the server) browser Client your laptop or phone Server holds the pages GET /science/water-cycle.html 200 OK + the HTML page Before this, DNS turned www.example.in into an IP address.
The browser sends a request for a path; the server sends back a status code and the page.

Worked examples

See how it works

  1. Taking a URL apart

    Take the address www.ncert.nic.in/textbook.php?class=8, typed with the scheme https in front. It has scheme https, domain www.ncert.nic.in, path /textbook.php and query class=8. The query passes the value 8 for the name class to the server.

  2. One page load, step by step

    You type www.example.in/about. The browser asks DNS for the IP address of www.example.in and gets one, say 203.0.113.5. It sends GET /about to that address. The server replies 200 OK with the HTML. The browser reads the HTML, sees it needs a picture, sends another GET for the picture, and draws the page.

  3. Reading a status code

    You follow an old link and the page says 404 Not Found. The server was reached fine, but there is no page at that path; perhaps it was moved. If instead you see 500, the page exists but the server program failed while building it.

Try it at home

Play the browser and the server

You will need

  • Paper and a pencil
  • Three envelopes
  • Four or five sheets with short pretend pages written on them, each with a path like /home, /about, /menu

What to do

  1. One person is the server. They keep the pages in a box and write a list of their paths on the outside.

  2. The other person is the browser. Write a request on paper: GET /menu. Put it in an envelope and hand it over.

  3. The server looks for the page. If it exists, they write 200 OK on top and send it back in the envelope. If not, they send back a sheet saying 404 Not Found.

  4. Try a request for a page that is not in the box and see the 404 reply.

  5. Now write a URL on paper for one page, label its scheme, domain, path and query, and swap roles.

Lesson 6 of 6

Passwords, encryption basics and two-factor

Make strong passwords, see how a Caesar cipher scrambles a message and why a key matters, and learn how two-factor login adds a second lock.

Let us begin

The big idea

A password is a secret that proves you are you. Encryption is a way to scramble information so only someone with the key can read it. Together with a second check called two-factor authentication, they keep accounts and messages safe. You can practise all three on paper.

A strong password is long, hard to guess and used for only one account. Length matters most: each extra character multiplies the number of guesses an attacker must try. A short phrase of unrelated words with a number and a symbol, such as "mango!tractor7cloud", is both long and easy to remember. Never use your name, birthday, "123456" or "password", and never share a password, even with a friend.

Encryption turns readable text (plaintext) into scrambled text (ciphertext) using a rule and a key. The oldest example is the Caesar cipher: shift every letter forward by a fixed number. With key 3, A becomes D, B becomes E, and Z wraps round to C. To decrypt, shift back by the same key. Anyone can know the rule; the key is the secret.

A Caesar cipher is easy to break because there are only 25 useful keys, so an attacker can simply try them all. Modern encryption, such as the kind behind HTTPS, uses keys that are 128 bits or more long (a string of 128 or more zeros and ones), so trying every key would take longer than the age of the universe. The idea is the same: a public rule, a secret key.

Two-factor authentication (2FA) asks for two different kinds of proof: something you know (the password) and something you have (your phone, which receives a one-time code, or an authenticator app). If someone steals your password, they still cannot log in without your phone. Turn it on for important accounts, with an adult's help.

Caesar cipher with key 3Two rows of letters. The top row shows the plain alphabet A to M and the bottom row shows each letter shifted three places, D to P. An arrow labelled key equals 3 points from top to bottom. Below, HELLO is shown becoming KHOOR.plain cipher A B C D E F G H I J K L M D E F G H I J K L M N O P key = 3: shift forward 3 HELLO KHOOR plaintext becomes ciphertext; shift back 3 to decrypt The Caesar cipher
With key 3 every letter moves three places forward. The rule is public; the key is the secret.

Worked examples

See how it works

  1. Encrypting with Caesar, key 3

    Plaintext HELLO. H plus 3 is K, E plus 3 is H, L plus 3 is O, L plus 3 is O, O plus 3 is R. Ciphertext: KHOOR. To decrypt KHOOR, shift each letter back 3 and HELLO returns.

  2. Wrapping round the alphabet

    Encrypt XYZ with key 4. X plus 4: X, Y, Z, then wrap to A, B, so X becomes B. Y becomes C. Z becomes D. Ciphertext: BCD.

  3. Comparing passwords

    "rahul2010" is weak: it is a name plus a birth year, both easy to find out. "Tj7" is short, so a computer can try every three-character combination in seconds. "purple!river42kite" is 18 characters of unrelated words, so it is strong and still memorable.

  4. How 2FA stops a thief

    Someone learns Meera's email password from a leaked website. They type it in, but the site then asks for the six-digit code sent to Meera's phone. The thief does not have her phone, so the login fails, and Meera gets a warning to change her password.

Try it at home

Secret messages with a paper cipher wheel

You will need

  • Two strips of paper
  • A pencil
  • A ruler or a straight edge

What to do

  1. On both strips write the alphabet A to Z with equal spacing. On the second strip, write it twice in a row so it is twice as long.

  2. Place the short strip above the long one and slide it so that A on the short strip sits above D on the long strip. That is key 3.

  3. Encrypt a short message by reading each letter on the short strip and writing the letter below it on the long strip.

  4. Give the ciphertext and the key to a family member and have them decrypt it by reading upwards.

  5. Now give them only the ciphertext and see how long it takes them to try all the keys. Discuss why real encryption needs much bigger keys.

Part two

Practice sheets

One sheet for each of the 6 lessons. Write your name and the date at the top, answer in the spaces, then check with the answer keys at the back.

Practice sheet

How the internet works

Practice sheet: How the internet works (Classes 9-10, Computers and coding)

  1. What is the internet in simple words?
  2. In the client-server model, what is the client and what is the server?
  3. What is a router used for at home?
  4. What is an IP address?
  5. What does DNS do?
  6. Why is data sent as packets?
  7. A file of 600 KB is sent in packets of 150 KB. How many packets are needed?
  8. What is the difference between the internet and the web?
  9. What does the padlock sign in the address bar tell you?
  10. List in order the steps when you open a website.

Practice sheet

Functions: reusing steps

Practice sheet: Functions: reusing steps (Classes 9-10, Computers and coding)

  1. What are the four parts of a function named in the lesson?
  2. What is the difference between a parameter and an argument?
  3. FUNCTION cube(n): RETURN n * n * n. What does cube(3) return?
  4. FUNCTION area(l, b): RETURN l * b. What does area(9, 6) return?
  5. Does defining a function run its steps? When do they run?
  6. Trace: a = 4, b = double(a), c = double(b) + 1, where double(x) returns x * 2. What is c?
  7. What does local scope mean?
  8. Give two reasons for using functions.
  9. FUNCTION circleArea(r): RETURN 3.14 * square(r). What is circleArea(2)?
  10. Write pseudocode for a function that returns the average of three numbers.

Practice sheet

Lists and arrays

Practice sheet: Lists and arrays (Classes 9-10, Computers and coding)

  1. colours = ["red", "green", "blue"]. What is colours[0]?
  2. What is the length of the list above, and what is its highest valid index?
  3. nums = [5, 9, 2, 8]. What is nums[3]?
  4. After nums[1] = 10, what is the list?
  5. Add up [4, 11, 6, 9]. What is the total?
  6. What is the largest value in [17, 42, 8, 35]? Show the comparisons.
  7. Why is asking for marks[4] an error when the list has 4 items?
  8. How many items does a list with highest index 9 contain?
  9. In pseudocode, write a loop that counts how many items in a list are equal to 0.
  10. Why is a list better than 40 separate variables for 40 marks?

Practice sheet

Sorting and searching

Practice sheet: Sorting and searching (Classes 9-10, Computers and coding)

  1. In bubble sort, when do you swap two neighbours?
  2. After the first pass of bubble sort, where is the largest value?
  3. How do you know bubble sort has finished?
  4. Write the list after the first pass of bubble sort on [3, 8, 1, 6].
  5. How many checks does linear search need to find 8 in [3, 9, 7, 1, 8]?
  6. What must be true about a list before binary search can be used?
  7. Binary search for 15 in [4, 8, 15, 16, 23, 42, 50]: which values are checked?
  8. Roughly how many checks does binary search need for 1,000 sorted items?
  9. Why is a printed dictionary sorted?
  10. You have an unsorted list and need to find one item just once. Is it worth sorting first?

Practice sheet

How the web works: URL, HTTP, browser and server

Practice sheet: How the web works: URL, HTTP, browser and server (Classes 9-10, Computers and coding)

  1. What do the letters URL stand for?
  2. In the address www.example.in/science/water-cycle.html (scheme https), what is the domain name?
  3. What is the path in that URL?
  4. What does DNS do?
  5. What does HTTP stand for, and what is a GET request?
  6. What does status code 200 mean? And 404?
  7. What is the difference between HTTP and HTTPS?
  8. In the address shop.example.com/search?q=shoes, what is the query?
  9. Which computer is the client and which is the server when you read a page on your phone?
  10. Why does a page with pictures cause more than one request?

Practice sheet

Passwords, encryption basics and two-factor

Practice sheet: Passwords, encryption basics and two-factor (Classes 9-10, Computers and coding)

  1. Give two features of a strong password.
  2. Why is "priya2011" a weak password?
  3. Encrypt CAB with a Caesar cipher, key 3.
  4. Decrypt MDO (key 3).
  5. Encrypt ZOO with key 2.
  6. What is the difference between the rule and the key in a cipher?
  7. Why is a Caesar cipher easy to break?
  8. What are the two factors in two-factor authentication?
  9. A thief knows your password but not your phone. Can they log in to a 2FA account?
  10. What is the padlock in a browser address bar telling you?
  11. Should you use the same password for every account? Why or why not?

Part three

Answer keys

The answers to every practice sheet, in the same order as the lessons. Parents and teachers may like to keep these pages separately.

Answer key

Answers: How the internet works

  1. A huge network of networks that connects computers and other devices all over the world.
  2. The client is the device that asks, such as your phone. The server is the computer that stores things and sends them back.
  3. It connects the devices in your home to the internet (and to each other).
  4. A number that acts as the address of a device on the network.
  5. It turns a website name into the IP address, like a phone book.
  6. Small packets can take different routes, are easier to resend if lost, and share the network fairly with others.
  7. 600 / 150 = 4 packets.
  8. The internet is the network itself. The web is one service (websites) that runs on it. Email also uses the internet.
  9. The connection is encrypted, so others cannot easily read your data on the way.
  10. Type the name, DNS finds the IP address, a request goes to the server, the server sends packets back, and the browser puts them together to show the page.

Answer key

Answers: Functions: reusing steps

  1. Name, parameters, body and return value.
  2. A parameter is the name used inside the function definition (n); an argument is the actual value passed in a call (7).
  3. 27
  4. 54
  5. No; the steps run only when the function is called.
  6. 17: b = 8, double(8) = 16, plus 1 is 17.
  7. Variables made inside a function belong to that function only and cannot be seen outside it.
  8. Any two of: reuse the steps, fix a mistake in one place, make the program easier to read.
  9. 12.56, because square(2) = 4 and 3.14 * 4 = 12.56.
  10. FUNCTION average(a, b, c): RETURN (a + b + c) / 3.

Answer key

Answers: Lists and arrays

  1. "red"
  2. Length 3, highest valid index 2.
  3. 8
  4. [5, 10, 2, 8]
  5. 30
  6. 42: start 17; 42 is bigger, so biggest = 42; 8 is not; 35 is not.
  7. Indexes run from 0 to 3, so there is no slot numbered 4.
  8. 10 items (indexes 0 to 9).
  9. count = 0; FOR i FROM 0 TO length - 1: IF list[i] = 0 THEN count = count + 1.
  10. One short loop can handle every mark, however many there are, and the list can grow or shrink.

Answer key

Answers: Sorting and searching

  1. When the left one is bigger than the right one.
  2. At the end (the last position).
  3. When a whole pass makes no swaps.
  4. [3, 1, 6, 8]: 3,8 no swap; 8,1 swap; 8,6 swap.
  5. 5 checks, because 8 is the last item.
  6. It must be sorted.
  7. 16 (middle), then 8 (middle of the left half), then 15: found in 3 checks.
  8. About 10, because each check halves the list and 2 to the power 10 is 1,024.
  9. So you can jump near the right place and search it quickly, like binary search, instead of reading from the start.
  10. No; sorting takes many steps, so a single linear search is cheaper. Sorting pays off when you will search many times.

Answer key

Answers: How the web works: URL, HTTP, browser and server

  1. Uniform Resource Locator.
  2. www.example.in
  3. /science/water-cycle.html
  4. It turns a domain name into an IP address so the browser can find the server.
  5. HyperText Transfer Protocol; GET asks the server to send a page.
  6. 200 means OK, the page was sent; 404 means not found.
  7. HTTPS encrypts the data between the browser and the server, so others cannot read or change it; HTTP sends it unscrambled.
  8. q=shoes (the part after the question mark).
  9. Your phone (the browser) is the client; the computer holding the page is the server.
  10. The HTML arrives first; each picture, style or script it needs is fetched with its own request.

Answer key

Answers: Passwords, encryption basics and two-factor

  1. Any two of: long, hard to guess, not based on personal details, used for only one account, mixes words with numbers and symbols.
  2. It is a name plus a birth year, both easy to find out or guess.
  3. FDE
  4. JAL
  5. BQQ: Z wraps to B, O becomes Q, O becomes Q.
  6. The rule is the method (shift letters) and can be public; the key is the secret number that makes the scrambling unique.
  7. There are only 25 useful keys, so an attacker can try every one in minutes.
  8. Something you know (a password) and something you have (your phone or an authenticator app).
  9. No; the site also asks for the one-time code on the phone, which the thief does not have.
  10. That the connection uses HTTPS, so data between you and the site is encrypted.
  11. No; if one site leaks the password, every account using it is open to attack.
WhatsApp us