For Bear
For Bear
Unit Learning objectives to be checked Levels of thinking Task Type Time to Score* Score
skills number* of perform for
task* (min)* section
Unit 12.1А: 12.6.1.1 use the functions of the library Applying 1, 2 SAQ 3 4 30
Python libraries. Random to get a pseudo-random number.
12.6.1.3 identify code snippets that use Higher order 3 EAQ 7 3
random sequence generation. thinking skills
12.6.2.1 determine standard colors by RGB Knowledge and 4 SAQ 1 1
code. comprehension
12.6.2.2 use commands of module Image in PIL Applying 5, 6a, 6b, SAQ 4 4
library (load, create, size, save) to manipulate 6c
images.
12.6.2.3 apply graphic primitives to Applying 7, 11 SAQ 12 10
create drawings.
12.6.2.4 create filters for image processing. Higher order 8 SAQ 8 5
thinking skills
12.6.3.1 use commands of the Wave library to Knowledge and 9, 10 EAQ, 5 3
process sound files. Comprehension, SAQ
Applying
Total: 40 30 30
Student’s full name:
Teacher:
Subject: Programming
Grade 12 Group
Term I
SUMMATIVE ASSESSMENT
30 marks
Instructions:
1. There are a total of 40 minutes to answer all the questions. (You are not allowed to talk, copy or
seek help from teachers or other students).
2. If you need more space to answer any question, use the pages provided at the back of this booklet
and mention the question number clearly.
3. For all numerical answers, complete solution must be shown and the answer to be rounded to the
nearest significant figure with SI unit.
For all ‘describe’ or ‘explain’ questions, the answer must be in detail and logic fully explained.
Total:
……./30
Notes: The tasks use Python code.
[2]
Answer:
Import random
Rand=random.randint(-10,10)
Print(Rand)
[2]
Line 4
Output the first two items from this list
[3]
[1]
6. Ruslan needs to load the graphic file below into the program and save it with a new name
“pyth.jpg”.
python.jpg
[1]
draw = ImageDraw.Draw(new_image)
new_image.save('new.png', "PNG")
[5]
pixels = file.load()
x, y = file.size
for i in range(x):
for j in range(y):
r, g, b=pixels[x][y]
r=100
b = (b + 100) // 3
pixels[i, j] = g, b, r
[5]
mode="wb")
dest.setparams(source.getparams())
frames_count = source.getnframes()
newdata=data[::2]
*newdata) dest.writeframes(newframes)
source.close()
dest.close() [2]
[5]
Mark scheme
1 A 1
D 1
[Max: 2]
2 randint(-10, 10)
randint 1
range from -10 to 10 1
[Max: 2]
4 (0, 255, 0) 1
pip install pillow 1
5
6(c) file.save("python.jpeg") 1
7 draw.rectangle 1
((20, 20, 1 1 pixel error
380, 380), 1 allowed
fill=(0, 0, 255), 1
outline=(255, 255, 255)) 1
[Max: 5]
TOTAL 30