Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

-------Final Coding Problem for Practice, need immediate help please------- \"Th

ID: 3581475 • Letter: #

Question

-------Final Coding Problem for Practice, need immediate help please-------

"This is our final exam.

For full credit:

Place your name and the purpose of the program at the top of your code.

Use comments to document your code.

Gather together information on list methods and functions.

If you are unable to write a complete solution, write as much code as you can and explain how you would do what you haven’t done with words in as much detail as possible.

Submit a unique solution."

Question is below::

QUESTION 1 Here is a poem by Gwendolyn Brooks, saved as a string: We real cool. We left school. We lurk late. We strike straight. We sing sin. We thin gin. We jazz june. We die soon poem Print the string Assign the string to a list Print the list Determine the number of words in the list and print the result in sentence form Write code to count the number of times the word "We" appears in the list and print out the result in sentence form Calculate the percentage of times "We' appears in the list and print out the result in sentence form

Explanation / Answer

list = []
poem = "We real cool. We left school. We lurk late. We strike straight. We sign sin. We thin gin. We jazz june. We die soon"
print(poem)
words = poem.split(" ")
for i in range (len(words)):
   list.append(words[i])
      
print("The number of words in the list is "+str(len(list)))
WeCount = 0
for i in range(len(list)):
   if list[i] == "We":
       WeCount = WeCount + 1
print("The number of times the word 'We' appears in list is "+str(WeCount))
percentage = (WeCount/float(len(list))) * 100
print ("The percentage of times the word 'We' appears in list is "+str(percentage))

Output:

sh-4.3$ python main.py                                                                                                                                                                                                                                 

We real cool. We left school. We lurk late. We strike straight. We sign sin. We thin gin. We jazz june. We die soon                                                                                                                                    

The number of words in the list is 24                                                                                                                                                                                                                  

The number of times the word 'We' appears in list is 8                                                                                                                                                                                                 

The percentage of times the word 'We' appears in list is 33.3333333333