Question
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()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started