Question: Python programming Write a program containing 2 functions and a main program that calls those functions to test them thoroughly. Step 1: Create a FUNCTION

Python programming

Write a program containing 2 functions and a main program that calls those functions to test them thoroughly.

Step 1: Create a FUNCTION called createMenu that creates a STRING which will produce the following output when printed by the main program. The function should accept TWO parameters: menuHeading (a string) and optionList (a list of strings). It should NOT PRINT ANYTHING it simply RETURNS a string.

Python programming Write a program containing 2 functions and a main program HINT: initialize tmp to be an empty string, then use a loop that goes through the optionList one string at a time, concatenating a count, the string, and a newline character ( ) onto tmp , Return tmp when the loop is finished.

Step 2: Create another FUNCTION called getValidInput that accepts 3 parameters:

msg: a string that tells the user what they should be entering

start: a POSITIVE integer

end: a POSITIVE integer that is greater than start

This function should continue to ask the user to enter a number (using the msg parameter to describe what kind of number theyll be entering) until they type an integer that is in the range start to end, including both. If they enter a punctuation character, a letter, or something that isnt a number, print an error message asking them to try again. The function should RETURN a valid number.

Example main program to test these functions:

message = Enter a test score in the range 1-100 sc = getValidInput(message, 1, 100) print(Your test score: , sc, was in the proper range) prompt = Enter your guess 1 for heads, 2 for tails guess = getValidInput(prompt, 1,2) if guess == 1: print(You guessed heads) else: print(You guessed tails)

menuOptions = [ Add, Subtract,Quit] mainMenu = createMenu(Arithmetic Practice, menuOptions) print(mainMenu) optionList = [Savings Account, Checking Account, IRA Account, Exit] myMenu = createMenu(Bank Accounts, optionList) print(myMenu)

Employee Maintenance 1) Add a New Employee 2) Print Employee Roster 3) Delete an Employee 4) Sort List by Last Name 5) Exit. Please choose an item from the menu by typing its number

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!