Question: Problem 2: Longest Words We will now find the longest words used by Shakespeare. We will start by looking for the single longest word.

image text in transcribed

Problem 2: Longest Words We will now find the longest words used by Shakespeare. We will start by looking for the single longest word. Complete the following steps in a single code cell: 1. Write a Python function with two parameters, both of which are intended to be strings. The function should return the longer of the two strings. If the strings are the same length, then the function should return the word that appears later when ordered lexicographically (alphabetically). 2. Use the function you wrote along with reduce() to find the longest word in the RDD dist_words. Print the result. We will now find the 20 longest words used by Shakespeare. Use sortBy() with the Python len() function to sort the elements of dist_words according to their length, with longer words appearing first. Print the first 20 elements of this RDD.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!