4.1 You are required to implement a menu-driven application using Python that performs operations on strings based on user input. The program should display a menu of options and execute the corresponding operation based on the user's selection. The application should include the following operations: I. Concatenate two strings. II. Convert a string to uppercase. III. Convert a string to lowercase. IV. Exit Each operation should be implemented as a separate function. You need to define these functions and integrate them into a menu-driven application. The application should continue displaying the menu until the user chooses to exit it. The user's input should be validated to ensure that only valid menu options are accepted. [20 marks]
Added by Aitor R.
Close
Step 1
Step 1: Define the function for concatenating two strings. Show more…
Show all steps
Your feedback will help us improve your experience
Shelayah Robinson and 78 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
In Python 3, which functions are used to accept input from the user? 1. input() 2. raw_input() 3. raw_input() 4. string()
Shelayah R.
Write a program that reads string that consists of (Upper case, Lower case, and Digits) including white spaces from the keyboard until user enters '#'. Then, your program should count total number of characters, uppercase letters, lowercase letters, and digits. Example of a possible input: Hello, welcome to Tempe. Today's temperature is 117!# Approach: * First write the algorithm * Come up with a flowchart that represents the program logic. * verify your approach with sample data set * Develop the program and test it for various inputs Hint: You will need to use selection within the while loop. <cctype> library has character related functions (Appendix G2,3,4 - CD). Will be discussed during the lab. Also, string data type has a method length() which gives how many characters are stored in the string.
Supreeta N.
2.2 Write a program that uses input to prompt a user for their name and then welcomes them. Note that input will pop up a dialog box. Enter Sarah in the pop-up box when you are prompted so your output will match the desired output. Code I wrote: name = input('Enter your name:') print('Hello Sarah') I got the desired output, which is: Hello Sarah. The error message was that I actually had to prompt for the user's name. How do I do this? Desired output: Hello Sarah Programming language: Python Original sample code: # The code below almost works name = input("Enter your name") print("Howdy")
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD