Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python3: but this needs to be in a webbased form here is the form code: import cgi, cgitb cgitb.enable() print (Content-type: text/html ) def printForm(default):
python3: but this needs to be in a webbased form here is the form code:
import cgi, cgitb cgitb.enable() print ("Content-type: text/html ")
def printForm(default): print ("
") def printTable(): form = cgi.FieldStorage()print ("
{} | ".format( form.getvalue('paragraph') )) print ("
def printLines(longstring): posOfNewLine = longstring.find(' ') while posOfNewLine != -1: item = longstring[:posOfNewLine] longstring = longstring[posOfNewLine+1:] posOfNewLine = longstring.find(' ') print ("Here's an item {}
".format(item)); print ("Here's the last item {}
".format(longstring));
def printLink(): print ("
") # # main code below # #printTable() form = cgi.FieldStorage() input = form.getvalue('paragraph') printForm(input) if input: # only do the following if there is input printLines(input)Requirements Write a python program that 'analyzes' a list of words supplied in a textarea as described on a later slide Your python code will generate both the form and the output. Analyzing requirements You must split the entire text area into a list of strings by spaces. (This is what split() does by default) (i.e. words in a paragraph) It will sort the words in ASCENDING lexicographical order and print the first 400 words in 10 columns. You have to count the number words in the text area and print that out. You have to determine the average word length of the words in the paragraph and print that out too. Sample output UnsortedThis', 'is', 'a', 'sentence', 'I', 'just', 'typed', 'in'] Sorted:[T, This', 'a', 'in', 'is', just, 'sentence', 'typed] There are 8 words The average word length is #####
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