Question

Can you please Test and debug the program below using the following specifications? Many thanks! Create...

Can you please Test and debug the program below using the following specifications? Many thanks!

Create a list of valid entries and the correct results for each set of entries. Then, make sure that the results are correct when you test with these entries.

Create a list of invalid entries. These should include entries that test the limits of the allowable values. Then, handle the invalid integers (such as negative integers and

unreasonably large integers). In addition, make sure the user can't enter data that doesn't make sense (such as a player having more hits than at bats).

Don't attempt to handle invalid entries that cause exceptions, such as the user entering a string like "x" for an integer value. You can do that after you read chapter 8.

Tip: whenever needed please provide screenshots of your debugging. Thorough Test Plan also would be a BIG plus.

def display_menu():

  print("+"*50)

  print(" \t\tBaseball Team Manager")

  print("MENU OPTIONS")

  print("1 - Calculate batting average.")

  print("2 - Exit program.")

  print("+"*50)

  

def convertBat():

  print("Calculate batting average.")

  num_at_bats = int(input("Enter official number of at bats: "))

  num_hits = int(input("Enter number of hits: "))

  average = num_hits/num_at_bats

  print("Batting average:", round(average,3))

def main():

  while True:

    display_menu()

    rk = int(input("Menu Option : "))

    if (rk == 1):

      convertBat()

    elif(rk == 2):

      break

    else:

      print("Not a valid option. Please try again.")

  print("Bye!")

   

main()

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Souace code pointe C- calculat batting avege main: menu-optf ont) eccept menu ophon o prmt Not a vaid optton pleace g againmenu optfon D Pf menu-option=- \ Contmua on ea K

Add a comment
Know the answer?
Add Answer to:
Can you please Test and debug the program below using the following specifications? Many thanks! Create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================")...

    Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================") print(" Baseball Team Manager") print("MENU OPTIONS") print("1 - Calculate batting average") print("2 - Exit program") print("=====================================================================")    def convert_bat(): option = int(input("Menu option: ")) while option!=2: if option ==1: print("Calculate batting average...") num_at_bats = int(input("Enter official number of at bats: ")) num_hits = int(input("Enter number of hits: ")) average = num_hits/num_at_bats print("batting average: ", average) elif option !=1 and option !=2: print("Not a valid...

  • Chapter 05 Case study Baseball team For this case study, you’ll use the programming skills that...

    Chapter 05 Case study Baseball team For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then, after you...

  • Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming...

    Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then,...

  • Can you please enter this python program code into an IPO Chart? import random def menu():...

    Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...

  • Help me figure this problem out, please. Use a list to store the players Update the...

    Help me figure this problem out, please. Use a list to store the players Update the program so that it allows you to store the players for the starting lineup. This should include the player’s name, position, at bats, and hits. In addition, the program should calculate the player’s batting average from at bats and hits. Console ================================================================ Baseball Team Manager MENU OPTIONS 1 – Display lineup 2 – Add player 3 – Remove player 4 – Move player 5...

  • Something is preventing this python code from running properly. Can you please go through it and...

    Something is preventing this python code from running properly. Can you please go through it and improve it so it can work. The specifications are below the code. Thanks list1=[] list2=[] def add_player(): d={} name=input("Enter name of the player:") d["name"]=name position=input ("Enter a position:") if position in Pos: d["position"]=position at_bats=int(input("Enter AB:")) d["at_bats"] = at_bats hits= int(input("Enter H:")) d["hits"] = hits d["AVG"]= hits/at_bats list1.append(d) def display(): if len(list1)==0: print("{:15} {:8} {:8} {:8} {:8}".format("Player", "Pos", "AB", "H", "AVG")) print("ORIGINAL TEAM") for x...

  • Using python 3.6 How do I incorporate 0 or negative input to raise an error and...

    Using python 3.6 How do I incorporate 0 or negative input to raise an error and let the user try again? like <=0 #loop to check valid input option. while True: try: choice = int(input('Enter choice: ')) if choice>len(header): print("Invalid choice!! Please try again and select value either:",end=" ") for i in range(1,len(header)+1): print(i,end=",") else: break choice = int(input('\nEnter choice: ')) except ValueError as ve:print('Invalid response, You need to select the number choice from the option menu') # Catch your...

  • Write a Python program that stores the data for each player on the team, and it...

    Write a Python program that stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. Questions: - Handle the exception that occurs if the program can’t find the data file. - Handle the exceptions that occur if the user enters a string where an integer is expected. - Handle the exception that occurs if the user enters zero for the number of at bats. - Thoroughly test the...

  • (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the...

    (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT