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
Lisa [10]
3 years ago
9

Write a function that finds the number of occurrences of a specified character in the string using the following header: def cou

nt(s, ch): For example, count("Welcome", 'e') returns 2. The str class has the count method. Implement your function without using the count method. Write a test program that reads a string and a character and displays the number of occurrences of the character in the string.
Computers and Technology
1 answer:
Ludmilka [50]3 years ago
6 0

Answer:

def count(userInput, character):

   occurrences = 0

   for character_in_string in userInput:

       if(character == character_in_string):

           occurrences += 1

   return occurrences

userInput = input("Enter string: ")

character = input("Enter character: ")[0]

print(count(userInput, character))

Explanation:

  • Define a count function that takes in the userInput as a string and character parameters.
  • Loop through the userInput and check whether selected character is equal to the character found in the string.
  • Increase the counter of occurrences by 1 if the condition is true and then return the occurrences.
  • Take the userInput and character as input from the user.
  • Finally display the results by calling the count function.
You might be interested in
Bill has released a new line of products for his business and is using Google Display Ads to influence customer consideration. H
ra1l [238]

Answer:

By allowing Bill to increase per-transaction sales by adjusting the prices of his products, based on customer interest.

 

By allowing Bill to show his ads to the exact audience he selected, based on his automated marketing objective.

 

By allowing Bill to improve the customer experience by finding only those who are interested in his products.

 

By allowing Bill to strategically show his message to users when they’re actively browsing, researching, or comparing the types of products he sells.

Explanation:

4 0
3 years ago
What information should be included in the closing paragraph of a thank-you letter? a. Mention skills that were omitted during t
stiks02 [169]
The answer is c and sorry for being so rude I didn't realize it was you girly

3 0
4 years ago
Read 2 more answers
What will be the output of the following Python code? class A: def test1(self): print(" test of A called ") class B(A): def test
Vlad [161]

Answer:

"test of B called"

Explanation:

  • The object is created for the D class, but there are two test methods in class B and C.
  • The D class does not hold any test method. So when the object called the test method. Then the B method is called.
  • It is because the B class is declared first in the inheritance of D class like in the statement "class D(B, C)".
  • If the statement will be "class D(C, B)", then the C method will be called.
  • if the D class holds the method test, then only the D method will be called.
  • Hence the output is "test of B called".
7 0
4 years ago
With an Internet connection, you can view, modify and delete files stored in your
Soloha48 [4]

Answer:

Computer

Explanation:

Files stored in the "cloud" are stored remotely in some file system in one or more data centers. To access these files from any device you need to have an internet connection. Technically speaking, you can Create, Read, Update and Delete(C.R.U.D) anything stored in any cloud from any internet connected device as long as you have the permission to do so.

4 0
3 years ago
In every organization, workers receive and sendinformation daily. The flow of this information should be____________.upward and
Aleks [24]

Answer:

upward and downward

Explanation:

4 0
4 years ago
Other questions:
  • Samantha received a gaming session as a gift. She would like to have it communicate with her sister Jennifer’s gaming system so
    15·1 answer
  • (TELL ME WHY PLEASE!! THANK YOU!!)
    9·2 answers
  • A toolkit is:
    15·1 answer
  • Why do astronomers prefer to use the reflecting telescope rather than the refracting telescope to view distant objects in space?
    15·2 answers
  • What is the full form of cpu​
    11·2 answers
  • Cloud architects have been largely replaced by ScrumMasters.<br><br> True<br><br> False
    15·2 answers
  • State and explain five misused of science and technology​
    12·1 answer
  • A student has completed some work at school and wishes to take it home. He could use a pen
    9·1 answer
  • Complete a flowchart and a Python program to calculate grade of a student based on marks using the following criteria:
    6·1 answer
  • Artificial intelligence (ai) in perspective is a complex and interdisciplinary field that involves several specialties, includin
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!