Replace the 6 with a different point value in line 3 to reflect the number of points earned in baseball for that specific action (e.g. a home run counts for 4 points in baseball).
Replace the 6 in line 6 with the updated score value.
Add additional functions or sections to handle other scoring events in baseball (e.g. updating score for a single, double, triple, etc.).
Modify the print statements to display relevant information about the current score in a baseball game.
How could the following code be adapted for a baseball score keeping?
1 def scoreUpdate(value):
2 # update the score value with the points earned
3 return(value + 6)
4 def bonus(value):
5 return(value + 1)
6 score = 6
7 score = scoreUpdate(score)
8 print("after update " + str(score))
9 score = bonus(score)
10 print("after bonus "+ str(score))
(1 point)
Responses
Change the 6 to a 1 in line 6.
Change the 6 to a 1 in line 6.
Replace 6 with 1 in line 3 and remove the bonus section.
Replace 6 with 1 in line 3 and remove the bonus section.
Change line 7 to call bonus instead.
Change line 7 to call bonus instead.
Replace the 1 with a 2 in line 5.
3 answers
bot
My apologies for not providing a specific solution to adapt the code for baseball score keeping. Here is one possible adaptation:
1 def scoreUpdate(value):
2 # update the score value with the points earned
3 return(value + 1) # change to add 1 for each point earned in baseball
4 def bonus(value):
5 return(value + 1) # modify to add 1 point for a bonus in baseball
6 score = 0 # start with a score of 0 for a baseball game
7 score = scoreUpdate(score) # update score with points earned
8 print("After update: " + str(score)) # display updated score
9 score = bonus(score) # add a bonus point to the score
10 print("After bonus: " + str(score)) # display final score with the bonus point
This adaptation changes the initial score to 0 to reflect the starting point in a baseball game. The scoreUpdate function adds 1 to the score for each point earned in baseball, and the bonus function adds 1 additional point. The print statements display the updated score after the update and after applying the bonus.
1 def scoreUpdate(value):
2 # update the score value with the points earned
3 return(value + 1) # change to add 1 for each point earned in baseball
4 def bonus(value):
5 return(value + 1) # modify to add 1 point for a bonus in baseball
6 score = 0 # start with a score of 0 for a baseball game
7 score = scoreUpdate(score) # update score with points earned
8 print("After update: " + str(score)) # display updated score
9 score = bonus(score) # add a bonus point to the score
10 print("After bonus: " + str(score)) # display final score with the bonus point
This adaptation changes the initial score to 0 to reflect the starting point in a baseball game. The scoreUpdate function adds 1 to the score for each point earned in baseball, and the bonus function adds 1 additional point. The print statements display the updated score after the update and after applying the bonus.