HOME/Articles/

lesson4-MathQuiz (snippet)

Article Outline

Python example 'lesson4-MathQuiz'

lesson4-MathQuiz

Python beginners example: lesson4-MathQuiz

This program will help the user practice math skills by quizing them.

Example Execution:
\begin{lstlisting}
3 + 5 = 8
Correct!

4 + 6 = 9
Incorrect!
4 + 6 = 10

5 + 9 = I love ice cream!
Please enter a number!
5 + 9 = 14
Correct!
\end{lstlisting}

\subsection*{Requirements}
\begin{enumerate}
\item The program must be able to run without typing the word ``python" first.
\item The program must ask the user random addition questions adding single digit numbers.
\item The program must implement a function called something like int\_input() that allows the program to take numbers as an input, and give them another chance if they enter something that is not a number.
\end{enumerate}


\subsection*{Optional}
\begin{enumerate}
\item Allow the user to practice subtraction, division, multiplication, or other mathematical operations as well.
\item Provide the user with a nice way to quit to the program other than pressing ctrl + c