This Python module will be menu driven
and use conditions to check user input in order to
determine which operation to perform based on the
user’s menu selection.
The output should look like the attached example output.
The menu will have the following selections
(NOTE: all menu selections by the user should not be case
sensitive)
:
1.
‘CC’ – Character Count
a.
This operation will prompt the user for a string
b.
The number if characters will be counted in the string
c.
Display the number of characters in the string to the user
2.
‘RV’ – Reverse
a.
This operation will prompt the user for a string
b.
The string will be reversed
c.
Display the reversed string to the user
3.
‘M5’ – Multiply by 5
a.
This operation will prompt the user for a choice between ‘N’ for a number and ‘S’ for a String
b.
If ‘N’ is entered:
i.
Prompt the user to enter a number
ii.
The number will then be multiplied by 5
iii.
Display the result of multiplying the number by 5 to the user
c.
If ‘S’ is entered:
i.
Prompt the user to enter a string
ii.
The string will then be multiplied by 5
iii.
Display the result of multiplying the string by 5 to the user
d.
If any character other than ‘N’ or ‘S’ is entered:
i.
Display the message ‘You entered an invalid option!’ to the user
e.
NOTE: all input by the user for this menu option should not be case sensitive
4.
‘MC’
–
Middle Character(s)
a.
This operation will prompt the user for a string
b.
If the
string has an odd number of characters:
i.
Determine the middle character of the string
ii.
Display the single middle character to the user
c.
If the string has an even number of characters:
i.
Determine the middle characters of the string
ii.
Display the 2 middle characters to the user
5.
‘EX' – Exit
a. This operation will display ‘Goodbye!’ to the user
NOTE
:
If any menu selection other than ‘CC’, ‘RV’, ‘M5’, ‘MC’, or ‘EX’ or the lowercase version of these is entered:
• Display the message ‘You entered an invalid menu selection’ to the user
• At the end of the Python module print the string ‘End of Project #3'
THE PYTHON CODE IS :
# character count def CC(): print("Input String") string = input() # len is used to find length of a string in python number_of_characters = len(string) print("Number of characters in the string is :", number_of_characters," ") # Reverse String def RV(): print("Input String") string = input() reversed_string = "" # iterate through all characters in the string and store it in # reversed manner in reversed_string for i in string: reversed_string = i + reversed_string print("The reversed string is :", reversed_string," ") # multiply by 5 def M5(): print("Enter ‘N’ for a number and ‘S’ for a String") choice = str(input()) if choice == 'N' or choice == 'n': print("Enter a number") n = int(input()) n = n * 5 print("The number multiplied by 5 is :", n," ") elif choice == 'S' or choice == 's': print("Enter a string") s = input() s = s * 5 print("The string multiplied by 5 is :", s," ") else: print("You entered an invalid option! ") # middle character(s) def MC(): print("Input String") string = input() mc = '' length = len(string) # // is used for integer division in python i.e. # 5/2 = 2.5 and 5//2 = 2 in python if length % 2 != 0: # middle character is in index = length//2 in a odd length string mc = string[length // 2] print("Middle Character :", mc," ") else: # middle characters is in indexes = length//2-1 and length//2 in # an even length string mc = string[length // 2 - 1] + string[length // 2] print("Middle Characters :", mc," ") def main(): choice = "" while True: print('Enter your choice !') print('Enter CC for Character Count . Enter RV for Reverse .') print('Enter M5 for Multiply by 5 . Enter MC for Middle Character(s) .') print('Enter EX to Exit . ') choice = input() if choice == 'CC' or choice == 'cc': CC() elif choice == 'RV' or choice == 'rv': RV() elif choice == 'M5' or choice == 'm5': M5() elif choice == 'MC' or choice == 'mc': MC() elif choice == 'EX' or choice == 'ex': print('Goodbye!') break; else: print('You entered an invalid menu selection ') break; print('End of Project #3') if __name__ == '__main__': main()
CONSOLE INPUT AND OUTPUT OF THE PROGRAM :
This Python module will be menu driven and use conditions to check user input in order...
Write the Script in Python. courseCategories = ["Mathematics","Computer Science","Business","Economics","Literature","Art","Music"] Sample of the output. It should look same as the output. 'SR' - Sort a. b. 1. This operation will display the list before being sorted Display the list to the user after being sorted 2. 'CC-Character Count This operation will prompt the user for an index as an integer that will be the location to reference in the list If the integer is less than 0 or greater than the...
extra credit 1 Write a program that will display the following menu and prompt the user for a selection: A) Add two numbers B) Subtract two numbers C) Multiply two numbers D) Divide two numbers X) Exit program The program should: display a hello message before presenting the menu accept both lower-case and upper-case selections for each of the menu choices display an error message if an invalid selection was entered (e.g. user enters E) prompt user for two numbers...
Menu-driven programs will display the menu options to the user and then prompt them for a menu choice. This program will display the following menu in the following format: Calculator Options: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the area of a trapezoid Calculate the area of a sphere Exit Enter your choice (1-6) Once the user enters a choice for the menu, the program should use a...
‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...
This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...
C++ please! (1) Prompt the user to enter the name of the input file. The file will contain a text on a single line. Store the text in a string. Output the string. Ex: Enter file name: input1.txt File content: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! (2) Implement a PrintMenu() function,...
Using Python’s tkinter Graphical User Interface (GUI) module create a Python program to input the number of each type of coin a user has in their possession and then compute and display the total dollar and cents value of these coins. Your solution must accommodate Dollar, Half-Dollar, Quarter, Dime, Nickel, and Penny coins. Your solution must be robust against invalid inputs (i.e., negative value entered into any coin entry widget).
Methods: Net beans IDE Java two methods. Identifier: calculateScore(String word) Parameters: word – the word for which you should calculate the points in Scrabble Return Value: int – the number of points for the parameter word Other: This method should be static. This method should use the following system for scoring: 0 – blank 1 – e, a, i, o, n, r, t, l, s, u 2 – d, g 3 – b, c, m, p 4 – f, h,...
C++ (1) Prompt the user to enter a string of their choosing (Hint: you will need to call the getline() function to read a string consisting of white spaces.) Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!...
(1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! You entered: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews...