1. def longest_word(list): longword = max(list, key=len) print("Longest word : ",longword) print("Length of longest word : ",len(longword)) input_string = input('Enter words of a list separated by space ') print("\n") user_list = input_string.split() # call function logestWord = longest_word(user_list); Output:- ======= Enter words of a list separated by space Apple Banana Watermelon Longest word : Watermelon Length of longest word : 10 ============================================================================ 2. def remove(string, n): first = string[:n] last = string[n+1:] return first + last string=input("Enter the sring:") n=int(input("Enter the index of the character to remove:")) print("Modified string:") print(remove(string, n)) Output :- =========   Enter the sring: Apple Enter the index of the character to remove: 2 Modified string: Aple ============================================================================== 3. def lastPartString(tstring,specChar): print(tstring.rsplit(specChar, 1)[0]) tstring = input("Please enter string for testing :") tposition = input("Please enter specified characher:") lastPartString(tstring,tposition) output:- ========   Please enter string for testing : Data science - class Please enter specified characher: - Data science ============================================================================== 4. Original_Array = ["Python", "Julia", "Go", "MATLAB", "SPSS", "R", "C"] # Printing original array print ("The original array: ",Original_Array) # sorting words in dictionary order Original_Array.sort() # printing original array after sorting print ("Sorted array: ",Original_Array) Output:- ========   The original array: ['Python', 'Julia', 'Go', 'MATLAB', 'SPSS', 'R', 'C'] Sorted array: ['C', 'Go', 'Julia', 'MATLAB', 'Python', 'R', 'SPSS'] ================================================================================ 5. string = ' My son name is Jatin Krishna. ' print(f'String =\'{string}\'') print(f'After Removing Leading Whitespaces String =\'{string.lstrip()}\'') print(f'After Removing Trailing Whitespaces String =\'{string.rstrip()}\'') print(f'After Trimming Whitespaces String =\'{string.strip()}\'') Output:- ======== String =' My son name is Jatin Krishna. ' After Removing Leading Whitespaces String ='My son name is Jatin Krishna. ' After Removing Trailing Whitespaces String =' My son name is Jatin Krishna.' After Trimming Whitespaces String ='My son name is Jatin Krishna.' =============================================================