Photo AI

Figure 8 shows a Python program that is being developed - AQA - GCSE Computer Science - Question 17 - 2021 - Paper 1

Question icon

Question 17

Figure-8-shows-a-Python-program-that-is-being-developed-AQA-GCSE Computer Science-Question 17-2021-Paper 1.png

Figure 8 shows a Python program that is being developed. It is supposed to calculate and display the highest common factor of two numbers entered by the user. The ... show full transcript

Worked Solution & Example Answer:Figure 8 shows a Python program that is being developed - AQA - GCSE Computer Science - Question 17 - 2021 - Paper 1

Step 1

State the output from the program in Figure 8 when the user enters the numbers 4 and 4.

96%

114 rated

Answer

When the user enters the numbers 4 and 4, the program will incorrectly output 1 instead of 4 because the loop condition never allows count to reach 4 due to inconsistent iteration logic.

Step 2

State the line number from the program in Figure 8 which contains the error that stops the program from sometimes working correctly.

99%

104 rated

Answer

The error is contained in line 5, where the loop condition is count < num1. In this case, it restricts the loop from checking the value num1, which is equal to 4.

Step 3

Describe how the line of code identified in your answer to Question 17.2 should be changed so that the program in Figure 8 will work correctly.

96%

101 rated

Answer

The line should be changed from while count < num1: to while count <= num1:. This will ensure that the loop runs until count equals the input number, allowing it to correctly identify the highest common factor of 4.

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;