Skip to content

← Final exam model papers

Final Exam Model Paper 4

Theory paper: 50 marksTime: 2 hours

Practical exam: 25 marksTime: 1 hour 30 minutes

All questions are compulsory.

A full practice run of the Grade 8 final exam: the theory paper (50 marks, 2 hours) and, below it, the practical exam (25 marks, 1 hour 30 minutes, at a computer, marked by the school). In the theory paper, work out on paper what each program does, as in the exam hall: its programs have no Run button. In the practical exam, the programs run on this page.

A practice paper by Science Playground, made to its own course’s grid; not an official exam paper.

Write your answers on paper first. Then open each answer and its marking scheme, and give yourself one mark for each point you got. In multiple choice, your first choice counts.

Section A

10 × 1 = 10

1. Choose the correct option for each of the following questions.

a.

Sunil, in Dang, writes a program for Laxmi Puja greeting cards. What does it print?

name = "Laxmi"print(name == "laxmi")

Pick an answer to see why.

b.

At Dashain, children in Baglung take turns on the linge ping. A program praises each child by the number of swings:

swings = 12if swings > 10:    print("Champion of the ping!")if swings > 5:    print("Good swinging!")else:    print("Keep trying!")

What does it print?

Pick an answer to see why.

c.

Bikash says: “Bubble sort, with the rule that it stops after a pass with no swaps, always needs at least 4 passes for a list of 5 numbers.” Which list proves him wrong?

Pick an answer to see why.

d.

On a page about Dashain, the paragraphs about tika have class="tika". Which selector, in the style sheet, picks out those paragraphs?

Pick an answer to see why.

e.

A school in Gulmi has made a 30-page Dashain magazine, with text and photos, to send to a printing press. In which format should it be sent?

Pick an answer to see why.

f.

For Tihar, a micro:bit by the door plays the start of a tune when guests arrive. About how long does this line play?

music.play(["c4:4", "d", "e", "g:8"])

Pick an answer to see why.

g.

Before Tihar, Puja installs a torch app to light the courtyard. It asks to read her contacts and her SMS messages. What should she do?

Pick an answer to see why.

h.

A tea shop in Gulmi draws a chart of the total cups of tea sold since Baisakh, month by month. The line goes up every month, and the owner says, “Business grew every month.” Which judgment is right?

Pick an answer to see why.

i.

What is a large language model?

Pick an answer to see why.

j.

A diffusion model is trained on millions of pictures, each buried in random noise step by step. At each step, what is the model asked to do?

Pick an answer to see why.

Section B

8 × 1 = 8

2. Write very short answers to the following questions.

a.

Name the Python function that turns the number 15 into the text "15", so that it can be joined to other text with +.

Answer

str(): str(15) gives "15", and "Day " + str(15) gives "Day 15".

Marking scheme
  • str().
b.

What is a function’s docstring?

Answer

A string in triple quotes on the first line of a function’s body, saying what the function does; Python keeps it as the function’s documentation, and help() shows it.

Marking scheme
  • A string on the first line of the function’s body that says what it does (shown by help()).
c.

For the ward’s news page, Dipak removes a man from a photo of a Dashain tika program, because he “spoils” it. Why is this dishonest?

Answer

It changes what happened: the photo now shows a program without someone who was there, and readers trust a news photo to show the event as it was. Honest edits only show more clearly what was really there.

Marking scheme
  • It changes what happened (a person who was there is removed), so the news photo no longer shows the truth.
d.

Why is a micro:bit’s button a digital input, but its light sensor an analog one?

Answer

A button has only two states, pressed or not (True or False). Light can be any amount in a range, from dark to bright, which the sensor measures as a number from 0 to 255.

Marking scheme
  • The button is only on or off; light can be any amount, measured as a number (0 to 255).
e.

The brown of a Dashain kite is rgb(139, 69, 19). Write a CSS rule that makes every h2 heading this color.

Answer
h2 {  color: rgb(139, 69, 19);}

(The same color in hex, #8b4513, is just as right.)

Marking scheme
  • The selector h2 with color: rgb(139, 69, 19); (or #8b4513).
f.

Bipana’s photo of kites over the rooftops at Dashain is 3,000 pixels wide. Using the rule of thirds, how far from the left edge are the crop tool’s two upright lines?

Answer

A third of 3,000 is 1,000, so the lines are 1,000 and 2,000 pixels from the left edge.

Marking scheme
  • 1,000 and 2,000 pixels.
g.

Dashain lasts 15 days, from Ghatasthapana to Kojagrat Purnima. This program should print a line for each of the 15 days, but the last line it prints is “Dashain day 14”. Which part is wrong, and what should it be?

for day in range(1, 15):    print("Dashain day", day)
Answer

range(1, 15) stops before 15, so it gives 1 to 14. It should be range(1, 16).

Marking scheme
  • range(1, 15) leaves out 15; it should be range(1, 16).
h.

To plan the family’s Dashain spending, Sanjay wants to paste his father’s bank statement, with the account number and name, into a chatbot and ask for a budget. Is that a good idea? Give a reason.

Answer

No. What is typed into a chatbot may be kept by the company, read by people who check the AI, and used to train the next model. A bank statement is private information about another person. He could make the budget himself, or ask the chatbot for a general plan with made-up numbers and nothing that tells who they are.

Marking scheme
  • No, because a prompt may be kept, read by people or used for training, and the statement is private (another person’s money).

Section C

8 × 2 = 16

Write short answers to the following questions.

3.
[2]

Gopal, in Arghakhanchi, starts a program for his Dashain shopping list, but Python won’t run it:

1st_gift = "kite"class = 8
  • i.Why is 1st_gift not allowed as a variable name?
  • ii.Why is class not allowed? Suggest an allowed name for each.
Answer
  • i.A name can’t start with a digit. (Python stops with a SyntaxError on line 1 before running anything.)
  • ii.class is one of Python’s keywords, its own words, which can’t be names. Allowed names: for example first_gift and grade (or class_8).
Marking scheme
  • i. A name can’t start with a digit.
  • ii. class is a keyword; with allowed names such as first_gift and grade.
4.
[2]

Rita sends a Dashain greeting to 3 friends; each of them sends it to 3 more, and so on. A program works out how many people get it in one round:

rounds = 4people = 3 ** roundsprint("In round", rounds, "it reaches", people, "people")
  • i.Write the output of the program.
  • ii.Write one line of Python that prints how many people get it in the four rounds altogether.
Answer

i. ** is “to the power of”: 3 × 3 × 3 × 3 = 81.

Output

In round 4 it reaches 81 people

ii. 3 + 9 + 27 + 81:

print(3 + 3 ** 2 + 3 ** 3 + 3 ** 4)

Output

120
Marking scheme
  • i. In round 4 it reaches 81 people.
  • ii. A line that prints 3 + 3² + 3³ + 3⁴ (120), with ** or the numbers written out.
5.
[2]

A program for Dashain greetings:

def wish(person, festival):    return f"Happy {festival}, {person}!" print(wish("Dashain", "Sita"))
  • i.Write the output.
  • ii.What is wrong, and how should line 4 be written?
Answer

i. Arguments are given to parameters in order: person gets "Dashain" and festival gets "Sita".

Output

Happy Sita, Dashain!

ii. The arguments are in the wrong order. Line 4 should be print(wish("Sita", "Dashain")), which prints Happy Dashain, Sita!.

Marking scheme
  • i. Happy Sita, Dashain!.
  • ii. The arguments are matched in order, so they must be swapped: wish("Sita", "Dashain").
6.
[2]

At a chess tournament in Dang during the Dashain holidays, games are timed in minutes and seconds. Write a function seconds(minutes, secs) that returns the time in seconds, and use it to print the total time, in seconds, of two games that took 12 minutes 30 seconds and 15 minutes 45 seconds.

Answer
def seconds(minutes, secs):    return minutes * 60 + secs print(seconds(12, 30) + seconds(15, 45))

Output

1695
Marking scheme
  • A function seconds with two parameters that returns minutes * 60 + secs.
  • A line that calls it for both games and prints the sum of the returned values (1695).
7.
[2]

Anjali’s Dashain photo of her grandmother’s whitewashed house looks dull, so she makes it brighter by multiplying every pixel’s numbers by 1.4. Two pixels side by side on the wall are (180, 175, 170) and (200, 195, 190).

  • i.Write the new numbers of each pixel.
  • ii.A third pixel was (210, 205, 200). Compare its new numbers with the second pixel’s. What has happened to the detail of the wall?
Answer

i. A number can’t go above 255, so the editor stops it there.

  • (180, 175, 170) × 1.4 = (252, 245, 238).
  • (200, 195, 190) × 1.4 = (280, 273, 266), stopped at (255, 255, 255).

ii. (210, 205, 200) × 1.4 = (294, 287, 280), also stopped at (255, 255, 255). The two pixels were slightly different before; now they are exactly the same pure white. The light parts of the wall are clipped: the differences that showed its texture are gone, and no slider can bring them back. She should brighten less, or go back to the original photo.

Marking scheme
  • i. (252, 245, 238) and (255, 255, 255), with each number stopped at 255.
  • ii. Both become (255, 255, 255), so the difference between them is lost: the wall is clipped.
8.
[2]

A shopkeeper in Dang wants a micro:bit to switch a fan’s relay on when the shop gets hot. Her first program switches it on above 31 °C and off at 31 °C or below. On a day when the temperature stays near 31 °C, the fan clicks on and off again and again.

  • i.Why does this happen?
  • ii.How do two thresholds solve it?
Answer
  • i.A reading near the threshold goes a little up and down (31, 32, 31, 32…), and every time it crosses 31 the program switches the fan on or off.
  • ii.Switch on above a higher threshold (say 32 °C) and off only below a lower one (say 30 °C), and in between leave it as it is. The program remembers in a variable whether the fan is on. Small changes near one number then don’t switch it.
Marking scheme
  • i. The reading wobbles across the one threshold, so the fan switches each time it crosses.
  • ii. On above one threshold and off below a lower one, leaving it as it is in between.
9.
[2]

What is data sovereignty? Why does it matter when a Nepali student’s data is kept by an app on servers in another country?

Answer

Data sovereignty is the idea that data about a country’s people should be under that country’s own laws.
It matters because most big apps keep their data in data centers abroad: there, that country’s courts and police may be able to ask for the data, and Nepal’s law may be hard to use to protect it. (For the same reason, many countries ask that government records, and sometimes banking and health data, be kept inside the country.)

Marking scheme
  • Data about a country’s people should be under that country’s own laws.
  • Data kept abroad may be asked for by that country’s courts or police, and Nepal’s law may be hard to use to protect it.
10.
[2]

For the cover of the school’s Dashain magazine, Nabin makes a picture with an image generator from the prompt “a Nepali family receiving Dashain tika”. Should the school use it as it is? Judge, with two reasons.

Answer

Not as it is. First, an image generator learned mostly from pictures from other countries, so it may draw the tika, the clothes or the house wrongly; someone who knows the festival must check it. Second, it is not a photo of a real family, so the cover must say it was made with AI, never pass it off as a photo or as a student’s drawing. (A photo or drawing by the students themselves would show their own Dashain.)

Marking scheme
  • It may show the festival wrongly, because the generator learned mostly from other countries’ pictures, so it must be checked.
  • It must be labeled as made with AI, not passed off as a photo or a student’s own drawing.

Section D

4 × 4 = 16

Write long answers to the following questions.

11.
[4]

At the Dashain linge ping in a village in Baglung, children count how many times they swing back and forth before they have to stop. Write a program that asks for each child’s name, then their count, until done is typed for the name, and then prints the name of the child with the most swings, and their count.

  • i.Write the program. (3)
  • ii.Why is a while loop better here than a for loop? (1)
Answer

i.

best_name = ""best_swings = 0name = input("Name (or done): ")while name != "done":    swings = int(input(f"Swings by {name}: "))    if swings > best_swings:        best_name = name        best_swings = swings    name = input("Name (or done): ")print("Most swings:", best_name, "with", best_swings)

Output

Name (or done): SitaSwings by Sita: 14Name (or done): HariSwings by Hari: 21Name (or done): NimaSwings by Nima: 17Name (or done): doneMost swings: Hari with 21

ii. Nobody knows in advance how many children will have a turn: a while loop repeats until a condition (here, typing done) says stop, while a for loop needs to know how many times to run.

Marking scheme
  • i. A while loop that asks for names until done, and a count for each child with int(input(…)).
  • i. The highest count so far kept, starting at 0, and replaced when a bigger count comes.
  • i. The name kept together with the highest count, and both printed once after the loop.
  • ii. The number of children isn’t known in advance, and while repeats until told to stop.
12.
[4]

Ramesh in Gulmi saves part of his Dashain money: Rs 10 on the first day, Rs 20 on the second, Rs 30 on the third, and so on, until he has saved at least Rs 100. His plan as pseudocode:

Pseudocode

SET total TO 0SET day TO 1WHILE total < 100    SET total TO total + day * 10    SET day TO day + 1END WHILEOUTPUT day - 1
  • i.Trace it: show total and day after each round of the loop. (2)
  • ii.What does it output, and what does that number mean? (1)
  • iii.In a flowchart of this algorithm, which symbol would you draw for the WHILE line, and which for the OUTPUT line? (1)
Answer

i.

Round total < 100? total day
(start) 0 1
1 yes 10 2
2 yes 30 3
3 yes 60 4
4 yes 100 5
(check) no: 100 is not less than 100
  • ii.It outputs 4: the number of days he saves before he has at least Rs 100. (day is already 5, the next day, when the loop ends, which is why it outputs day - 1.)
  • iii.The WHILE is a decision, a diamond, with Yes and No; the OUTPUT is input or output, a parallelogram.
Marking scheme
  • i. Rounds 1 and 2 right: total 10 and 30, day 2 and 3.
  • i. Rounds 3 and 4 right: total 60 and 100, day 4 and 5, and the loop stops because 100 is not less than 100.
  • ii. 4, the number of days he saves.
  • iii. A diamond (decision) for WHILE and a parallelogram for OUTPUT.
13.
[4]

Read the web page and its style sheet, and answer the questions that follow.

index.html

<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8">    <meta name="viewport" content="width=device-width, initial-scale=1">    <title>The Five Days of Tihar</title>    <link rel="stylesheet" href="style.css">  </head>  <body>    <img src="diyo-border.png" alt="">    <h1>The Five Days of Tihar</h1>    <ol>      <li>Kag Tihar: crows</li>      <li>Kukur Tihar: dogs</li>      <li>Gai Tihar and Laxmi Puja</li>      <li>Govardhan Puja and Mha Puja</li>      <li>Bhai Tika</li>    </ol>    <p>Read about <a href="deusi-bhailo.html">Deusi and Bhailo</a>.</p>  </body></html>

style.css

h1 {  color: #ffd700;}
  • i.Why is the list of days an <ol>, not a <ul>? (1)
  • ii.The picture diyo-border.png is a row of little oil lamps used as a decoration. Is alt="" right for it? Give a reason. (1)
  • iii.Which words can a visitor tap, and what happens then? (1)
  • iv.The heading is gold (#ffd700) on a white background. What is wrong with this, and how should it be fixed? (1)
Answer
  • i.The five days come in an order, one after the other, so a numbered (ordered) list fits: the browser numbers them 1 to 5. A <ul>, with bullets, is for things in no special order.
  • ii.Yes. It is only decoration and tells the visitor nothing, so an empty alt="" lets a screen reader skip it instead of reading out a file name.
  • iii.The words “Deusi and Bhailo”: tapping them opens the page deusi-bhailo.html.
  • iv.The contrast is far too low: gold on white is about 1.4 : 1, and text needs at least 4.5 : 1, so many people, and anyone reading a phone in sunlight, can’t read it. Use a darker color, such as a dark brown (#8b4513, about 7 : 1).
Marking scheme
  • i. The days come in order, and <ol> is the numbered list for things in order (<ul> for no special order).
  • ii. Yes, because it is only decoration, so a screen reader should skip it.
  • iii. “Deusi and Bhailo”, which opens deusi-bhailo.html.
  • iv. Too little contrast (needs at least 4.5 : 1); use a darker color.
14.
[4]

Read the given passage and answer the questions that follow.

Bikram, in Baglung, finds that his social media account has sent messages to his friends asking them to send money for a “Dashain emergency”. Then he gets an email saying that the recovery phone number on his account was changed. He didn’t do either.

  • i.How should he try to get back into his account? (1)
  • ii.Once he is in, what should he check first, and why? (1)
  • iii.Why should he warn his friends, and how? (1)
  • iv.Where in Nepal can he report it, since someone is pretending to be him and asking for money? (1)
Answer
  • i.Through the official Forgot password? or account-recovery page, typed in himself, never from a link in a message or that email. His recovery email, phone or codes get him back in.
  • ii.Change the password, then check the recovery email and phone (and sign out every other device): the attacker changed the phone number to keep a way back in, so he must put his own back.
  • iii.So that they don’t send money or trust links from the hacked account. He should warn them from another account or by phone, not from the hacked one.
  • iv.To Nepal Police’s Cyber Bureau (and to the website through its help pages), keeping screenshots, dates and times as proof.
Marking scheme
  • i. The official Forgot password or recovery page, typed in himself, not from a link.
  • ii. The recovery email and phone (put his own back), because the attacker changed them to get back in.
  • iii. So friends don’t send money or open links; warn them from another account.
  • iv. Nepal Police’s Cyber Bureau.

Practical exam

25 marks

Marked by the school. Work alone at a computer, with no internet and no AI, in front of the teacher, for 1 hour 30 minutes. Write and run each program, show it working, and answer the teacher’s questions. On this page, press Edit on a program to type in it, and Run to run it.

P1.
[8]

The linge ping queue. Children are waiting for the village’s Dashain swing. Each ride takes 2 minutes, and a child under 6 must ride with a grown-up. Write a program that:

  • asks how many children are waiting;
  • asks each child’s age, in turn, and prints “Ride with a grown-up.” for a child under 6, otherwise “Ride on your own.”;
  • at the end, prints how many children need a grown-up, and how many minutes it will take for everyone to ride.

Run it in front of the teacher with 4 children, aged 5, 9, 12 and 3.

# The linge ping queue: write your program heresmall = 0
Answer
children = int(input("How many children are waiting? "))small = 0for child in range(1, children + 1):    age = int(input(f"Age of child {child}: "))    if age < 6:        print("Ride with a grown-up.")        small = small + 1    else:        print("Ride on your own.")print("Children who need a grown-up:", small)print("Time for everyone to ride:", children * 2, "minutes")

Output

How many children are waiting? 4Age of child 1: 5Ride with a grown-up.Age of child 2: 9Ride on your own.Age of child 3: 12Ride on your own.Age of child 4: 3Ride with a grown-up.Children who need a grown-up: 2Time for everyone to ride: 8 minutes

A for loop fits, because the program knows how many children there are before the loop starts. Other wordings of the messages are fine.

Marking scheme
  • Asks for the number of children with int(input(…)).
  • A for loop that runs once for each child (range(children) or range(1, children + 1)).
  • Asks each child’s age with int(input(…)) inside the loop.
  • An if/else with the right condition (age < 6).
  • Prints the right message for each child.
  • A counter of the children under 6, starting at 0 before the loop.
  • Prints the count and the minutes (children × 2) once, after the loop.
  • Runs it in front of the teacher with 4 children aged 5, 9, 12, 3, and gets 2 children and 8 minutes.
P2.
[4]

The Dashain greeting. This program should greet a person by name. Run it.

name = input("Your name: ")print("Happy Dashain, + name)
  • i.Write the kind of error and the line Python names.
  • ii.Say why it happens, and why the program didn’t even ask for a name.
  • iii.Fix the program.
  • iv.Test it with the names Sita, Ram Bahadur and an empty answer (just press Enter): write what each should print first, then run it.
Answer

i. and ii. A SyntaxError, on line 2:

Error message

  File "main.py", line 2    print("Happy Dashain, + name)          ^SyntaxError: unterminated string literal (detected at line 2)

The string that starts with "Happy is never closed: the closing quote is missing, so Python reads , + name) as part of the text and reaches the end of the line still inside it. A SyntaxError is found while Python reads the program, before anything runs, so the question on line 1 was never asked.

iii. Close the string before +:

name = input("Your name: ")print("Happy Dashain, " + name)

Output

Your name: SitaHappy Dashain, Sita

iv.

Name Should print Kind of test
Sita Happy Dashain, Sita ordinary
Ram Bahadur Happy Dashain, Ram Bahadur ordinary: a name with a space
(empty) Happy Dashain, edge: nothing typed
Marking scheme
  • Names the SyntaxError and line 2.
  • Explains the missing closing quote, and that a SyntaxError stops the program before anything runs.
  • Fixes it ("Happy Dashain, " + name), and it runs.
  • Writes the expected results for the three names first, and the program gives them.
P3.
[7]

A page about the linge ping. Make a small web page about the Dashain swing with:

  • a title, and a main heading;
  • a sentence or two about the linge ping;
  • a list of three steps in building one, or three things to do at Dashain;
  • the photo linge-ping.jpg, of a bamboo swing at sunset, with alt text;
  • at least one CSS rule in the style sheet that changes how the page looks.

Show it to the teacher, on a phone width as well.

Try it

A page about the linge ping

Your page, titled
  • Title

  • Language

  • Headings

  • Pictures

  • Contrast

  • Phone width

Change the code until every row has a ✓.

Your page is kept in this browser only. Nothing you type is sent anywhere.

linge-ping.jpg: Mithun Kunwar, CC BY 2.0, via Wikimedia Commons

Answer

One good page (yours will be different):

index.html

<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8">    <meta name="viewport" content="width=device-width, initial-scale=1">    <title>The Linge Ping, Our Dashain Swing</title>    <link rel="stylesheet" href="style.css">  </head>  <body>    <h1>The Linge Ping</h1>    <p>At Dashain, villages build a tall swing of four bamboo poles, and children and grown-ups take turns swinging high.</p>    <h2>Things to do at Dashain</h2>    <ul>      <li>Swing on the linge ping</li>      <li>Fly kites from the roof</li>      <li>Receive tika and jamara from elders</li>    </ul>    <img src="linge-ping.jpg" alt="A child swinging high on a tall bamboo linge ping at sunset, with hills behind">  </body></html>

style.css

body {  font-family: sans-serif;} h1 {  color: #8b4513;} img {  max-width: 100%;}

The max-width: 100% rule keeps the photo inside a phone’s screen.

Marking scheme
  • A <title> that says what the page is, with the skeleton (lang, head and body) kept correct.
  • One <h1> main heading at the top of the body.
  • A paragraph (<p>) about the linge ping.
  • A list (<ul> or <ol>) with three <li> items, opened and closed correctly.
  • The photo shown with <img src="linge-ping.jpg">.
  • Alt text that says what the photo shows (not just “photo” or “image”).
  • A CSS rule with a selector and a declaration (property: value;) that changes how the page looks.
P4.
[6]

Viva. The teacher asks each student about their own work, for example:

  • i.In your queue program, what values does the loop variable take? Why did you use a for loop and not a while loop? (2)
  • ii.In your fixed greeting, "Happy Dashain, " has a space before its closing quote. Why? What would it print for Sita without that space? (2)
  • iii.Which line in your index.html connects it to style.css? What would your page look like if that line were deleted? (2)
Answer
  • i.With range(1, children + 1) it takes 1, 2, 3 and 4 for 4 children, one value for each child (with range(children), 0 to 3). A for loop fits because the number of rounds is known before the loop starts: the number of children typed in.
  • ii.+ joins two strings exactly as they are, adding nothing between them. The space inside the quotes keeps the comma and the name apart. Without it, the line would be Happy Dashain,Sita.
  • iii.<link rel="stylesheet" href="style.css">, in the head. Without it the browser never reads the style sheet, so none of its rules apply: the page shows in the browser’s plain style (its default font, black headings, the photo at its full size), though all the words and the photo are still there.
Marking scheme
  • i. The values it takes (1 to the number of children, or 0 to one less).
  • i. A for loop, because the number of children is known before the loop.
  • ii. + adds nothing between the strings, so the space keeps the comma and the name apart.
  • ii. Without it: Happy Dashain,Sita.
  • iii. The <link rel="stylesheet" href="style.css"> line in the head.
  • iii. Without it, none of the CSS rules apply: the page shows in the browser’s plain style.

Your score

0 / 50 theory

0 / 25 practical

34 questions not marked yet

Section A–Full marks 10
Section B–Full marks 8
Section C–Full marks 16
Section D–Full marks 16
Practical exam–Full marks 25

Marks lost, by unit

Mark a question to see your score here.

Score 0 of 0 0 of 34 marked Time left: 2:00:00