CPT Writeup
Video: https://www.youtube.com/watch?v=vK-NwzAlDlc
3a.
- 3.a.i.: The overall purpose of the program is to help with exercising. It is to make it easier for people to plan out how they are going to workout.
- 3.a.ii.: The functionality is a sports quiz. The user is asked questions based on their personality and their interests and a sport is given to them. This helps them figure out what sport is best for them and how they are going to use this sport to workout. It makes it much simpler.
- 3.a.iii.: The input is the clicking of the questions in the sports quiz and the output is the result of the sport and the next question appearing. When you click the yes or no button on the quiz, it removes sports from a list and also causes the next question to appear. At the end of the quiz when the questions are all answered, the second output of the results will appear which is the list.
3b.
- 3.b.i.:
- 3.b.ii.:
- 3.b.iii.: The name of the list is "Sports" and the different elements of the list are different sports
- 3.b.iv.: The data in the list represent what is going to be shown at the end of the quiz. The different sports in the list will be removed based on the question that is answered and it will result in just a few elements at the end
- 3.b.v.: I am able to write a lot less code with a lot more function. The list also is essential to my code because it is the actual output. The way it works is that at the beginning of the quiz all of the sports are still in the list. As you answer more and more questions, more and more sports are removed from the list based on your answers. At the end of the quiz there will be a "final list" which has the recommended sport. Without this code, I would have to make a conditional statement for every combination of questions and sports which would make the code much longer. It also allows me to add more questions and sports easily.
3c.
- 3.c.i.:
- 3.c.ii.:
- 3.c.iii.: The function described here is "remove sports." What it does is it removes a sport from the sports list according to the answer to a question. When these sports are removed from the list the final list is displayed at the end of the quiz. If it were not for this feature the list would be the same for every input.
- 3.c.iv.: The way it works is that it calculates what the user entered as their answer for a question. The answer is either "yes" or "no." When yes is clicked the variable according to that question becomes true and false if no is clicked. For example, if the user says they don't want to play with a ball the "ball" variable becomes false. When the function is called it has two conditionals corresponding to each variable. One true and one false. In each one of these statements it removes certain sports from the list. For example, if "ball" is true, then it will remove sports such running.
3d.
- 3.d.i.:
- First call: The first call of "remove sports" is the way it removes sports from the question asking. The actual quiz removes sports from the list with conditionals.
- Second call: The second call of "remove sports" is removing a sport from the selection menu. When a sport is selected from the selection menu it is removed from the list.
- 3.d.ii.:
- The first call is testing if the answers to the statements were true or false and removes sports accordingly
- The second tests if a sport is selected in the selection menu and removes that sport.
- 3.d.iii.:
- The result is a list with various sports removed.
- The result is a list with one sport removed.