Write a Python function (give it any name you choose) to analyze a text string given to it. The function will receive one single string as argument It will return two tuples of two elements each: One tuple contains the word with the maximum occurrence in the input text and the number of its occurrence. The other tuple contains the longest word with in the input text and the number of characters in it. The function should be called like function1(text), where text is a string variable. Use the paragraph below to test your code:
Write a Python function (give it any name you choose) to analyze a text string given to it.
- The function will receive one single string as argument
- It will return two tuples of two elements each:
- One tuple contains the word with the maximum occurrence in the input text and the number of its occurrence.
- The other tuple contains the longest word with in the input text and the number of characters in it.
- The function should be called like function1(text), where text is a string variable.
- Use the paragraph below to test your code:
text = ‘’’During a wet autumnal walk, I was explaining to my girlfriend about my recent presentations. I've been doing my 'Getting Started with Python' talk at Aruba Airheads meet-ups. I recorded an early version of it, see below. One point I mentioned is that the reaction is always mixed. When I ask who is learning Python, about 5% of each audience put their hands up. Regularly people object to the idea of network engineers learning Python. The arguments are usually along the lines of 'network engineers already have enough to learn'. The conversation continued as we walked through sodden leaves and we discussed why, if the other speakers were doing talks that the crowds want to hear, like product updates, I'm burdened with a subject the audience are less enthusiastic about. The assumption being that I was assigned this topic. My response: "Oh no, I choose to do this." The next question was, of course, "Why?"
My Why:
There's something of the two-edged sword in the word 'why'. It can be used to undermine, casting doubt about the veracity of an argument, cutting through the rhetoric and leaving those with ill-reasoned ideas to flounder and stutter a response. But it can also galvanize, provide the opportunity to refine and reinforce one's thoughts, to thrust home one's argument.
Here's my why. Why I think learning Python is a worthwhile exercise as the first step on the road to automating networks, and this conviction stems from personal experience.’’’
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images