Question: for this program. i want the program to add the total points printed out when user enters 2. example: when user enters 2, it should





POINT_1_SHOTS = 1 POINT_2_SHOTS =2 def main( ): name_match = "" shots_attempted =0 percent_shots =0.00 option =0 ADD_MATCH =1 QUIT =2 print_menu() option = get_option(option) while(option !=2 ): if option =1 : print_welcome() name_match = get_match_name( ) shots_attempted = get_attempted_shots( ) POINT_1_SHOTS = get_point_1_shots () POINT_2_SHOTS = get_point_2_shots () percent_shots = calc_percent_shots ( shots_attempted ) print_percent_shots(percent_shots) print_points() print_menu() option = get_option(option) else: print_goodbye(name_match) \#Functions def print_menu(): This function prints a menu to the user giving them list of options to choc from "n print("1. Enter 1 to add match") print("2. Enter 2 to quit") def get_option(option): option is defined and passed here. option is input, returned, and stored in get_option() wnw. option = int(input( "Enter your option: ")) return option def print_welcome(): " function that prints welcome message uu print( "Welcome to by basketball game. In") def get_match_name(): " "n this function will define name_match, ask for the name match, and return i "n" name_match =nn name_match = input ("Enter name of match: ") return name_match def get_attempted_shots( ): "n" this function will ask for the attempted shots and return it "" return int(input("Enter number of shots you want to attempt: ")) def get_point_1_shots(): This function will ask for 1 point shots and return it in the same line return int( input( "Enter number of 1 point shots made: ")) def get_point_2_shots(): This function will ask for 1 point shots and return it in the same line "*" return int( input( "Enter number of 2 point shots made: ")) def calc_percent_shots( shots_attempted): function below passes three arguments, percent_shots is defined to store calculation, then clculated value will be returned "n" percent_shots =0.00 percent_shots =( POINT_1_SHOTS + POINT_2_SHOTS )/ shots_attempted return percent_shots This function will print the calculated value. Calculated value in function above, mutiply that value by 100 and format it. " "" print(" ", "You made ", "\{:.2f\}". format (percent_shots * 100), " \& of Attempted shots", sep="") def print_points(): This function will pass point_1_shots and point_2_shots as arguments. total_points is defined and will store the addition and multiplication of two variables. Instead of returning and printing, I put them into one function so it looks more simplified n n n total_points =0 total_points = POINT_1_SHOTS 1+ POINT_2_SHOTS 2 print ("You scored ", total_points, "points", " ", sep="") def print_goodbye(name_match): Function below will print a goodbye message while passing the name_match as an argument so the console can print it. " print("Thanks for playing ", name_match, sep="") main() 1. Enter 1 to add match 2. Enter 2 to quit Enter your option: 1 Welcome to by basketball game. Enter name of match: name Enter number of shots you want to attempt: 30 Enter number of 1 point shots made: 1 Enter number of 2 point shots made: 2 You made 10.00% of Attempted shots You scored 5 points 1. Enter 1 to add match 2. Enter 2 to quit Enter your option: 1 Welcome to by basketball game. Enter name of match: and Enter number of shots you want to attempt: 25 Enter number of 1 point shots made: 1 Enter number of 2 point shots made: 3 You made 12.00% of Attempted shots You scored 5 points 1. Enter 1 to add match 2. Enter 2 to quit Enter your option: 2 Thanks for playing and
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
