1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Zepler [3.9K]
3 years ago
6

1. INTRODUCTION In this project, you will gain experience with many of the Python elements you’ve learned so far, including func

tions, repetition structures (loops), input validation, exception handling. and working with strings 2. PROBLEM DEFINITION Present the user with the following menu within a continuous loop. The loop will exit only when the user selects option 7. 1. Enter a string 2. Display the string 3. Reverse the string 4. Append a string to the existing one 5. Slice the string 6. Display the number of occurrences of each letter 7. Quit Program operation: Option 1: Prompt the user to enter a string. Option 2: Display the string to the user. Option 3: Reverse the string and display it to the user. Option 4: Prompt the user to enter a string, then append (i.e. concatenate) it to the end of the existing string. Option 5: Prompt the user for the first and second integers of a slice operation, then replace the existing string with a sliced version of it. Option 6: Print on a separate line each alphabetic character contained in the string. Don’t worry about punctuation, special characters, or whitespace. The letters are not to be considered case-sensitive, so you are free to display them either upper or lower case. Along with each letter, display number of occurrences within the string. For example, if the string is "Hello, World", the output would be: h, 1 e, 1 l, 3 o, 2 w, 1 r, 1 d, 1
Computers and Technology
1 answer:
yulyashka [42]3 years ago
6 0

Answer:

See Explaination

Explanation:

def process_string(s):

global char#global varibles

char=[]

global count

count=[]

for i in s:

#checking whether i is alphabet or not

if(i.isalpha()):

#converting to lower

i=i.lower()

if i in char:

#if char already present increment count

count[char.index(i)]+=1

else:

#if char not present append it to list

char.append(i)

count.append(1)

#menu

print("1. Enter a string")

print("2. Display the string")

print("3. Reverse the string")

print("4. Append a string to the existing one")

print("5. Slice the string")

print("6. Display the number of occurences of each letter")

print("7. Quit")

op=input("Enter option:")

#as I don't know what you have covered

#I am trying to make it simple

#checking whether input is numeric or not

#you can use try except if you want

while(not op.isnumeric()):

op=input("Enter valid option:")

op=int(op)

global x

while(op!=7):

if(op==1):

x=input("Enter a string: ")

elif(op==2):

print("The string is:",x)

elif(op==3):

x=x[::-1]#reversing the string

print("The string is:",x)

elif(op==4):

y=input("Enter a string: ")

x=x+y #string concatnation

elif(op==5):

a=input("Enter first integer: ")

while(not a.isnumeric()):

a=input("Enter valid first integer: ")

a=int(a)

b=input("Enter second integer: ")

while(not b.isnumeric()):

b=input("Enter valid second integer: ")

b=int(b)

x=x[a:b]#string slicing

#you can also use x.slice(a,b)

elif(op==6):

process_string(x)

for i in range(len(char)):

print(char[i],",",count[i])

else:

#incase of invalid input

print("Invalid option")

print("1. Enter a string")

print("2. Display the string")

print("3. Reverse the string")

print("4. Append a string to the existing one")

print("5. Slice the string")

print("6. Display the number of occurences of each letter")

print("7. Quit")

op=input("Enter option:")

while(not op.isnumeric()):

op=input("Enter valid option:")

op=int(op)

You might be interested in
When you select Insert and click on a shape the mouse pointer turns into a/an
Gennadij [26K]

It turns into crosshairs

6 0
3 years ago
Read 2 more answers
Which type of RAM is used exclusively in laptops?<br> a) SODIMM<br> b) DDR3<br> c) DDR<br> d) DDR4
Black_prince [1.1K]

Answer:

DDR3

Explanation:

6 0
3 years ago
A(n) ______ database stores data in tables that consist of rows and columns.
melisa1 [442]
The answer is a spreadsheet.
4 0
4 years ago
Read 2 more answers
What is a fruitful function? Explain with help of programming example?<br> plz
kupik [55]
These are the functions that return a value after their completion. A fruitful function must always return a value to where it is called from. A fruitful function can return any type of value may it be string, integer, boolean, etc. It is not necessary for a fruitful function to return the value of one variable, the value to be returned can be an array or a vector. A fruitful function can also return multiple values.
5 0
3 years ago
Your help will help me understand my answers by comparing to yours. Your kind contribution is very much appreciated.
OLEGan [10]
4. B
for # 5 what illustration are u talking about
6. D
7. D
8. don't understand that question

sorry these questions might be wrong

6 0
3 years ago
Other questions:
  • In addition to talking to other doctors remotely, telegraphy technology?
    5·1 answer
  • In a(n) ________ either one condition or some other condition must be met in order for an event to take place.
    11·1 answer
  • We can log on to computer or to network through s creen<br>​
    7·1 answer
  • The _______________ is a priority-ordered list of the other carrier networks and frequencies it should search for when it cannot
    6·1 answer
  • Word processing software, spreadsheet software, database software, and presentation software are examples of what category of co
    6·1 answer
  • Using the given definition of the Measurable interface: public interface Measurable { double getMeasure(); } Consider the follow
    10·1 answer
  • 4.2 lesson practice helps plzs
    9·1 answer
  • The space that helps you organize your PowerPoint or Web Page is called ______.
    13·1 answer
  • After running the following pseudocode, what will the value of VARIABLE be? 1. Set value of VARIABLE to 5 2. Increase the value
    15·1 answer
  • What is a worm?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!