Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to show users a set of choices, and then respond to those choices until they choose to quit ('q'). For each

imageimage

Write a program to show users a set of choices, and then respond to those choices until they choose to quit ('q'). For each option, write a function. Each function should do as follows: halfstring() - Ask the user to enter the string of even length. Your function should display the last half string. For example, HelloWorld should display World. first three_char() - As the k user to enter the string. Your function should display the string made up of the first three characters. For example, HelloWorld will display Hel. If the string is shorter than length 3, display whatever there is, so "He" yields "He", and the string is empty, then display "Empty String." When a user enters 'q', it should display "See you later". See the sample output. 1 Welcome! What would you like to do? [1] Enter 1 to print Half string. [2] Enter 2 to print First three characters. [9] Enter 'q' to print quit. Enter your options: 1 Please input string of even length: HelloWorld World [1] Enter 1 to print Half string. [2] Enter 2 to print First three characters. [q] Enter 'q' to print quit. Enter your options: 1 Please input string of even length: hello Please enter an even string. [1] Enter 1 to print Half string. [2] Enter 2 to print First three characters. [q] Enter 'q' to print quit. Enter your options: 2 Please enter a string: test tes [1] Enter 1 to print Half string. [2] Enter 2 to print First three characters. [9] Enter 'q' to print quit. Enter your options: 2 Please enter a string: tes tes [1] Enter 1 to print Half string. [2] Enter 2 to print First three characters. [9] Enter 'q' to print quit. Enter your options: 2 Please enter a string: Empty string. [1] Enter 1 to print Half string. [2] Enter 2 to print First three characters. [q] Enter 'q' to print quit. Enter your options: q See you later.

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

Step: 1

Heres a Python program that implements the functionality you described python def halfstring string ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Architecture A Quantitative Approach

Authors: John L. Hennessy, David A. Patterson

6th Edition

0128119055, 978-0128119051

More Books

Students also viewed these Programming questions