Gce Model Questions Vol1 2023 Computer Studies Question 19

Practice objective / multiple choice question 19 from the 2023 Gce Model Questions Vol1 Computer Studies examination.

Gce Model Questions Vol1 2023 Computer Studies Objective / Multiple Choice Hard Difficulty
Question 19 GCE_MODEL_QUESTIONS_VOL1 • 2023 • COMPUTER_STUDIES • objective

The following Python function returns the sum of all numbers from 1 to *n* that are multiples of 3 or 5 but not both. ```python def f(n): total = 0 for i in range(1, n+1): if (i % 3 == 0) ^ (i % 5 == 0): # exclusive OR total += i return total ``` (a) What value does `f(20)` return? (b) Rewrite the function so that it computes the same result without using a loop, by applying arithmetic‑series formulas. (You need only give the new function body, not the full program.)

Answer Options

A. 78
B. 85
C. 90
Correct Answer D. 83
Correct Answer
D
Correct Option:
83

About This Question

This is Gce Model Questions Vol1 2023 Computer Studies Question 19. It is one of the objective questions from the 2023 Gce Model Questions Vol1 Computer Studies examination.

Difficulty level: Hard .

Master the Exam!

You've seen a preview, but there are thousands more questions plus AI tutor to break down complex solutions.

Unlock Full Access Available for Android & Windows
Chat with Support