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
What function would you use to find the mean in a Microsoft excel document ?
kupik [55]
I think its 3 average
8 0
3 years ago
Read 2 more answers
Nicole wants to create a database to collect information about sales transactions. She would like to use the database to look up
Snowcat [4.5K]
D. name, credit card number, product number, and sales price
3 0
3 years ago
Read 2 more answers
A microphone, a track ball, and speakers are all examples of ____. hardware software
djyliett [7]
Hardware . . . . . . . . . . . .  . . . . . . .. 
3 0
2 years ago
Read 2 more answers
Which combining form is spelled incorrectly? group of answer choices gynic/o carcin/o nephr/o laryng/o
liraira [26]

The combining form is spelled incorrectly is known to be called gynic/o .

<h3>What is combining form in medical terminology?</h3>

The term Combining Forms is known to be one that is linked to the Correct pronunciation of all of medical words and it is known to be important.

For a person to be able to make the pronunciation of word roots to be easy, sometimes it is needed to place a vowel after the root.

Therefore, based on the above, The combining form is spelled incorrectly is known to be called gynic/o .

Learn more about combining form from

brainly.com/question/3124757

#SPJ1

3 0
1 year ago
Which logging category does not appear in event viewer by default?
Ulleksa [173]

I believe this should have some multiple choice options: Application, System, Volume, Security.


The correct answer is volume.

7 0
2 years ago
Other questions:
  • Survey Q, Non-scoring: What role are you playing in your team?
    5·2 answers
  • On the Insert tab, select Table &gt; _______ to create a table from selected text.
    14·1 answer
  • Which of the following is a category of social media?
    8·2 answers
  • Kiaan wants to give people who attend his presentation a printed copy of the slides. Instead of printing one slide on each piece
    11·1 answer
  • Which of the following is NOT a safe skill you can use to reduce your risk
    11·2 answers
  • __________ contain(s) remnants of word processing documents, e-mails, Internet browsing activity, database entries, and almost a
    9·1 answer
  • Cine stie repede va rog mult si repede
    9·1 answer
  • Can you move it like this? I can shake it like that
    6·1 answer
  • Draw
    7·1 answer
  • What is pseudocode? O A way of describing a set of instructions in text form using plain english O A diagrammatic representation
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!