Answered step by step
Verified Expert Solution
Link Copied!

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):

image text in transcribed

image text in transcribed

image text in transcribed

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 ("

") print ("Enter some stuff:") print ("") print ("") print ("
") def printTable(): form = cgi.FieldStorage()

print ("

") print ("") print ("".format( form.getvalue('paragraph') )) print ("") 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 ("

") print ("") 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions