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
The music is the soul who says this
Crazy boy [7]

Question:the music is the soul who says this

Answer: Arthur Schopenhauer

Explanation: he says music is the language of feeling and of passion

question answered by

(jacemorris04)

4 0
3 years ago
10. Select the correct answer.
Aleks [24]
B) licensing because they are giving Thomas permission to use the images
6 0
3 years ago
Read 2 more answers
Task 7: The following is a quiz program that asks the us-
Leni [432]

Answer:

peread

Explanation:

7 0
3 years ago
When sending emails and setting goals, you want to go beyond checkpoints of activities for your goals. What are examples of chec
yulyashka [42]

Answer:

Open and click rates

Explanation:

Open and click rates are measuring units of how well your campaigns perform.

8 0
4 years ago
Present a detailed data model for your project scenario. You can create your data model using Microsoft Visio 2010, which you wi
Troyanec [42]

Answer:

THE FARMERS PRICE CENTER

The farmer's price center is about helping farmers acquire farm inputs easily

and conveniently. Through relevant branches and supportive statt, the farmers

price center provides a fresh perspective on the day to day hardships that farmers

Tace. The tarmer's price center is run by a practicing tarnmer with tirst hand

information as he holds a bachelors degree in agriculture. His unique perspective

allows farmers to automatically connect with his point of view. The farmer's center

is equally informal as it is also a mentor or a friend. Besides selling farm inputs,

the center guides tarmers overcome their challenges.

The tarmer's price center addresses the tarming and tarming management

sector. The people who purchase from famers price center are either practicing

tarmers or want to start a venture in agriculture. They have a natural drive to create

agricultural products and seek out professional advice. The ideal customer for the

farmer's price center would be the new farmer or investor who wants to start an

agricultural venture or manage their firm better. The farmer's price center provides

a comprehensive resource that answers the questions farmers have while at the

same time giving thema step by step way to succeed. Mostly, farmers do not have

The farrmers price center will be getting 5,000 unique customers per month

and be ranked as a pace setter and a trusted mentor and be ranked as a leader in

agricultural products and advice site. To achieve these long term goals, the

Tarmer s price center needs to apply imbound marketing te chniques to get tound.

Part or this strategy will be to contract sales representatives to market the varlous

products to the retail shops across the countryside. These sales representatives are

to be paid a retainer and commission upon hitting their sales target. The (products

are transported by our fleet of trucks to the customer's premises. Payment shall be

made on cheque at the end of the month according to the number of products

delivered. Each sales representative shall prepare a report on their daily sales with

accordance to their specitic routes.

ne raners price center is all about neiping ramers tnve n tne cndotic

world of business filled with scrupulous products. The farmer's price center will

achieve upwards of 5,000 unique customers and S10,000 in revenue per month

within the next two years.

6 0
3 years ago
Other questions:
  • In the C-SCAN disk scheduling algorithm, the disk arm is required to move in one direction only until it reaches the last track
    7·1 answer
  • Write a program that reads in an array of type int . you may assume that there are fewer than 50 entries in the array. your prog
    6·1 answer
  • Which statement correctly explains why televisions became less bulky?
    6·1 answer
  • The ______ manages the hardware components including the cpu, memory storage, and peripheral devices. options operating system d
    9·1 answer
  • Edhesive 3.2 Lesson Practice question 1
    5·1 answer
  • What are some ways to rename a worksheet? Check all that apply.
    9·1 answer
  • Difrent between computer and computer system​
    9·1 answer
  • How does natural gas move through pipelines from the well head to the end user thousands of miles away
    5·1 answer
  • What kind is a utility file that shrinks the size of a file
    14·1 answer
  • Design a circuit that will tell whether a given month has 30 days in it.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!