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 four primary factors described in the text that set the state for Web 2.0 or the social Web that we enjoy today??
antiseptic1488 [7]


The four primary factors that set the stage for web 2.0 of the social web are following:  broad bandwidth, sustainable business models, new web programming technologies and application programming interfaces.
• Broad Bandwidth which technology developments have been taking place at a faster situation and the availability of internet has remarkably increased over the years through the rise of broad band technology. The broadband increase in easy accessibility laid a strong base for social web or web 2.0.

• Sustainable Business Model which E-commerce took its roots and has proven a great success rate.

• New Web Programming Technologies which includes web content, web client, server scripting and network security.

• Application Programming Interface is a system of resources and tools in an operating system which enables the developers to create software applications.
7 0
3 years ago
Domain of (x+8)/(x(x+10))
UkoKoshka [18]
The domain of this, assuming it's a function, is all real numbers such that x does not equal zero or negative ten.

In interval notation, this is (-∞, -10) U (-10, 0) U (0, <span>∞).

In set builder notation, this is {x | x </span>≠ -10, x <span>≠ 0}.

These inputs are excluded from the domain because they would otherwise allow division by zero. Try plugging in one of the restricted inputs. You'll see that it does not work! On a graph of this </span>function, you will see vertical asymptotes. 

5 0
3 years ago
How do ethics affect people?
Mnenie [13.5K]
People are affected because ethics are suppose to be moral
5 0
3 years ago
Which type of multiplexing divides transmission opportunities into slots of 125 microseconds with position inside each slot rese
Zinaida [17]

Answer: Time division multiplexing

Explanation: because a slot is equivalent to 125ms

And each position inside a slot is for each signal and a single bit frim each voice conversation is sent during each 125ms slot

7 0
3 years ago
What is 1-7? Plz help!!!
VARVARA [1.3K]
You want 10-12 too?.............

6 0
3 years ago
Other questions:
  • A brick weighs 26 N. Measured underwater, it weighs 11 N.
    10·1 answer
  • Which keyboard feature is a form feed character?
    14·1 answer
  • Propose, two new, proudly South African ways, which you can visualize that the internet of things, can be used in at work to mak
    7·1 answer
  • What component on a smartphone requires pairing with another device?
    8·1 answer
  • Swiping up with three fingers on mac os x launches what?
    8·1 answer
  • A browser allows you to set preferences for using the browser. These preferences include all of the following except
    7·1 answer
  • You’re configuring a Web-based intranet application on the WebApp server, which is a domain member. Users authenticate to the We
    13·1 answer
  • Question #4
    10·1 answer
  • Who Likes K-pop? Which group or groups do you like
    12·2 answers
  • In this project you will write a set of instructions (algorithm). The two grids below have colored boxes in different
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!