Write a function count_words(sentence) that returns the number of words in the string sentence. A word is a run of characters without a space. Words are separated by one or more spaces, and there can be extra spaces at the start and at the end. If the sentence is empty or has only spaces, return 0.
NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition.
count_words("the bus is late") -> 4
count_words(" hello world ") -> 2
Implement this function:
def count_words(sentence: str) -> int:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: sentence.
Input
"the bus is late"
Output
4

Write a function `count_words(sentence)` that returns the number of words in the string `sentence`. A word is a run of characters without a space. Words are separated by one or more spaces, and there can be extra spaces at the start and at the end. If the sentence is empty or has only spaces, return 0. NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition. ### Example ``` count_words("the bus is late") -> 4 count_words(" hello world ") -> 2 ``` ## Your task Implement this function: ```python def count_words(sentence: str) -> int: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `sentence`. ## Example **Input** ``` "the bus is late" ``` **Output** ``` 4 ``` Names were typed into a form with capital and small letters mixed up. Write a function `fix_name(name)` that returns the name with its first letter as a capital letter and all its other letters as small letters. The string `name` is one word, it has only letters, and it has at least one letter. NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition. ### Example ``` fix_name("rAVI") -> 'Ravi' fix_name("PRIYA") -> 'Priya' ``` ## Your task Implement this function: ```python def fix_name(name: str) -> str: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `name`. ## Example **Input** ``` "rAVI" ``` **Output** ``` 'Ravi' ``` Write a function `count_letter(text, ch)` that returns how many times the letter `ch` is in the string `text`. Capital and small letters count as the same letter: both `a` and `A` are counted when `ch` is `a`, and also when `ch` is `A`. The string `ch` is always exactly one letter. If the letter is not in `text`, or `text` is empty, return 0. NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition. ### Example ``` count_letter("Banana", "a") -> 3 count_letter("Anna Anand", "A") -> 4 ``` ## Your task Implement this function: ```python def count_letter(text: str, ch: str) -> int: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `text`, `ch`. ## Example **Input** ``` "Banana" "a" ``` **Output** ``` 3 ```