Question: It needs to be written in Python. I'm having a really hard time with this. I've written the whole program but every value I enter

It needs to be written in Python.

It needs to be written in Python. I'm having a really hard

time with this. I've written the whole program but every value I

I'm having a really hard time with this. I've written the whole program but every value I enter it says "invalid choice". please help.

This is what I have done:

def PrintPurpose(): print("Please choose from the menu.") print("============================") print("1: Draw a single bar of symbol") print("2: Print numbers from n to m") print("3: Draw a rectangle") print("4: Draw a right triangle") print("5: Quit") print("============================")

def DarBar(symbol,length): for i in range(0,length): print()

def PrintSequence(n,m): if n

def PrintRectangle(symbol,width,height): for i in range(0,height): for j in range(0,width): print(symbol) print() print()

def PrintTriangle(symbol,height): for i in range(0,height): for j in range(0,i+1): print(symbol) print() print()

def main():

while True: PrintPurpose() choice = input(print("Enter your choice: ") if choice == 1 symbol = raw_input("Enter the symbol for bar") length = input("Enter the length of the bar") DrawBar() elif choice == 2: n = input("Enter first bound") m = input("Enter second bound") PrintSequence(n,m) elif choice == 3: symbolR = raw_input("Enter the symbol for rectangle") widthR = input("Enter the width of the rectangle") heightR = input("Enter height of the rectangle") PrintRectangle(symbolR, widthR, heightR) elif choice == 4: symbolT = raw_input("Enter the symbol for triangle") heightT = input("Enter height of the triangle") PrintTriangle(symbolT, heightT) elif choice == 5: return else: print( choice, "is an invalid choice")

Program details and requirements: 1 Print the purpose of the program. 2) Display a menu and process the user's choices as shown a sample run above 3) If the user fails to enter a valid choice, the program must output an error message (as shown in the sample run) and then repeat the request until the user enters a valid choice. Use a while loop.) 4) Your program must process the user's choices until the user wants to quit. (the same while loop.) 5) Use a multi-way if (elif statement in processing the option. 6) The while statements and multi-way if statements should NOT contain redundant logical expressions. 7) The program must have a beginning comment block and proper documentation as shown in the class notes for OLA #1. Your program must define and call the following functions. You may define other functions. main ( ) # main function PrintPurpose( ) # prints the purpose of the program DrawBar(symbol, length) # prints a horizontal bar of symbol which is length long. PrintSequence(first, second) 8) # prints a sequence of numbers. If first is smaller than second, it prints in ascending order. # Otherwise, it prints in descending order gle(symbol, width, height) # prints a rectangle filled with symbol with the size of width by height (should call Draw:Bar) PrintTriangle(symbo height) # prints a right triangle filled with symbol with the size of height (should call Draw,Bar) 1) The program must have a beginning comment block and a proper documentation as shown below: Function Purpose: prints a horizontal bar of symbol which is length long synbol (to fill), length (of the horizontal bar) Parameters: Post-con def DrawBar (symbol, length) Pre-condition symbol and length have appropriate values, length >0 A horizontal bar has been printed dition

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!