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...

  • Case Study Baseball Team Manager For this case study, you’ll use the programming skills that you...

    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, after you complete...

  • 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...

  • How can I modify my program to accept a list of integers (up to 20 entries)...

    How can I modify my program to accept a list of integers (up to 20 entries) from the user into a list and prints the numbers entered by the user in ascending order, their sum and their average. The program then stops when the user inputs -100 as a number to search. #function that returns largest number def max(numOne,numTwo,numThree): if(numOne > numTwo and numOne > numThree): return numOne elif(numTwo > numOne and numTwo > numThree): return numTwo elif(numThree > numOne...

  • 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...

  • *KEEP IT SIMPLE PLEASE* Write a program that allows the user to convert any integer number...

    *KEEP IT SIMPLE PLEASE* Write a program that allows the user to convert any integer number to Roman numeral and the other way around. - You should create and print a menu that allows the user to select either Roman to Int or Int to Roman. - If one option is selected then you should promote the user to enter the number and then you print the equivalence in the other system. - Validate input, i.e Roman numerals should be...

  • USING PYTHON - Write a program that calls a function that prompts the user to enter...

    USING PYTHON - Write a program that calls a function that prompts the user to enter a real number. The function should verify that the user entered a valid real number, and should prompt the user to re-enter any invalid input. After a valid real number has been entered, the function should return the number as a number. To test your function, from a main function, call the function two separate times and print the sum of the two numbers...

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