Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this program, I want the program to add the total points calculated and print them out when the user enters 2. When the user

For this program, I want the program to add the total points calculated and print them out when the user enters 2. When the user enters 2, it should print out You scored 29 points for two games. Thats an average of 14.5 points per game. A variable that adds all the total points and prints it. Another one to keep track of all the matches. I dont want to use global variables. Please keep this program as original as possible. I just want to add the total points calculation for all total points and a count variable to keep track of all matches.

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) """ This prints intro: Welcome Message """ #print_welcome() """ this gets user input regarding match's name """ #name_match = get_match_name() """ get input from user attempted shots, point 1 and point 2 shots """ #shots_attempted = get_attempted_shots() #POINT_1_SHOTS = get_point_1_shots() #POINT_2_SHOTS = get_point_2_shots() """ calculates percentage of shots made. passess the arguments so calculation can recognize these values """ #percent_shots = calc_percent_shots(shots_attempted) """ prints out the calculation results. these arguments are passed so they wouldn't have to be defined again. input by user is used to calculate by calling them as arguments """ #print_percent_shots(percent_shots) #print_points() """ prints goodbye message and name of match """ #print_goodbye(name_match) #Functions def print_menu(): """ This function prints a menu to the user giving them list of options to choose from """ 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() """ option = int(input("Enter your option: ")) return option def print_welcome(): """ function that prints welcome message """ print("Welcome to by basketball game. ") def get_match_name(): """ this function will define name_match, ask for the name match, and return it """ name_match = "" name_match = input("Enter name of match: ") return name_match def get_attempted_shots(): """ 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 """ percent_shots = 0.00 percent_shots = (POINT_1_SHOTS + POINT_2_SHOTS)/shots_attempted return percent_shots def print_percent_shots(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 """ 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()

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

Identify three types of physicians and their roles in health care.

Answered: 1 week ago

Question

Compare the types of managed care organizations (MCOs).

Answered: 1 week ago