Computer Science · May / June 2022 · Paper 1 HL · Question 14
Adapt for 2027Turning a flowchart into functions with parameters and return values is B2.3.4 and B1.1.4; write the code in Python or Java.
IBCS
As printed in the paper
The question as text
14. The flowchart on page 6 represents an algorithm that allows a user to enter the number of sides, length of side and apothem (see diagram below) for a regular polygon. It then calculates and outputs the area and perimeter of this shape. Worked example: a regular hexagon Number of sides = 6 Length of side = 10 cm Apothem = 8.66 cm Perimeter = Number of sides × Length of side = 6 × 10 = 60 cm Area = × 2 Perimeter Apothem = × 60 8.66 2 = 259.8 cm2 A regular hexagon Apothem 10 cm 8.66 cm (This question continues on the following page) (Question 14 continued) START END PERIM = NUM_SIDES * LENGTH_SIDE output "Enter the number of sides for your shape" input NUM_SIDES output "Enter the length of each side for your shape" input LENGTH_SIDE output "Enter the length of the apothem for your shape" input APOTHEM AREA = PERIM * APOTHEM / 2 output "The area of your shape is ", AREA output "The perimeter of your shape is ", PERIM (This question continues on the following page) (Question 14 continued)
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
14(a)(i)[2]
14(a)(ii)[4]
14(a)(iii)[5]
14(b)[4]
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

