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
Doss [256]
3 years ago
6

Write a program whose input is a string which contains a character and a phrase, and whose output indicates the number of times

the character appears in the phrase. Ex: If the input is:
Computers and Technology
1 answer:
otez555 [7]3 years ago
4 0

Answer:

The program written in python is as follows

def countchr(phrase, char):

     count = 0

     for i in range(len(phrase)):

           if phrase[i] == char:

                 count = count + 1

     return count

phrase = input("Enter a Phrase: ")

char = input("Enter a character: ")

print("Occurence: ",countchr(phrase,char))

Explanation:

To answer this question, I made use of function

This line defines function countchr

def countchr(phrase, char):

This line initializes count to 0

     count = 0

This line iterates through each character of input phrase

     for i in range(len(phrase)):

This line checks if current character equals input character

           if phrase[i] == char:

The count variable is incremented, if the above condition is true

                 count = count + 1

The total number of occurrence is returned using this line

     return count

The main method starts here; This line prompts user for phrase

phrase = input("Enter a Phrase: ")

This line prompts user for a character

char = input("Enter a character: ")

This line prints the number of occurrence of the input charcater in the input phrase

print("Occurence: ",countchr(phrase,char))

You might be interested in
If you want the values in your cell to have dollar signs in front of them, _________
Vlad1618 [11]
Use the number formatting option
4 0
3 years ago
What is an internet marketing manager?
Digiron [165]
An individual who develops and implements plans to exploit the internet for marketing and sales opportunities!
5 0
3 years ago
I'll pay 50 dollars to anyone who can do this leave your snap after answering doing it and ill cash app it
gladu [14]

Well for must cases it is the Ram of the system and the processor I will show you how you can get rid of slow processing

  1. Run the task manager then try to stop some running programs
  2. the antivirus sometimes slows the computer due to the processing power it takes.
  3. I would recommend that all program should be closed from the task manager and close some running apps in the system settings go to start up and then close it now you are good to go.

5 0
3 years ago
Is the PS5 worth it?
ratelena [41]
Yes it is worth it!!!!!!!!!!!
3 0
3 years ago
Read 2 more answers
Data ________ is important because it establishes an organization's rules for sharing, disseminating, acquiring, standardizing,
photoshop1234 [79]

Data protection policy is important because it establishes an organization's rules for acquiring, standardizing and disseminating data.

<h3>What is Data protection policy?</h3>

These are policies adopted by organizations that help to ensure data is adequately protected.

When data isn't protected , it could get to the hands of criminals which could use it for different types of cybercrime and also to ensure compliance with data protection laws in the country.

Read more about Data protection policy here brainly.com/question/26493645

3 0
2 years ago
Other questions:
  • How should you decide what to wear to an interview? What kind of things should be considered?
    5·1 answer
  • Which of the following is an Important criterion for evaluating the effctiveness of a graphic organizer
    14·2 answers
  • What does DOS stand for?
    15·1 answer
  • Which objects with developed to help astronomers to learn more about the sun
    12·1 answer
  • Who can help me on my school we will to google meet and i share my screen
    5·1 answer
  • During side show mode, hitting the B key will do which one of these?
    7·1 answer
  • Of the following choices what was the best thing to do with electronic equipment you no longer want
    7·1 answer
  • If a fuse block or holder has tree fuses, it may be termed a...
    7·1 answer
  • Write an algorithm to calculate the sum of integer ​
    7·1 answer
  • Which unknown factor affects prices in the financial markets?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!