Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In the last few exercises you've learned everything there is to know about heights and weights of baseball players. Now it's time to dive into
In the last few exercises you've learned everything there is to know about heights and weights of baseball players. Now it's time to dive into another sport: soccer.
You've contacted FIFA for some data and they handed you two lists. The lists are the following:
positions GKMAD
heights
Each element in the lists corresponds to a player. The first list, positions, contains strings representing each player's position. The possible positions are: GKgoalkeeperMmidfieldAattack and Ddefense The second list, heights, contains integers representing the height of the player in cm The first player in the lists is a goalkeeper and is pretty tall cm
You're fairly confident that the median height of goalkeepers is higher than that of other players on the soccer field. Some of your friends don't believe you, so you are determined to show them using the data you received from FIFA and your newly acquired Python skills. heights and positions are available as lists
Instructions
XP
Convert heights and positions, which are regular lists, to numpy arrays. Call them npheights and nppositions.
Extract all the heights of the goalkeepers. You can use a little trick here: use nppositions GK as an index for npheights. Assign the result to gkheights.
Extract all the heights of all the other players. This time use nppositions GK as an index for npheights. Assign the result to otherheights.
Print out the median height of the goalkeepers using npmedian Replace None with the correct code.
Do the same for the other players. Print out their median height. Replace None with the correct code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started