Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I can't figure out why it's not prompting a message for the match name and the other inputs. I need some help with that. PLEASE

I can't figure out why it's not prompting a message for the match name and the other inputs. I need some help with that. PLEASE DO NOT USE GLOBAL VARIABLES!!!

POINT_1_SHOTS = 1 POINT_2_SHOTS = 2 ADD_MATCH = 1 QUIT = 2

def main(): total_points = 0 matches_count = 0 name_match = "" shots_attempted = 0 percent_shots = 0.00 option = 0

# remove the extra spaces.. Only one blank line in functions print_menu() get_option() if option == QUIT: print(" Goodbye") while(option != QUIT): if option == ADD_MATCH: print_welcome() name_match = get_match_name() shots_attempted = get_attempted_shots() point_1_shots = get_point_shots("Enter number of 1 point shots made: ") point_2_shots = get_point_shots("Enter number of 2 point shots made: ") # you don't change the constants, you will use these to calculate the score # make other variables to hold the number of one point or two point shots

percent_shots = calc_percent_shots(shots_attempted, point_1_shots, point_2_shots) print_percent_shots(percent_shots)

total_points += calc_total_points(point_1_shots, point_2_shots) matches_count += 1 print_match_name(name_match) print_menu() get_option() else: print_goodbye(name_match, total_points, matches_count)

#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 is defined and passed here. option is input, returned, and stored in return: option as integer """ option = 0 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 return: match name """ name_match = "" name_match = input("Enter name of match: ") return name_match

def get_attempted_shots(): """ this function will ask for the attempted shots return: attempted shots as integer """ shots_attempted = 0 shots_attempted = int(input("Enter number of shots you want to attempt: ")) return shots_attempted

def get_point_shots(): """ This function will ask for 1 point shots and return it in the same line """ #declare a variable to hold shots, not a constant

shots = 0 shots = int(input()) return shots

def calc_percent_shots(shots_attempted, point_1_shots, point_2_shots):

""" :param : shots attempted, point 1 and 2 shots returns calc of percent shots """ 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="")

# pass variales with number of 1 and 2 point shots, use the constatns in the calc

def calc_total_points(point_1_shots, point_2_shots): """ :param : point 1 and 2 shots returns calc of point shots """ # the constatns should contain the 1 and 2, use those to calculate the score total_points = POINT_1_SHOTS * 1 + POINT_2_SHOTS * 2 print("You scored {} points ".format(total_points)) return total_points

def print_goodbye(name_match, total_points, matches_count):

""" Function below will print a goodbye message while passing the name_match as an argument so the console can print it. In the goodbye message, it will also print out the total points and divide by total_matches """

print(" Thanks for playing {}!".format(name_match)) print(" You scored a total of {} points in {} matches.".format(total_points, matches_count)) print("That's an average of {:.1f} points per game.".format(total_points/matches_count))

def print_match_name(name_match): print("Thanks for playing", name_match)

main()

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago