Embercode
✕
Flowcharts and PseudocodeQuick quiz

Flowchart loop reading

6 questions. Covers Flowcharts for loops and early exits.

Questions 1 to 5 of 6

  1. 1. What does this program print? ``python scores = [10, 20, 30, 40] total = 0 count = 0 while count < 3: total = total + scores[count] count = count + 1 print(count, total) ``
  2. 2. What does this program print? ``python readings = [5, 9, -1, 4, -1] position = 0 value = readings[position] seen = [] while value != -1: seen.append(value) position = position + 1 value = readings[position] print(seen, position) ``
  3. 3. The temperature loop in the lesson has a break. If the break is removed, which value does first_hot_position end up holding for the list [21, 38, 19, 40], searching for readings above 35?
  4. 4. Put these steps in the order you use to check a loop drawing by tracing it with real values.

    Use the arrows to put the steps in order.

    1. 1.Go down to the test and answer it with real numbers
    2. 2.Follow the return arrow back up to the test and check it again
    3. 3.Follow the yes arrow into the body and do its work
    4. 4.Start at the top with the starting values, such as total = 0 and count = 0
    5. 5.Stop when the test says no and the flow reaches the end box
  5. 5. Put these steps of a sentinel loop in the order a program runs them.

    Use the arrows to put the steps in order.

    1. 1.Test whether the value is -1
    2. 2.Move position on by one and read the next value
    3. 3.If it is not -1, add the value to seen
    4. 4.Set position to 0 and read the first value, readings[0]

3 question(s) left on this page.