2878zu84 WR

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

3.

WRITTEN RESPONSES

3 a.
3.a.i.
The overall purpose of the program is to provide you with the winner and host of the FIFA Women’s World Cup, by typing
in any year and clicking the next button.

3.a.ii.
When I typed in 2015, and then clicked the check button it provided me with the two outputs. The first output was the
champion's output and the answer to that was United States, and the second output was the Host of the World Cup, and
the answer to that was Canada. Then in the input, I typed in 2017, and since that year does not have a World Cup, both
the outputs told the user “There was no world cup this year”. Then I typed in 2015 and got the correct answers to both the
Champions and Hosts of the World Cup.

3.a.iii.
When I type in a year input in the year text box, and then click check, I get my output which is the Champions output
and the Hosts output.

3 b.
3.b.i.
3.b.ii.

3.b.iii.
In the image above, you are able to see the champions, hosts and the worldCup list being used in two different loops. In
the video, all three of these lists were being utilized

3.b.iv.
The champions list stores the name of all the champions throughout the years, the worldCup list stores the years the
world cup happened, and then the hosts list stores the list of the places the world cup was hosted that certain year.

3.b.v.
The lists come in quite handy when you need to store a lot of variables or data. Having access to lists eliminates the
need to establish numerous unique variables, each of which would only contain a single piece of information or a single
value. Like in my program if I didn’t have lists for the champions, hosts, and the year the world cup was held, my program
would not be running as smoothly, and I would have a bunch of unnecessary code in my program, which could cause
many errors, since it is possible for a user to repeat the same variable name and completely remove one of its values.
3 c.
3.c.i.

3.c.ii.

3.c.iii.
In my host's function pictured above, the code is using the input of a year the world cup could’ve been held to then get the
output which are the hosts of that year. Without this function in the program, the year would not be executed into the
overall decision of what list to pull the hosts from. But with it, the user is able to receive the country that hosted the world
cup.
3.c.iv.
In the function, I made the “hosts” list. For each index of the “hosts” list, the procedure compares the year passed at the
same index in the year list. If the year that is passed matches with the year in the year list at the same index, then the
correct host value is returned. However, if the year passed in does not match any of the values in the year list, it returns
the string "There was no world cup this year" indicating that an invalid year was passed to the procedure.

3 d.
3.d.i.
First call:
The first call is for a nonvalid world cup year (The year 2030)

Second call:
The second call is for a valid year (the year 2018)

3 d.ii.
Condition(s) tested by first call:
The condition tested is to check if the world cup year passed into the procedure matches with the year in the year list.

Condition(s) tested by second call:


The condition that is tested is to check if the world cup year that is passed into the procedure matches with the year in
the year list.

3.d.iii.
Results of the first call:
The result of the second call is an empty string from the procedure. However, the string that is displayed to the user is
“There was no world cup this year”.

Results of the second call:


The result of the second call is the host of the year the user typed in.

You might also like