Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use python language to complete the Titleparser part and the BizzaroGUI part 1. Finish the BizzaroGUI implementation. The BizzaroGUI does three things: Has a text

use python language to complete the Titleparser part and the BizzaroGUI part image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1. Finish the BizzaroGUI implementation. The BizzaroGUI does three things: Has a text box you can enter a URL and retrieve the title of the web page. Enter a folder name and retrieve the depthCount of the folder (recursive function provided for you.) Enter a question and have the Magic8Ball answer it for you (Magic8Ball class provided). You need to 'shake' the Magic8Ball each time a user enters a question and clear the Entry field a. b. c. Enter a url and click "Get Title" button: Bizzaro G Enter URL: http://zoko.cdm.depaul.edu Enter Folder SetTitle GetDepth Count Ask Question Get Magic Answer Results in: The answer... Zoko Web Server OK Enter a folder name and press GetDepth Count' button. This example traverses the Test folder provided in the zip file. Make sure your.py is in the same folder that the test folder Bizzaro GUI Enter URL: Enter Folder: Test Get Title GetDepth Count Get Magic Answer Ask Question: /The ans....x OK Finally, ask a Question and click 'Get Magic Answer": Bizzaro GU Eate URLGe Tole Enter URL: Get Title GetDepth Count Enter Folder: Ask Question: Will this help the students understand events? Get Magic Answer Whew: The answer.. The answer to your question Will this help the students understand events? is Outlook good OK If you get done early, think about how you can optimize the interface and just use one edit widget. import os def nestingCount (pathname): largest-0 for item in os. listdir (pathname): os, path, join (pathname, item) n if os. path. isdir(n): = = nest ingCount (n) depth if depth > largest: largest = depth return 1+largest fron html. parser import HTMLParser from urllib. parse import urljoin from urllib. request import urlopen class TitleParser (HTMLParser): def init (self): HTMLParser. _init_ (self) pass def handle starttag (self, tag, attrs): def handle endtag (self, tag): def handle_data (self, data): def getTitle(self): pass pass pass pass from random import randrange lass Magic8Bal1 (object): def init__ (self, q-[]): the constructo if len(q)0: q. append It is certain) q. append( It is decidedly so) q. append ( Without a doubt) q. append ( Yes definitely) q. append( You may rely on it) q. append C As I see it, yes') q. append( Most 1ikely) q. append( Outlook good) q. append ( Yes') q. append ( Signs point to yes') q. append( Reply hazy try again) q. append( Ask again later q. append( Better not tel1 you now') q. appendC Cannot predict now) q. append( Concentrate and ask again) q. append (Don' t count on it") q. append(' My reply is no') q. append( My sources say no) q. append( outlook not so good') q append ( Very doubtful') self. q q self. current-randrange (0, len(self. q)) def shake (self): get the next answer seif. current-randrange (0, len (self.a)) def get (self): get the current answer return self. qlself. current] def numAnswers (self): get the number of answers in the ball' return 1en(self. q) def iter _(self): get the iterator return iter (self. q def _str__(selt): string representation return I am a Magic 8 Ball with 0 answers'. format (1en(self. qa)) from tkinter import Button, Entry, Label, Tk, TOP, LEFT, RIGHT, END from tkinter. messagebox import showinfo class BizzaroGUI (Tk): Number guessing app def -init (self,parent-None) : constructor Tk. init_ (self, parent) pass def getTitle(self): #1 left the following line as hint. #content urlopen(url), read(), decode() pass def getFo1derDepth (self): def getAnswer (self): def make widgets (self): pass pass pass 1. Finish the BizzaroGUI implementation. The BizzaroGUI does three things: Has a text box you can enter a URL and retrieve the title of the web page. Enter a folder name and retrieve the depthCount of the folder (recursive function provided for you.) Enter a question and have the Magic8Ball answer it for you (Magic8Ball class provided). You need to 'shake' the Magic8Ball each time a user enters a question and clear the Entry field a. b. c. Enter a url and click "Get Title" button: Bizzaro G Enter URL: http://zoko.cdm.depaul.edu Enter Folder SetTitle GetDepth Count Ask Question Get Magic Answer Results in: The answer... Zoko Web Server OK Enter a folder name and press GetDepth Count' button. This example traverses the Test folder provided in the zip file. Make sure your.py is in the same folder that the test folder Bizzaro GUI Enter URL: Enter Folder: Test Get Title GetDepth Count Get Magic Answer Ask Question: /The ans....x OK Finally, ask a Question and click 'Get Magic Answer": Bizzaro GU Eate URLGe Tole Enter URL: Get Title GetDepth Count Enter Folder: Ask Question: Will this help the students understand events? Get Magic Answer Whew: The answer.. The answer to your question Will this help the students understand events? is Outlook good OK If you get done early, think about how you can optimize the interface and just use one edit widget. import os def nestingCount (pathname): largest-0 for item in os. listdir (pathname): os, path, join (pathname, item) n if os. path. isdir(n): = = nest ingCount (n) depth if depth > largest: largest = depth return 1+largest fron html. parser import HTMLParser from urllib. parse import urljoin from urllib. request import urlopen class TitleParser (HTMLParser): def init (self): HTMLParser. _init_ (self) pass def handle starttag (self, tag, attrs): def handle endtag (self, tag): def handle_data (self, data): def getTitle(self): pass pass pass pass from random import randrange lass Magic8Bal1 (object): def init__ (self, q-[]): the constructo if len(q)0: q. append It is certain) q. append( It is decidedly so) q. append ( Without a doubt) q. append ( Yes definitely) q. append( You may rely on it) q. append C As I see it, yes') q. append( Most 1ikely) q. append( Outlook good) q. append ( Yes') q. append ( Signs point to yes') q. append( Reply hazy try again) q. append( Ask again later q. append( Better not tel1 you now') q. appendC Cannot predict now) q. append( Concentrate and ask again) q. append (Don' t count on it") q. append(' My reply is no') q. append( My sources say no) q. append( outlook not so good') q append ( Very doubtful') self. q q self. current-randrange (0, len(self. q)) def shake (self): get the next answer seif. current-randrange (0, len (self.a)) def get (self): get the current answer return self. qlself. current] def numAnswers (self): get the number of answers in the ball' return 1en(self. q) def iter _(self): get the iterator return iter (self. q def _str__(selt): string representation return I am a Magic 8 Ball with 0 answers'. format (1en(self. qa)) from tkinter import Button, Entry, Label, Tk, TOP, LEFT, RIGHT, END from tkinter. messagebox import showinfo class BizzaroGUI (Tk): Number guessing app def -init (self,parent-None) : constructor Tk. init_ (self, parent) pass def getTitle(self): #1 left the following line as hint. #content urlopen(url), read(), decode() pass def getFo1derDepth (self): def getAnswer (self): def make widgets (self): pass pass pass

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

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions