Question

In Very Basic Python: Kyle Lowry is trying to calculate his career statistics thus far in...

In Very Basic 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). [

Homework Answers

Answer #1

CODE:

#DECLARE A LIST TO STORE AVERAGE POINTS PER GAME(PPG) OF 14 SEASONS

average_ppg=[]

#ITERATE FOR LOOP 14 TIMES TO INPUT THE AVERAGE PPG FOR EVERY SEASON

for i in range(14):

  #INPUT AVERAGE PPG IN EACH SEASON

  #INPUT STATEMENT TO PROMPT USER

  str1="Enter the average points per game(ppg) in season ",(i+1),": "

  avg_ppg=int(input(str1))

  #ADD THE INPUT TO THE LIST TO FIND THE CAREER STATISTICS LATER

  average_ppg.append(avg_ppg)

#INITIALIZE A VARIABLE TO COUNT THE NUMBER OF SEASONS IN WHICH LOWRY AVERAGED 15 PPG OR MORE

count_average=0

#INITAILIZE A VARIABLE TO FIND AVERAGE PPG OF ALL 14 SEASONS

career_average=0

#FIND THE BEST SEASON OF ALL THE SEASONS

best_season=0

#CALCULATE BEST SEASON USING THE HIGHEST PPG OF ALL THE 14 SEASONS

highest_ppg=0

for i in range(14):

  #CHECK IF AVERAGE PPG OF ANY SEASON IS GREATER THAN OR EQUAL TO 15 THAN INCREMENT COUNT

  if average_ppg[i]>=15:

    count_average+=1

  #SUM AVERAGE PPG OF ALL 14 SEASONS

  career_average+=average_ppg[i]

  #FIND THE BEST SEASON HAVING HIGHEST PPG OF ALL THE SEASONS

  if highest_ppg<average_ppg[i]:

    highest_ppg=average_ppg[i]

    best_season=i+1

#CALCULATE CAREER AVERAGE OF 14 SEASONS

career_average/=14

#PRINT ALL THESE CALCULATED STATISTICS

print("The number of seasons in which Kyle Lowry averaged 15 ppg or more: ",count_average)

print("The career average of Kyle Lowry: ",career_average)

print("The Best Season of Kyle Lowry is Season: ",best_season," with highest ppg of: ",highest_ppg)

CODE SNIPPET:

#DECLARE A LIST TO STORE AVERAGE POINTS PER GAME(PPG) OF 14 SEASONS
average_ppg=[]
#ITERATE FOR LOOP 14 TIMES TO INPUT THE AVERAGE PPG FOR EVERY SEASON
for i in range(14):
  #INPUT AVERAGE PPG IN EACH SEASON
  #INPUT STATEMENT TO PROMPT USER
  str1="Enter the average points per game(ppg) in season ",(i+1),": "
  avg_ppg=int(input(str1))
  #ADD THE INPUT TO THE LIST TO FIND THE CAREER STATISTICS LATER
  average_ppg.append(avg_ppg)

#INITIALIZE A VARIABLE TO COUNT THE NUMBER OF SEASONS IN WHICH LOWRY AVERAGED 15 PPG OR MORE
count_average=0
#INITAILIZE A VARIABLE TO FIND AVERAGE PPG OF ALL 14 SEASONS 
career_average=0
#FIND THE BEST SEASON OF ALL THE SEASONS
best_season=0
#CALCULATE BEST SEASON USING THE HIGHEST PPG OF ALL THE 14 SEASONS
highest_ppg=0
for i in range(14):
  #CHECK IF AVERAGE PPG OF ANY SEASON IS GREATER THAN OR EQUAL TO 15 THAN INCREMENT COUNT
  if average_ppg[i]>=15:
    count_average+=1
  #SUM AVERAGE PPG OF ALL 14 SEASONS
  career_average+=average_ppg[i]
  #FIND THE BEST SEASON HAVING HIGHEST PPG OF ALL THE SEASONS
  if highest_ppg<average_ppg[i]:
    highest_ppg=average_ppg[i]
    best_season=i+1
#CALCULATE CAREER AVERAGE OF 14 SEASONS
career_average/=14
#PRINT ALL THESE CALCULATED STATISTICS
print("The number of seasons in which Kyle Lowry averaged 15 ppg or more: ",count_average)
print("The career average of Kyle Lowry: ",career_average)
print("The Best Season of Kyle Lowry is Season: ",best_season," with highest ppg of: ",highest_ppg)

OUTPUT:

Enter the average points per game(ppg) in season ,1,: 15
Enter the average points per game(ppg) in season ,2,: 5
Enter the average points per game(ppg) in season ,3,: 15
Enter the average points per game(ppg) in season ,4,: 5
Enter the average points per game(ppg) in season ,5,: 5
Enter the average points per game(ppg) in season ,6,: 5
Enter the average points per game(ppg) in season ,7,: 3
Enter the average points per game(ppg) in season ,8,: 15
Enter the average points per game(ppg) in season ,9,: 20
Enter the average points per game(ppg) in season ,10,: 21
Enter the average points per game(ppg) in season ,11,: 8
Enter the average points per game(ppg) in season ,12,: 6
Enter the average points per game(ppg) in season ,13,: 9
Enter the average points per game(ppg) in season ,14,: 14
The number of seasons in which Kyle Lowry averaged 15 ppg or more:  5
The career average of Kyle Lowry:  10.428571428571429
The Best Season of Kyle Lowry is Season:  10  with highest ppg of:  21

SUMMARY:

The above python code is written in a very basic manner and all the functionalities are explained in the comments of the program. The code is implemented using list to store all the average ppg of 14 seasons and for loop to process these and get all the required statistics. You can run this code online on google colab or any online compiler or softwares.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
CASE Wyatt Earp - The Buffalo Hunter F. Robert Jacobs, Indiana University The legend of Wyatt...
CASE Wyatt Earp - The Buffalo Hunter F. Robert Jacobs, Indiana University The legend of Wyatt Earp lives on largely based on his exploits as a gunfighter and Marshall of the frontier West in the 1880s. The classic tales of the shootout at the O.K. Corral in Tombstone or his sawed-off shotgun duel with Curly Bill are possibly the most celebrated gunfights of frontier history and cannot fail to stir the reader's imagination. Wyatt lived to be over 80 years...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...