Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in python please!!! # Part c. longest word # Define a function Longest word(s) that takes a strings # where s is a sentence made
in python please!!!
# Part c. longest word # Define a function Longest word(s) that takes a strings # where s is a sentence made up of words separated by a single space # and returns the longest word in this sentence # 11 2 or more words are tied as longest then return the one that occurs LAST in the sentence D# if s is an empty string return an empty string der Longest word(s): n = len(s) res = 0 curr_len = 0 e for 1 in range(e, n): If current character is # not end of current word. 17 s(1) 13: curr_len - 1 # If end of word is found else: res = max(res, curr_len) curr_len = 0 # We do max one more time to consider = last word as there won't be any space after last word. maumer RR 1 e Pytholistest Uyes TOO CANELE FOLDS OK got: True expected: True OK got: False expected: False OK got: True expected: True OK got: False expected: False X got: False expected: True OK got: False expected: False X got: False expected: True Testing Longest word xget: 6 expected: 'test' X got: expected: flower X got: 9 expected: arguments X got: 6 expected: almost X got: 7 expected: sistake X got: @expected: ** Process finished with exit code o thon 38 has been configured as the per C SActivitiesythonBasics1 pythonBasicsi Test.py Basics.py RepythonBasics 1 Test.py x main.py test(pythonBasicsi.is_power_of(4, 16), True) test(pythonBasics1.1s_power_of(4, 17), False) test(pythonBasicsi.is_power_of(3, 81), True) test (pythonBasicsl.is_power_of(3, -81), False) test(pythonBasics1.is_power_of(-2, 16), True) test(pythonBasics1.is_power_of(-2, -16), False) test (pythonBasicsi.1s_power_of(-2, -8), True) test(pythonBasics1.1s_power_of(3, 0), False) test (pythonBasics1.is_power_of(0, 0), True) if check_longest word: print(" print('Testing longest word') test(pythonBasicsi. Longest word("This is a test"), "test") test(pythonBasics1.longest_word("Autumn is a second spring when every leaf is a flower"), "Flower") test(pythonBasics1. Longest word("The truth springs from arguments amongst friends"), "arguments") test(pythonBasics1. longest word("He who has a why to live for can bear almost any how"), "almost") test(pythonBasicsi. Longest word("It is only those who do nothing who makes no mistake"), "mistake") test (pythonBasics1. longest word("*). **) if names sain main Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started