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
Nataly_w [17]
3 years ago
5

Write a function analyze_text that receives a string as input. Your function should count the number of alphabetic characters (a

through z, or A through Z) in the text and also keep track of how many are the letter 'e' (upper or lowercase). Your function should return an analysis of the text in the form of a string phrased exactly like this: "The text contains 240 alphabetic characters, of which 105 (43.75%) are ‘e’."
Using function
Computers and Technology
1 answer:
laiz [17]3 years ago
5 0

Answer:

def analyze_text(sentence):

   count = 0

   e_count = 0

   for s in sentence:

       s = s.lower()

       if s.isalpha():

           count += 1

       if s == "e":

           e_count += 1

   return "The text contains " + str(count) + " alphabetic characters, of which " + str(e_count) + " (" + str(e_count*100/count) + "%) are ‘e’."

Explanation:

Create a function called analyze_text takes a string, sentence

Initialize the count and e_count variables as 0

Create a for loop that iterates through the sentence

Inside the loop, convert all letters to lowercase using lower() function. Check each character. If a character is a letter, increment the count by 1. If a character is "e", increment the e_count by 1.

Return the count and e_count in required format

You might be interested in
How I can learn writing code?
slavikrds [6]

A good website to learn coding is called Lynda.com. It costs money but its well worth it!

3 0
2 years ago
Read 2 more answers
A device that modulates digital data onto an analog signal and then demodulates the analog signal back to digital data is a ____
LenKa [72]
A modem. (From modulator-demodulator)
5 0
2 years ago
What is the output of this program?
Wewaii [24]

Answer:

6 +4 + 6 +4

Explanation:

It will start from index 0 and wherever you find the character inside the indexOf methods then you will note it down.

5 0
3 years ago
What is the quotient of 8.16 ÷ 100​
Natalka [10]

Answer:

0.0816

Explanation:

8.16 ÷ 100 = 0.0816 (Ans)

6 0
2 years ago
How's your day :D I hope its goin well you amazing person :D
Rainbow [258]

Answer:

You are an awesome and amazing person!!

Explanation:

7 0
2 years ago
Read 2 more answers
Other questions:
  • What type of data visual would you use to illustrate trends over time? Gantt chart Bar graph Line chart Scatter diagrams
    5·1 answer
  • What is the solubility of an empty soda can
    10·1 answer
  • What are the two basic steps in communication
    9·1 answer
  • How many bytes are there in 256 Kbytes?
    6·1 answer
  • A ________ database state is one in which all data integrity constraints are satisfied
    15·2 answers
  • What is the cell reference for row 22 and column B? __________<br><br> In excel
    5·1 answer
  • Gimme Shelter Roofers maintains a file of past customers, including a customer number, name, address, date of job, and price of
    8·1 answer
  • Hey, wanna pair our account on Brainly so we can share the perks? https://brainly.com/invite/8db681239ab5027e03b097bcded13755?ut
    15·2 answers
  • Assign listNodes with all elements with a clasa name prog-lang
    11·1 answer
  • TRUE/FALSE. a good with many close substitutes is likely to have relativelyelastic correct demand, since consumers can easily ch
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!