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 are the ASE special certifications?
kykrilka [37]

Answer:

It is The National Institute for Automotive Service Excellence.

Explanation:

8 0
3 years ago
Read 2 more answers
HEYY GUYS START REPORTING ALL THE SPAMMERS PLSS!!!!! For the spammers, I hope you go to hell >:c!!!!!!!!!!!
Molodets [167]

Answer:

i totally agree

Explanation:

4 0
3 years ago
I WILL GIVE BRANLIST
qaws [65]

Answer:

space alignment

Explanation:

I'm not sure just taking a guess cuz I'm bored lol

4 0
2 years ago
Read 2 more answers
2. Read the following scenarios about how three different programmera approach
zheka24 [161]

Answer: A or B

Explanation: I think it's A or B Because they are the ones that make more sence

4 0
2 years ago
Read 2 more answers
Researchers conducted a 'natural experiment' to examine the effects of on-site food services on weight gain among first-year col
anygoal [31]

Answer:

On-site food services is the INDEPENDENT variable and the weight gain is the DEPENDENT variable

Explanation:

Variables can be dependent or independent. An independent variable is the one used by the researcher to test its degree of influence on the dependent variable. The dependent variable, as the name implies, relies on changes in the independent variable to effect its own changes.

In the question, it is obvious that weight gain among the first year students is dependent on on-site food services

7 0
3 years ago
Other questions:
  • Elisa and josh need to access general helps. Elisa will press the F1 key. josh will on ?. who will access general help
    15·1 answer
  • Im trying to learn c# for unity does anyone know any good sources
    10·1 answer
  • How can you tell that a website is valid and reliable
    7·2 answers
  • You are a developer for a company that is planning on using the AWS RDS service. Your Database administrator spins up a new MySQ
    7·1 answer
  • A researcher develops a new instrument to measure coping skills and conducts a pilot study to compare the new tool with an exist
    5·1 answer
  • Which camera mode gives the photographer the greatest amount of control?
    7·2 answers
  • Which feature is used to summarize data from multiple worksheets but does not require that the data be in the same location on e
    12·1 answer
  • Declare a variable temperature and initialize it to 98.6. Instructor Notes: Note that "initialize" means "declare and assign a v
    5·1 answer
  • Is there anyone that knows how to work in Microsoft Access and someone that could help me on my test at 11 30am?​
    7·1 answer
  • What should a pie chart represent?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!