Quiz App Projects Loops with Lists

Time Estimate: 90 minutes

Introduction and Goals

In this lesson, you will complete several small programming projects that add enhancements to the Quiz App. You are encouraged to discuss your ideas for how to solve these problems with the instructor and with your partner and other students. Hints and suggestions are provided.
Learning Objectives: I will learn to
  • count right and wrong answers using a list to keep track of which questions have already been answered
  • use loops with lists and standard algorithms to enhance my app
  • manipulate lists in pseudocode using the insert, append, and length procedures
  • design and implement my own custom quiz app features
Language Objectives: I will be able to
  • use target vocabulary, such as insert, append, and length while improving app features and User Interface with the support of concept definitions and vocabulary notes from this lesson

Learning Activities

Loops with Lists:

Here is a quick review of comparing AP pseudocode and App Inventor blocks for loops with list:

Basic operations on lists include:
  • Accessing an element by index: list[i] where i is an index from 1 to the length of the list.
  • Saving an element of a list into a variable like x:   x ← list[i]
  • Assigning a value to an element of a list:
    • list[i] ← x assigns the value of x to list[i].
    • list[i] ← list[j] assigns the value of list[j] to list[i].
Some other list operations in AP-style questions are:
  • INSERT(list, i, value) : inserts value into the list at index i, moving down all other items at and after i in the list.
  • APPEND(list, value): adds value to the end of the list.
  • REMOVE(list, i): removes the item at index i and moves up all items after the ith item.
  • LENGTH(list): evaluates to the number of elements currently in the given list.

Programming and Creative Projects

For this lesson you can start up App Inventor and open the project you created in the previous lesson. After opening your Quiz project, rename it QuizProjects2, for Quiz Version 2 -- or something similar to that. Then complete the programming exercises described below.

  1. If/else Scoring Algorithm: Modify your app to keep score of how many questions are answered correctly or incorrectly. Be sure to restrict it so that the quiz taker can only receive credit for answering each question once (i.e., if there are three questions, the quiz taker can only be credited with three correct answers). Use this short handout to guide you with this project.
  2. Loop Algorithm for Searching: Add a keyword search capability to your app. For example, if the user types in NASA and clicks on the search button, you should find the question or answer with the word NASA in it and show that question. This will be a linear search through the parallel question and answer lists using a loop. Use this short handout to guide you with this project.
  3. Your Own Quiz App: Use the Quiz App as a template to create a quiz on a topic of your own choosing. Besides changing the questions, answers, and pictures, add at least one enhancement to the app. Be creative!


In this lesson, you learned how to:



Here is a table of the technical terms we've introduced in this lesson. Hover over the terms to review the definitions.


Check Your Understanding

You can practice more algorithms with loops and lists below. It is useful to know standard algorithms that use loops like searching for an item in a list, finding the minimum or maximum value in a list, computing the sum or average of a list of values, etc. Using existing algorithms as building blocks for constructing new algorithms has benefits such as reducing development time, reducing testing, and simplifying the identification of errors.

Sample AP CSP Exam Questions

Reflection: For Your Portfolio

Answer the following portfolio reflection questions as directed by your instructor. Questions are also available in this Google Doc where you may use File/Make a Copy to make your own editable copy.

You have attempted of activities on this page