Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
Question 5

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(4):
    for c in range(3):
        if getValue(r, c) == 12:
            found_row = r
            found_col = c

Figure 2

column 0column 1column 2
row 0385
row 114129
row 21227
row 311610
  • A: The outer loop for r in range(4) executes exactly 4 times.
  • B: The final value of found_col will be 0.
  • C: The assignment found_row = r will run for every cell in the grid.
  • D: The total number of comparisons between getValue(r, c) and 12 is 8.
  • E: The inner loop variable c remains constant throughout the execution of the program.
[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