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
18) What is masking in Flash?
sammy [17]

Answer:

Ok thanks, I guess?

..............

6 0
2 years ago
What does Digital Citizenship mean to you?
Nikolay [14]
A digital citizen refers to a person who has the knowledge and skills to effectively use digital technologies to communicate with others, participate in society and create and consume digital content. Digital citizenship is about confident and positive engagement with digital technologies. Digital citizenship refers to responsible technology usage, and teaching digital citizenship is essential to helping students achieve and understand digital literacy, as well as ensuring cyberbullying prevention, online safety, digital responsibility, and digital health and wellness.
5 0
3 years ago
You are to design class called Employee whose members are as given below:
frozen [14]

Answer:

//The Employee Class

public class Employee {

   char name;

   long  ID;

//The constructor  

public Employee(char name, long ID) {

       this.name = name;

       this.ID = ID;

   }

//Method Get Person

   public void getPerson (char newName, long newId){

       this.ID = newName;

       this.ID = newId;

   }

//Method Print

   public void print(){

       System.out.println("The class attributes are: EmpName "+name+" EmpId "+ID);

   }

}

The working of the class is shown below in another class EmployeeTest

Explanation:

public class EmployeeTest {

   public static void main(String[] args) {

       Employee employee1 = new Employee('a', 121);

       Employee employee2 = new Employee('b', 122);

       Employee employee3 = new Employee('c', 123);

       employee1.print();

       employee2.print();

       employee3.print();

   }

}

In the EmployeeTest class, Three objects of the Employee class are created.

The method print() is then called on each instance of the class.

6 0
3 years ago
Which are examples of hardware? Select 3 options.
umka21 [38]

Answer: OS(Operating System), CPU, And The Program That you use to view email

6 0
3 years ago
Read 2 more answers
Answer the following questions:
Alika [10]

Answer:

nasaan po yung tanongkkkkk

8 0
3 years ago
Other questions:
  • An important advantage of using GUI data-entry objects is that you often can control what users enter by limiting their options?
    6·1 answer
  • Which of the following is a feature that is in the Excel program and NOT in Word? (Select all that apply.)
    14·1 answer
  • Noticing his reduced performance at work, Dan enrolled himself for training sessions offered by the company and saw his producti
    13·1 answer
  • Technology has proliferated in Kenya and Somaliland, with text messages used to replace cash, creating mobile money use that, on
    11·1 answer
  • A(n) ________ collects data from various key business processes and stores the data in a single comprehensive data repository, u
    11·1 answer
  • When you are fit, you can exercise and do physical work without getting too tired. A. True B. False\
    13·2 answers
  • This is a quick and easy program that will let you practice the basics of the switch statement. You will ask the user to enter a
    6·1 answer
  • Where can a client identify the instant deposit options for their QuickBooks Payments account?
    5·1 answer
  • Consider the following import statement in Python, where statsmodels module is called in order to use the proportions_ztest meth
    10·1 answer
  • 8. Choose the 3 correct statements for the code below.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!