Program Design and Development
This program was designed ordered and intentionally. Aidan developed and designed it from Tuesday till Wednesday in school, testing it in class on Wednesday and iteratively improving on the structure. Originally, the code we planned on making was hyperfocused on the Homework list using Canvas API, which was displayed in Aidan’s segment of the video. However, to meet 1.1-1.4 Team Test requirements, we added the code cells below to explore mathematical proccesses using lists and dictionaires.
We incrementally put together this code, first testing the user input section, then the printed data returned, then the dictionary and it’s KD ratios, and finally the error proofed Headshot-Legshot ratio. We investigated the functions of dictionaires as well as the usage of API’s for our Homework calendar app, and created useful, informative code.
Below you can find a copy of Aidan’s code, with documentation and comments explaining each part. This documentation was done in class collaboaratively, and largely at home on call. Daniel’s part is also documented (the tester data at the end)
## CODE FOR THIS SEGMENT DONE BY AIDAN LAU (github account AidanLau10), and DANIEL CHOI
## Makes use of a list here, specifically a list of popular games: Written by Aidan Lau
video_games = ["Valorant", "Apex legends", "Fortnite", "League of Legends", "Roblox"]
## Iterative code here: runs through all games in the list defined above: Written by Aidan Lau
print("Here is a list of some popular video games!")
for game in video_games:
print(game)
## Gets user input and provides basis for rest of code (based on KDR of the specific game Valorant): Written by Aidan Lau
favorite_game = input("What is your favorite video game? ")
if favorite_game == "Valorant":
print("You are class!")
elif favorite_game == "Apex Legends":
print("That game is not good!!")
elif favorite_game == "Fortnite":
print("That game used to be good.")
elif favorite_game == "League of Legends":
print("Please stop playing that game.")
else:
print("Alright game.")
## Defines player statitstics using a dictionary called "my_stats"
my_stats = {
"best_agent": "omen",
"adr": 178.8,
"kills": 26,
"deaths": 13,
"first_kills": 3,
"first_deaths": 1,
"hs_percent": 25,
"leg_percent": 0,
}
## Mathematical calculation here for kill/death ratio: uses dictionary above to divide stats. Uses less than and greater than signs to return info based on said stats. Written by Aidan Lau
print("But what is my K/D ratio and FK/FD ratio?")
kd = my_stats["kills"] / my_stats["deaths"]
print("My K/D ration is: ", kd)
if kd > 1:
print("Im a good player! I can get 1 kill for every death!")
elif kd < 1:
print("I'm so bad. I can't even get a kill for every death.")
## More statistical calculations, based on First Kills vs First Deaths
fkfd = my_stats["first_kills"] / my_stats["first_deaths"]
print("My FK/FD ratio is: ", fkfd)
if fkfd > 1:
print("Im so good at getting the first kill in the round and not dying first!")
elif fkfd < 1:
print("I die first in the round more times than I'm able to get the first kill!")
## Final Mathetmatical calculation, makes use of error checks as well to avoid math errors like dividing by zero. CODE WRITTEN BY DANIEL CHOI
print("What about my headshot to legshot ratio?")
def test_my_stats(stats):
try:
hs_leg_percent = my_stats["hs_percent"] / my_stats["leg_percent"]
except ZeroDivisionError as e:
print(f"Could not find the heashot to legshot ratio. Error: {e}")
if stats["adr"] < 0 or stats["kills"] < 0 or stats["deaths"] < 0:
raise ValueError("The ADR, kills, and death values should not be negative")
test_my_stats(my_stats)
Here is a list of some popular video games!
Valorant
Apex legends
Fortnite
League of Legends
Roblox
You are class!
But what is my K/D ratio and FK/FD ratio?
My K/D ration is: 2.0
Im a good player! I can get 1 kill for every death!
My FK/FD ratio is: 3.0
Im so good at getting the first kill in the round and not dying first!
What about my headshot to legshot ratio?
Could not find the heashot to legshot ratio. Error: division by zero