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
A technician is configuring a new SOHO multifunction wireless router at a customer's location to provide network access to sever
Alja [10]

Answer:

B. Change the router's default administrative password.

Explanation:

Whenever a user purchase a router for wireless network, a default password has been set for the device, which can be easily accessible to different users on the internet or that particular network. This will  lead to unsecured that particular user in terms of hacking or stealing data or personnel information easily.

To make sure the security of customer on private network, the technician should change the router default password.  

7 0
3 years ago
How is the execution speed of machine language compared to that of high-level languages? The execution speed of machine language
Alik [6]

The execution speed of machine language is faster than the execution speed of other languages. Machine or assembly language will execute the fastest as compared to high-level languages. No other language can execute faster than Machine language since instructions are directed straight to the CPU. Other high-level languages often add some non-zero amount of overhead to the execution time, thus, causing some delay.

7 0
3 years ago
Read 2 more answers
The domain in an email message tells you the
Alexus [3.1K]
The type of service provider
8 0
3 years ago
Show the printout of the following code.
alexira [117]

Answer:

E. 7.0

Explanation:

the 7 of the out of the older and make a shame of waves and force of trying

7 0
3 years ago
Ethereum Mining Calculator Profitability and Difficulty Level?
yanalaym [24]

Profitability Calculator: https://www.cryptocompare.com/mining/calculator/eth?HashingPower=200&HashingUnit=MH%2Fs&PowerConsumption=140&CostPerkWh=0.12&MiningPoolFee=1

Difficulty Level Chart: https://www.coinwarz.com/difficulty-charts/ethereum-difficulty-chart

3 0
3 years ago
Other questions:
  • If you want to conserve ink or toner, you can instruct PowerPoint to print ____ documents.
    10·1 answer
  • A person clicks on an ad of a fitness club in a blog on nutrition. The person conducts a search on yoga and moves to another web
    8·1 answer
  • Which group on the home tab contains the line spacing attribute?
    7·1 answer
  • A program needs to allow a customer to input integers until the input number is zero. When the input number is zero, the program
    14·1 answer
  • A website's ____ page provides basic information about the individual or organization and includes a navigation bar with links t
    13·1 answer
  • Name various phases of SDLC in Rational Unified Process (RUP)
    7·1 answer
  • The relation LIBRARY records books currently on loan to students. Each book has one ISBN_NO The library has several copies of ea
    14·1 answer
  • 9.4 Code Practice: Your task is to determine whether each item in the array above is divisible
    14·1 answer
  • How to make a project using PID and thermacouple
    11·1 answer
  • When you pass a double variable to a method, the method receives ______.a) a copy of the memory addressb) the reference of the v
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!