CS110 Introduction to Computing
Fall 2006
Lab Assignment#6
Problem: This assignment serves two purposes. First, it is the largest program we have written so far, so it will give you the chance to practice breaking up a problem into modular functions. Second, there are lots of opportunites to use the if decision structure. In the class, we will help you design the overall structure ofthe program. Please follow those design guidelines closely to learn how to design and then incrementally implement the program.
Educational Software: A Math Quiz
As computers become more common in schools, it is important to find ways to use them to aid in the teaching process. This need has led to the development of an educational software industry that has produced many programs that help teach concepts to children.
As an example of an educational application, write a program that poses a series of simple arithmetic problems for a student to answer, as illustrated by the following sample run:
Welcome to Math Quiz.
This program will ask you a series of 5 math
questions using addition and subtraction.
Have fun!
1. What is 5 - 4? 1
You rock!
2. What is 9 - 7? 2
Nice job.
3. What is 16 - 7? 8
That's incorrect. Try a different answer: 9
Well done.
4. What is 12 + 3? 16
That's incorrect. Try a different answer: 17
That's incorrect. Try a different answer: 11
No, the answer is 15
5. What is 17 - 6? 11
Yes indeed.
You answered 4 out of 5 questions correctly.
Goodbye and thanks for using Math Quiz.
Getting Started
Remember that your main program should be short and abstract. Most of the details for solving the problem should be divided up into functions. We strongly encourage you to build up your solution incrementally. You should add and test one function at a time, stubbing out the rest.
Your program should meet the following requirements:
- It should ask a series of five questions.
- Each question should consist of a single addition or subtraction problem involving just two numbers. The type of problem, addition or subtraction, should be chosen randomly for each question.
- To make sure the problems are appropriate for students in the first or second grade, none of the numbers involved, including the answer, should be less than 1 or greater than 20. This restriction means that your program should never ask a question like "What is 11 + 13?" or "What is 3 - 7?" because the answers are outside the legal range. Within these constraints, the program should choose the numbers randomly. We will discuss the random library in class. You can also read pages 268-270 in our textbook for more information.
- The program should give the student three chances to answer each question. If the student gives the correct answer, your program should indicate that fact in some properly congratulatory way and go on to the next question. If the student does not get the answer in three tries, the program should give the answer and go on to another problem.
- To keep the student interested, your program should randomly choose from at least five different congratulatory messages when the student gives a correct answer, as demonstrated in the sample run above.
- The program should keep track of how many questions the student was able to answer correctly, and it should report the results at the end.
For extra credit, change the program from text-based to a GUI. You should not try to add any graphical features until all of the above requirements are met.
What you will need to do
- Make sure you have read all of Chapters 6 & 7 and understand the examples and library functions presented there.
- Do the design first: plan out a complete sketch prior to writing your program. This is will be presented in class.
- Split your program into functions and make an incremental implementation plan.
- Make sure you do the above steps prior to entering the lab (or using your computer).
- Test and debug your program until it produces correct results.
- When done, print out the final version your your program and also a printout showing your program's sample outputs for at least two sessions.
- Make a blog posting saying that you have completed the assignment and also write up any logistical or other issues/questions raised while working on this assignment. Also write about your level of confidence on the concepts learned so far.
- ALL work in this course should be done individually without any help from any person other than the class TA's and instructor(s).
Notes:
Add the following line to all your Python programs:
# File: <place name of your program file here>
# Date: <date created>
# Created by: <your name>
# Assignment: <place assignment number here>
Back to CS110 Course Page