Discover: quiz.py

A while loop is a type of control flow statement that allows a block of code to be executed repeatedly based on a boolean condition. This means that a while loop will have a block of code run until a certain condition is met.

A triple-quoted string is a type of string that allows the programmer to create strings that span more than one line without using multiple print() statements.

Custom functions allow programmers to define their own functions. This means that a programmer can create a block of code that can be run multiple times by calling it rather than having to type out that entire block of code each time it is needed.

In quiz.py, I will need to use all three programming components as it will streamline the code. Using a while loop will allow my program to provide specific feedback to the user if their inputs are invalid, and prevent them from moving onto the next question until they enter an acceptable answer. Using a triple-quoted string will allow for easy formatting of the quiz. The use of programmer-defined functions will cut down on the length of the program, and make the code more readable as there will only be one while loop that will output the question, receive an input, check to see if it’s correct or acceptable and increment the score if it’s correct, and provide feedback if the input is not acceptable.

Leave a comment