dimanche 25 avril 2021

imbedded IF loops [closed]

I am trying to make a scouting tool, using a menu interface (no GUI yet) for selection eligibility in a sports team. My current output is below:

def main():
    choice = printMenu()
    choice

def printMenu ():
    print("Playing Statistics Calculator")
    print("A: Positions in Basketball")
    print("B: Key Performance Indicators for positions")
    print("C: Calculate your average-per-game statistics")
    print("D: Compare your statistics to other players in your position")
    print("X: Exit")

main()

selection = input("Please choose a selection: ")

if selection == "A":
    print("Centre", "Point Guard", "Power Forward", "Shooting Guard", "Small Forward")
elif selection == "B":
    print("Centre - Blocks, Rebounds and Scoring ability")
    print("Point Guard - Assists, Turnovers and Assist-to-Turnover Ratio")
    print("Power Forward - Rebounds per game and Scoring ability")
    print("Shooting Guard - Field Goal Percentage, Points per game, 3-Point Goal")
    print("Percentage, Assists and Rebounds\Small Forward - Rebounds, Assists and Scoring ability")
# currently thats the only outcomes I have assigned, but will get there soon    
else:
    print("try again")
    main()
    input("Please choose a selection: ")

I have run into 3 major questions that I am stuck on:

  1. Everything works as intended, until the else statement, where I want it to loop back and re-do the menu, where the input goes to an option, rather than just typing the letter, as it does now.

  2. Menu Option A and Menu Option B are as they need to be (if they have to be separate), but Menu Option C relies on the position and Key Performance Indicator (KPI) data in the above parts, to not give superfluous information (ie. only showing variables [B] that are relevant to the player's position [A]). Ideally A+B can be together, where the player can go:

  • if A is selected in initial menu, it gives options to select a position -> then user selects a position -> if Centre is selected, it will show the 4 KPIs relevant to the centre position

And then afterwards combining A + C as:

  • if C is selected in inital menu, it prompts user to select position -> once selected, 5 prompts will appear, 1 asking for the number of games played in last season, then the other 4 pertaining to the KPIs (where a calculation will be made for average per game).

This will then turn into Menu Option A being position and important KPI, and Menu Option B being calculating the user's statistics of the KPIs. I have tried to do the A + B style, however, I have had no luck with making the imbedded if statements, with the 2nd menu just typing my response rather than choosing an option, hence why they are currently separated.

  1. The comparison (current Menu option D) will be easy enough to do, as I will subtract the user's average from league's average, thus if it is negative, they are below average, etc. However, I am not sure how I can store data to compare it. I assume the best way is through a list but I am not sure (I have added an example of some of my data below):
KPI League Mean (per game)
2-Point Goal 1.75
3-Point Goal 0.61
Blocks 4.23
Rebounds 5.01

If you guys can help with any or all of these, I would really appreciate the help! Thanks :)

Aucun commentaire:

Enregistrer un commentaire