Question 1Easy5 marks
A teacher shares sweets equally between the children in a group. Any sweets left over are kept by the teacher.
01 sweets = 23
02 children = 4
03 each = sweets // children
04 left = sweets % children
05 print("Each child gets", each)
06 print(left, "sweets are left over")(a) State the output of line 05.[1]
(b) State the output of line 06.[1]
(c) State the value of
sweets / children.[1](d) State the value of
children ** 2.[1](e) Give a reason why the programmer used
// rather than / in line 03.[1]Show the answer and mark scheme
(a) Answer:
Each child gets 5Each child gets 5
(b) Answer:
3 sweets are left over3 sweets are left over
(c) Answer: 5.75
- 5.75
(d) Answer: 16
- 16
(e) Answer: // gives only the whole-number part of the division (5), because each child must get a whole number of sweets; / would give 5.75.
//gives only the whole-number part of the division, because the sweets cannot be split (/would give 5.75)