Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
Question 58

Which two of the following statements about the Python program in Figure 1 are true when it is executed with the grid shown in Figure 2?

Select two options.

Figure 1

for r in range(3):
    for c in range(3):
        if getCell(r, c) == 9:
            target_row = r
            target_col = c

Figure 2

column 0column 1column 2
row 0143
row 1592
row 2876
  • A: The outer loop for r in range(3) runs exactly 3 times.
  • B: The final value of target_col will be 1.
  • C: The selection assignment target_row = r will run for every cell in the grid.
  • D: The total number of comparisons between getCell(r, c) and 9 is 6.
  • E: The inner loop variable c does not change its value during execution.
[2]
Markscheme

Programming concepts Questions

  1. GCSE
  2. /Computer Science
  3. /Programming concepts

298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank