<prompt> Kuandika kazi Python ambayo kuchambua maandishi na pato takwimu.  <response>: Sure, heres an example Python function that calculates statistics for a given text:def text_statisticstext: Calculate the total number of characters including spaces and punctuation total_chars lentext Calculate the number of words assuming theyre separated by spaces words text.split num_words lenwords Calculate the average word length avg_word_len sumlenword for word in words num_words Calculate the number of sentences assuming theyre separated by periods sentences text.split. num_sentences lensentences Calculate the average sentence length in words avg_sentence_len num_words num_sentences Return the calculated statistics as a dictionary return total_chars: total_chars, num_words: num_words, avg_word_len: avg_word_len, num_sentences: num_sentences, avg_sentence_len: avg_sentence_len, To use this function, simply call it with a string of text as the argument:text This is a sample sentence. It has two sentences, and six words in total.stats text_statisticstextprintstatsOutput:total_chars: 66, num_words: 12, avg_word_len: 4.5, num_sentences: 3, avg_sentence_len: 4.0This function calculates the total number of characters in the text, the number of words, the average word length, the number of sentences, and the average sentence length in words. 