Question

In: Computer Science

in PYTHON - Kyle Lowry is trying to calculate his career statistics thus far in his...

in PYTHON - Kyle Lowry is trying to calculate his career statistics thus far in his illustrious career. Write a program that prompts the user for Lowry’s average points per game (ppg) in EACH of his 14 seasons in the NBA. The program will display the number of seasons in which he averaged 15 ppg or more, his career average, and his best season (SEASON # in which he had his highest ppg).

Solutions

Expert Solution

SOLUTION

Kyle Terrell Lowry (born March 25, 1986) is an American professional basketball player for the Toronto Raptors of the National Basketball Association (NBA). With the Raptors, he has been a six-time NBA All-Star and was named to the All-NBA Third Team in 2016. Lowry won an NBA championship with Toronto in 2019, their first title in franchise history. He was a member of the U.S. national team that won a gold medal in the 2016 Summer Olympics.

import pandas as pdclass TeamStats():    def getDataFrame(filename):
         data = pd.read_csv(filename) 
         return data
         #stores the CSV contents as a DataFrame object and returns    def getStat(data, row, column):
        stat = data.at[row,column]
        return stat
        #retrieves the statistic from the desired cell (ex. season,        PPG)
import TeamStats as tsdata_playoffs_1819 = ts.getDataFrame(“201819RaptorsPlayoffsPerGame.csv”)
#store CSV contents in DataFrame Objectdata_playoffs_1819.set_index(“Player”,inplace=True)
#Set the index (column of table) we want (ex. Player)Kawhi_PTS = ts.getStat(data_playoffs_1819, ‘Kawhi Leonard’, ‘PTS/G’)
#Retrieves and stores Kawhi's PTS/G in a variable
import matplotlib.pyplot as plt
import numpy as np# This function will graph DeMar and Kawhi's stat's side by sidedef graphDeMarKawhiAdvanced(demar_stats, kawhi_stats):      
      stats = [“VORP”, “OWS”, “DWS”, “WS”]
      ind = np.arange(len(stats))
      # Creates a numpy Array in the range of the number of elements             in the list  
      width = .35              plt.bar(ind, demar_stats, label = ‘DeMar DeRozan’, color = ‘red’, width = width, zorder = 2)      plt.bar(ind + width, kawhi_stats, label = ‘Kawhi Leonard’, color = ‘blue’, width = width, zorder = 2)
      #both of those lines will plot both of the player's stats      plt.xticks(ind+(width/2), stats)
      # Gives each stat a label on the x-axis
      plt.title(‘DeMar Derozan 2018 Playoffs v. Kawhi Leonard 2019 Playoffs (Advanced)’)
      # Gives the graph a title
      plt.xlabel(‘Advanced Stats')
      # Label of the x-axis
      plt.legend()
      # displays a legend for the graph

Related Solutions

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT