Lab work: Understanding str class methods: strip, split and re.split Understanding how to open and read from a text file =========================== 1. Predict the values and type of result and the value of sentence after these lines. Then run them to check sentence = ' Good morning, Skidmore! It is going to be a great day. ' result = sentence.strip() print(f'>{sentence}<') print(f'>{result}<') print(type(sentence)) print(type(result)) print(len(result)) 2. Predict the values and type of result and the value of sentence after these lines. Then run them to check. import re sentence = ' Good morning, Skidmore! It is going to be a great day. ' sentence = sentence.strip() result = re.split('[\s,!\.]', sentence) # recall that \s is shorthand for whitespace (includes: space, newline, tab) print(f'>{sentence}<') print(f'>{result}<') print(type(sentence)) print(type(result)) print(len(result)) # did you notice that there are empty strings as elements after doing the split? # do you understand why? 3. Predict the values and type of result and the value of sentence after these lines. Then run them to check. sentence = 'Good morning, Skidmore!' result = sentence.split() print(f'>{sentence}<') print(f'>{result}<') print(type(sentence)) print(type(result)) print(len(result)) 4. Predict the values and type of result after these lines. Then run them to check. # note, use the data.txt file posted to the labs page. with open('data.txt', 'r') as infile: result = infile.read() print(f'>{result}<') print(type(result)) print(len(result)) ============= 5. Write a program that reads the words from a file (you can use mobydick-chap1.txt from classnotes page) and counts - the number of words that start with an uppercase letter - the number of words that start with a lowercase letter - the number of words that are longer than 9 letters and outputs something like the following: There are ___ capitalized words in ____. There are ___ words that start with lowercase letter in ____. There are ___ words of at least 10 letters in ____. Think about whether you need to read the file line by line, or if you can just read the entire file in one shot.