SlideShare a Scribd company logo
1 of 17
programminghomeworkhelp.com
For any help regarding Python Assignment Help
Visit : https://www.programminghomeworkhelp.com/, Email
: support@programminghomeworkhelp.com or
call us at : +1 678 648 4277
Python Homework Help
Quick Reference
D = { } – creates an empty dictionary
D = {key1:value1, …} – creates a non-empty dictionary
D[key] – returns the value that’s mapped to by key. (What if there’s no such
key?) D[key] = newvalue – maps newvalue to key. Overwrites any previous
value. del D[key] – deletes the mapping with that key from D.
len(D) – returns the number of entries (mappings) in D.
x in D, x not in D – checks whether the key x is in the dictionary D.
Problem 1 – Names and Ages
(You can copy the below code into a file, but you can also optionally download this
code
in a pre-written file, namesages.py.)
Define two lists at the top of your file:
NAMES = [“Alice”, “Bob”, “Cathy”, “Dan”, “Ed”, “Frank”,
“Gary”, “Helen”,“Irene”, “Jack”, “Kelly”, “Larry”]
AGES = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19]
Problems:
programminghomeworkhelp.com
These lists match up, so Alice’s age is 20, Bob’s age is 21, and so on.
Write a program that combines these lists into a dictionary. Then, write a function that,
given an age, returns the names of all the people who are that age.
Test your program and function by running these lines: (replace people with your function)
print people(18) == [“Cathy”, “Dan”]
print people(19) == [“Ed”, “Helen”, “Irene”, “Jack”, “Larry”]
print people(20) == [“Alice”, “Frank”, “Gary”]
print people(21) == [“Bob”]
print people(22) == [“Kelly”]
print people(23) == [ ]
All lines should print True. If the last line is giving you an error, look at the name of the error.
Problem 2 – Indexing the Web, Part 1
Every day, we search the web. When we type in a search term like “MIT” into Google,
how does Google give us our results so fast? That’s a loaded question to answer, but in
this problem we’ll study the bulk of the response.
In computer science, we model the web as a graph, where each node (vertex) is a
webpage and each edge is a link we can click on. When we navigate the web, we’re
navigating this graph – each link we click on moves us from a node to a neighboring
node on the web. programminghomeworkhelp.com
Google wants to search every page on the internet, so it has to somehow navigate this
graph. That’s a daunting task, and how exactly you go about navigating the web so that you
can reach every page is a major challenge, so we’re going to ignore that. Instead, we’re
going to assume that we’ve seen every page and we have a giant list of pages that we’ve
read.
So now, when we search for something on Google, does Google scan every page and see
which ones have the words we’re searching for? Well, there are on the order of 10 billion
webpages out there (maybe closer to 100 billion now*), so even if Google could check an
average page for your words in 0.01 seconds, it would take on the order of 100 million
seconds, or 3 years. So clearly, Google isn’t doing the searching on the spot.
To fix this problem, we’re going to use the analogy of a textbook. We want to find which pages
mention a certain word. Similar to Google’s problem above, if we read page by page and kept
track of which pages mentioned the word, it would take us hours, maybe days.
So instead, most textbooks come with a pre-built index. The index allows us to easily look
up which pages contain the word we’re looking for. In the same way, Google has pre-built
(and is continually updating) their index. Their index allows them to look up any word, and see
what sites mention that word.
So now, when you search for a word, Google quickly looks up the word in its index (a
massively faster procedure) and returns the sites that mention that word.** In this part of the
problem, we’re going to build a similar index for a small number of sites. We’ll then be able to
use the index as part of a simple search engine.
programminghomeworkhelp.com
To begin, download the following files:
webindexer1.py – this is the file in which you’ll write all of your code.
websearch1.py – this completed program is a search engine that will use your index.
htmltext.py – this module takes care of parsing HTML into text.
smallsites.txt, mitsites20.txt, mitsites50.txt – these files list the URLs of 10, 20 and 50
sites respectively that we will index and use for our searches.
** The use of an index is nothing new. Every search engine before Google used an index
too – you have to. Google’s fame and success came mostly due to their rankings (the
order of the results). We’ll explore rankings in part 2, but unfortunately, understanding
Google’s ranking algorithm requires an understanding of graph theory. So instead, we’ll
use an older approach.
Let’s take a look at the main program, websearch1.py. This program lets the user
repeatedly enter a search string and view the results. This isn’t a difficult program to write,
and it’s nothing you haven’t seen before, so I went ahead and wrote the full thing. Take a
look and make sure you understand it.
It uses two functions which aren’t in the program, build_index and
search_multiple_words. Both are part of webindexer1.py, so let’s open that up and take a
look. This is a stub file where I’ve defined a bunch of functions for you, and some are
implemented whereas others are not.
Near the top, we’ve defined a variable called index, which is initially set to an empty
dictionary. Below that, I’ve implemented a few helper functions to take care of some of the
logistics. At the bottom is the build_index function. It retrieves all the sites listed in
FILENAME (initially set to the smallest file), reads them and finally indexes them. We’ll
have to implement the function index_site, which does the actual indexing.
programminghomeworkhelp.com
Task 1 – Implement the index_site function. If you’re stuck, this is analogous to
index_page for a textbook. What does the index at the back of a textbook look like? In
terms of a dictionary, what are the keys and what are the values? How will you modify the
dictionary if you’re given another page?
Hints: “he came, he saw”.split ( ) returns [“he”, “came,”, “he”, “saw”]. Don’t worry about
punctuation. Make sure to use only lowercase words, as the search program converts all
search strings into lowercase first.
Once we’ve indexed our sites, we’re able to search them! We see that the search
program calls search_multiple_words in order to handle a multi-word search string.
Before we think about multiple words, let’s solve the problem of searching for one word.
Task 2 – Implement the search_single_word function. If you’ve designed your index
well, this should be pretty trivial. But make sure you’re accounting for all cases!
Now that we can handle one word, we’ll use our solution to handle multiple words. The
only question is, should we treat a multiple-word search as “sites that have ALL of these
words”, or “sites that have ANY of these words”? The latter is considerably easier to
implement than the former, and it’s what most search engines do as well, so we’ll do
“any”.
Task 3 – Implement the search_multiple_words function. The argument words is a
list, not a string. Make sure you don’t return duplicate sites in your list!
programminghomeworkhelp.com
You should now have a working indexer, so run websearch1.py and try it out!
By default, FILENAME is set to the smallest file, which lists 10 sites (3 at google, 4 at MIT
and 3 at facebook). These sites were chosen specifically because they are small, so they’re
fast to load. If your search engine seems to work fine, try mitsites20.txt, which lists the top
20 sites for a Google search of “MIT”. Finally, if you are willing to wait a few minutes, try
mitsites50.txt, which lists the top 50 sites for the same search.
On the next page, I’ve pasted my output for a few searches from the default smallest file. If
your output is quite different, you may have done something wrong. If it’s just slightly
different, it may just be a change in the pages (e.g. web.mit.edu) from when I indexed the
site to when you did.
Here is my output:
6.189 Web Search! (version 1)
Building the index... (this may take a while) Done!
At any time, you may search for "QUIT" to quit.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
What would you like to search for? people google
6 site(s) found with the terms "people google": programminghomeworkhelp.com
http://www.google.com/intl/en/ads/
http://web.mit.edu/ http://www.eecs.mit.edu/
http://www.facebook.com/ http://www.google.com/
http://images.google.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
What would you like to search for? ads
2 site(s) found with the terms "ads":
http://www.google.com/intl/en/ads/
http://www.facebook.com/ads/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
What would you like to search for? ADS
2 site(s) found with the terms "ADS":
http://www.google.com/intl/en/ads/
http://www.facebook.com/ads/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
What would you like to search for? advertisements No
sites found with the terms "advertisements".
Try a broader search.
programminghomeworkhelp.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
What would you like to search for? QUIT Thanks
for searching!
# namesages.py
# Stub file for lab 9, problem 1
#
# 6.189 - Intro to Python
# IAP 2008 - Class 8
NAMES = ["Alice", "Bob", "Cathy", "Dan", "Ed", "Frank",
"Gary", "Helen", "Irene", "Jack", "Kelly", "Larry"]
AGES = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19]
# Put code here that will combine these lists into a dictionary
# You can rename this function
def people(age):
""" Return the names of all the people who are the given age. """
# your code here
pass # delete this line when you write your code
programminghomeworkhelp.com
# Testing
print people(18) == ["Cathy", "Dan"]
print people(19) == ["Ed", "Helen", "Irene", "Jack", "Larry"]
print people(20) == ["Alice", "Frank", "Gary"]
print people(21) == ["Bob"]
print people(22) == ["Kelly"]
print people(23) == []
# webindexer1.py
# Stub file for lab 9, problem 2
#
# 6.189 - Intro to Python
# IAP 2008 - Class 8
from urllib import urlopen
from htmltext import HtmlTextParser
FILENAME = "smallsites.txt"
index = {}
def get_sites():
""" Return all the sites that are in FILENAME. """
sites_file = open(FILENAME)
programminghomeworkhelp.com
sites = []
for site in sites_file:
sites.append("http://" + site.strip())
return sites
def read_site(site):
""" Attempt to read the given site. Return the text of the site if
successful, otherwise returns False. """
try:
connection = urlopen(site)
html = connection.read()
connection.close()
except:
return False
parser = HtmlTextParser()
parser.parse(html)
return parser.get_text()
def index_site(site, text):
""" Index the given site with the given text. """
# YOUR CODE HERE #
pass # delete this when you write your code
def search_single_word(word):
""" Return a list of sites containing the given word. """
programminghomeworkhelp.com
# YOUR CODE HERE #
pass # delete this when you write your code
def search_multiple_words(words):
""" Return a list of sites containing any of the given words. """
# YOUR CODE HERE #
pass # delete this when you write your code
def build_index():
""" Build the index by reading and indexing each site. """
for site in get_sites():
text = read_site(site)
while text == False:
text = read_site(site) # keep attempting to read until successful
index_site(site, text)
programminghomeworkhelp.com
Solutions
# namesages.py
# Stub file for lab 9, problem 1
#
# 6.189 - Intro to Python
# IAP 2008 - Class 8
NAMES = ["Alice", "Bob", "Cathy", "Dan", "Ed", "Frank",
"Gary", "Helen", "Irene", "Jack", "Kelly", "Larry"]
AGES = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19]
# Put code here that will combine these lists into a dictionary
ages_to_names = {}
for i in range(len(NAMES)):
name = NAMES[i]
age = AGES[i]
if age in ages_to_names:
ages_to_names[age].append(name)
else:
ages_to_names[age] = [name] # the LIST containing the name
programminghomeworkhelp.com
# You can rename this function
def people(age):
""" Return the names of all the people who are the given age. """
if age in ages_to_names:
return ages_to_names[age]
return []
# Testing
print people(18) == ["Cathy", "Dan"]
print people(19) == ["Ed", "Helen", "Irene", "Jack", "Larry"]
print people(20) == ["Alice", "Frank", "Gary"]
print people(21) == ["Bob"]
print people(22) == ["Kelly"]
print people(23) == []
# webindexer1.py
# Stub file for lab 9, problem 2
#
# 6.189 - Intro to Python
# IAP 2008 - Class 8
from urllib import urlopen
from htmltext import HtmlTextParser programminghomeworkhelp.com
FILENAME = "smallsites.txt"
index = {}
def get_sites():
""" Return all the sites that are in FILENAME. """
sites_file = open(FILENAME)
sites = []
for site in sites_file:
sites.append("http://" + site.strip())
return sites
def read_site(site):
""" Attempt to read the given site. Return the text of the site if
successful, otherwise returns False. """
try:
connection = urlopen(site)
html = connection.read()
connection.close()
except:
return False
parser = HtmlTextParser()
parser.parse(html)
return parser.get_text()
programminghomeworkhelp.com
def index_site(site, text):
""" Index the given site with the given text. """
words = text.lower().split()
for word in words:
if word not in index: # case 1: haven't seen this word ever
index[word] = [ site ] # make a new list for the word
elif site not in index: # case 2: haven't seen word on this site
index[word].append(site) # add this site to this word's list
# case 3: have included site for word
# do nothing (ignore this word)
def search_single_word(word):
""" Return a list of sites containing the given word. """
if word not in index:
return []
return index[word]
def search_multiple_words(words):
""" Return a list of sites containing any of the given words. """
all_sites = []
for word in words:
sites = search_single_word(word)
for site in sites:
if site not in all_sites:
all_sites.append(site)
return all_sites
programminghomeworkhelp.com
def build_index():
""" Build the index by reading and indexing each site. """
for site in get_sites():
text = read_site(site)
while text == False:
text = read_site(site) # keep attempting to read until successful
index_site(site, text)
programminghomeworkhelp.com

More Related Content

What's hot

Learning puppet chapter 2
Learning puppet chapter 2Learning puppet chapter 2
Learning puppet chapter 2Vishal Biyani
 
Creating native apps with WordPress
Creating native apps with WordPressCreating native apps with WordPress
Creating native apps with WordPressMarko Heijnen
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Parkpointstechgeeks
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kianphelios
 
9780538745840 ppt ch03
9780538745840 ppt ch039780538745840 ppt ch03
9780538745840 ppt ch03Terry Yoast
 
Programming in Computational Biology
Programming in Computational BiologyProgramming in Computational Biology
Programming in Computational BiologyAtreyiB
 
PHP Technical Questions
PHP Technical QuestionsPHP Technical Questions
PHP Technical QuestionsPankaj Jha
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 
Hadoop Streaming Tutorial With Python
Hadoop Streaming Tutorial With PythonHadoop Streaming Tutorial With Python
Hadoop Streaming Tutorial With PythonJoe Stein
 
Merging tables using R
Merging tables using R Merging tables using R
Merging tables using R Rupak Roy
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?lichtkind
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern PerlDave Cross
 
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...Puppet
 
SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09Elizabeth Smith
 
Writing and using php streams and sockets tek11
Writing and using php streams and sockets   tek11Writing and using php streams and sockets   tek11
Writing and using php streams and sockets tek11Elizabeth Smith
 

What's hot (20)

Learning puppet chapter 2
Learning puppet chapter 2Learning puppet chapter 2
Learning puppet chapter 2
 
Creating native apps with WordPress
Creating native apps with WordPressCreating native apps with WordPress
Creating native apps with WordPress
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
 
P4 2018 io_functions
P4 2018 io_functionsP4 2018 io_functions
P4 2018 io_functions
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
 
9780538745840 ppt ch03
9780538745840 ppt ch039780538745840 ppt ch03
9780538745840 ppt ch03
 
Programming in Computational Biology
Programming in Computational BiologyProgramming in Computational Biology
Programming in Computational Biology
 
PHP Technical Questions
PHP Technical QuestionsPHP Technical Questions
PHP Technical Questions
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
Hadoop Streaming Tutorial With Python
Hadoop Streaming Tutorial With PythonHadoop Streaming Tutorial With Python
Hadoop Streaming Tutorial With Python
 
Python For Large Company?
Python For Large Company?Python For Large Company?
Python For Large Company?
 
Merging tables using R
Merging tables using R Merging tables using R
Merging tables using R
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern Perl
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 
Power of Puppet 4
Power of Puppet 4Power of Puppet 4
Power of Puppet 4
 
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
 
SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09
 
Linux intro 5 extra: makefiles
Linux intro 5 extra: makefilesLinux intro 5 extra: makefiles
Linux intro 5 extra: makefiles
 
Writing and using php streams and sockets tek11
Writing and using php streams and sockets   tek11Writing and using php streams and sockets   tek11
Writing and using php streams and sockets tek11
 

Similar to Python Homework Help

Google ppt by amit
Google ppt by amitGoogle ppt by amit
Google ppt by amitDAVV
 
Software Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good ArchitectureSoftware Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good Architecturemahmud05
 
20 great google secrets
20 great google secrets20 great google secrets
20 great google secretsShakil Malik
 
Search Engine Optimization - Aykut Aslantaş
Search Engine Optimization - Aykut AslantaşSearch Engine Optimization - Aykut Aslantaş
Search Engine Optimization - Aykut AslantaşAykut Aslantaş
 
Search engines coh m
Search engines coh mSearch engines coh m
Search engines coh mcpcmattc
 
SearchLove San Diego 2017 | Will Critchlow | Knowing Ranking Factors Won't Be...
SearchLove San Diego 2017 | Will Critchlow | Knowing Ranking Factors Won't Be...SearchLove San Diego 2017 | Will Critchlow | Knowing Ranking Factors Won't Be...
SearchLove San Diego 2017 | Will Critchlow | Knowing Ranking Factors Won't Be...Distilled
 
A gentle introduction to algorithm complexity analysis
A gentle introduction to algorithm complexity analysisA gentle introduction to algorithm complexity analysis
A gentle introduction to algorithm complexity analysisLewis Lin 🦊
 
professional fuzzy type-ahead rummage around in xml type-ahead search techni...
professional fuzzy type-ahead rummage around in xml  type-ahead search techni...professional fuzzy type-ahead rummage around in xml  type-ahead search techni...
professional fuzzy type-ahead rummage around in xml type-ahead search techni...Kumar Goud
 
Upwork time log and difficulty 20160523
Upwork time log and difficulty 20160523Upwork time log and difficulty 20160523
Upwork time log and difficulty 20160523Sharon Liu
 
Viacheslav Eremin interview about DOT NET (eng lang)
Viacheslav Eremin interview about DOT NET (eng lang)Viacheslav Eremin interview about DOT NET (eng lang)
Viacheslav Eremin interview about DOT NET (eng lang)Viacheslav Eremin
 

Similar to Python Homework Help (20)

Google ppt by amit
Google ppt by amitGoogle ppt by amit
Google ppt by amit
 
Google
GoogleGoogle
Google
 
Google Searchology
Google SearchologyGoogle Searchology
Google Searchology
 
Internet search techniques by zakir hossain
Internet search techniques by zakir hossainInternet search techniques by zakir hossain
Internet search techniques by zakir hossain
 
Software Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good ArchitectureSoftware Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good Architecture
 
20 great google secrets
20 great google secrets20 great google secrets
20 great google secrets
 
20 great google secrets
20 great google secrets20 great google secrets
20 great google secrets
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Gaps in the algorithm
Gaps in the algorithmGaps in the algorithm
Gaps in the algorithm
 
20 great google secrets
20 great google secrets20 great google secrets
20 great google secrets
 
Search Engine Optimization - Aykut Aslantaş
Search Engine Optimization - Aykut AslantaşSearch Engine Optimization - Aykut Aslantaş
Search Engine Optimization - Aykut Aslantaş
 
Search engines coh m
Search engines coh mSearch engines coh m
Search engines coh m
 
SearchLove San Diego 2017 | Will Critchlow | Knowing Ranking Factors Won't Be...
SearchLove San Diego 2017 | Will Critchlow | Knowing Ranking Factors Won't Be...SearchLove San Diego 2017 | Will Critchlow | Knowing Ranking Factors Won't Be...
SearchLove San Diego 2017 | Will Critchlow | Knowing Ranking Factors Won't Be...
 
A gentle introduction to algorithm complexity analysis
A gentle introduction to algorithm complexity analysisA gentle introduction to algorithm complexity analysis
A gentle introduction to algorithm complexity analysis
 
Internet search techniques for K12
Internet search techniques for K12Internet search techniques for K12
Internet search techniques for K12
 
professional fuzzy type-ahead rummage around in xml type-ahead search techni...
professional fuzzy type-ahead rummage around in xml  type-ahead search techni...professional fuzzy type-ahead rummage around in xml  type-ahead search techni...
professional fuzzy type-ahead rummage around in xml type-ahead search techni...
 
Upwork time log and difficulty 20160523
Upwork time log and difficulty 20160523Upwork time log and difficulty 20160523
Upwork time log and difficulty 20160523
 
Viacheslav Eremin interview about DOT NET (eng lang)
Viacheslav Eremin interview about DOT NET (eng lang)Viacheslav Eremin interview about DOT NET (eng lang)
Viacheslav Eremin interview about DOT NET (eng lang)
 
MyReplayInZen
MyReplayInZenMyReplayInZen
MyReplayInZen
 
BDACA - Lecture6
BDACA - Lecture6BDACA - Lecture6
BDACA - Lecture6
 

More from Programming Homework Help

Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpProgramming Homework Help
 
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxprogramminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxProgramming Homework Help
 

More from Programming Homework Help (20)

C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 
Python Question - Python Assignment Help
Python Question - Python Assignment HelpPython Question - Python Assignment Help
Python Question - Python Assignment Help
 
Best Algorithms Assignment Help
Best Algorithms Assignment Help Best Algorithms Assignment Help
Best Algorithms Assignment Help
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxprogramminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
Algorithms Design Assignment Help
Algorithms Design Assignment HelpAlgorithms Design Assignment Help
Algorithms Design Assignment Help
 
Algorithms Design Homework Help
Algorithms Design Homework HelpAlgorithms Design Homework Help
Algorithms Design Homework Help
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
Computer Science Assignment Help
Computer Science Assignment Help Computer Science Assignment Help
Computer Science Assignment Help
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
Software Construction Assignment Help
Software Construction Assignment HelpSoftware Construction Assignment Help
Software Construction Assignment Help
 
C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Recently uploaded (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 

Python Homework Help

  • 1. programminghomeworkhelp.com For any help regarding Python Assignment Help Visit : https://www.programminghomeworkhelp.com/, Email : support@programminghomeworkhelp.com or call us at : +1 678 648 4277 Python Homework Help
  • 2. Quick Reference D = { } – creates an empty dictionary D = {key1:value1, …} – creates a non-empty dictionary D[key] – returns the value that’s mapped to by key. (What if there’s no such key?) D[key] = newvalue – maps newvalue to key. Overwrites any previous value. del D[key] – deletes the mapping with that key from D. len(D) – returns the number of entries (mappings) in D. x in D, x not in D – checks whether the key x is in the dictionary D. Problem 1 – Names and Ages (You can copy the below code into a file, but you can also optionally download this code in a pre-written file, namesages.py.) Define two lists at the top of your file: NAMES = [“Alice”, “Bob”, “Cathy”, “Dan”, “Ed”, “Frank”, “Gary”, “Helen”,“Irene”, “Jack”, “Kelly”, “Larry”] AGES = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] Problems: programminghomeworkhelp.com
  • 3. These lists match up, so Alice’s age is 20, Bob’s age is 21, and so on. Write a program that combines these lists into a dictionary. Then, write a function that, given an age, returns the names of all the people who are that age. Test your program and function by running these lines: (replace people with your function) print people(18) == [“Cathy”, “Dan”] print people(19) == [“Ed”, “Helen”, “Irene”, “Jack”, “Larry”] print people(20) == [“Alice”, “Frank”, “Gary”] print people(21) == [“Bob”] print people(22) == [“Kelly”] print people(23) == [ ] All lines should print True. If the last line is giving you an error, look at the name of the error. Problem 2 – Indexing the Web, Part 1 Every day, we search the web. When we type in a search term like “MIT” into Google, how does Google give us our results so fast? That’s a loaded question to answer, but in this problem we’ll study the bulk of the response. In computer science, we model the web as a graph, where each node (vertex) is a webpage and each edge is a link we can click on. When we navigate the web, we’re navigating this graph – each link we click on moves us from a node to a neighboring node on the web. programminghomeworkhelp.com
  • 4. Google wants to search every page on the internet, so it has to somehow navigate this graph. That’s a daunting task, and how exactly you go about navigating the web so that you can reach every page is a major challenge, so we’re going to ignore that. Instead, we’re going to assume that we’ve seen every page and we have a giant list of pages that we’ve read. So now, when we search for something on Google, does Google scan every page and see which ones have the words we’re searching for? Well, there are on the order of 10 billion webpages out there (maybe closer to 100 billion now*), so even if Google could check an average page for your words in 0.01 seconds, it would take on the order of 100 million seconds, or 3 years. So clearly, Google isn’t doing the searching on the spot. To fix this problem, we’re going to use the analogy of a textbook. We want to find which pages mention a certain word. Similar to Google’s problem above, if we read page by page and kept track of which pages mentioned the word, it would take us hours, maybe days. So instead, most textbooks come with a pre-built index. The index allows us to easily look up which pages contain the word we’re looking for. In the same way, Google has pre-built (and is continually updating) their index. Their index allows them to look up any word, and see what sites mention that word. So now, when you search for a word, Google quickly looks up the word in its index (a massively faster procedure) and returns the sites that mention that word.** In this part of the problem, we’re going to build a similar index for a small number of sites. We’ll then be able to use the index as part of a simple search engine. programminghomeworkhelp.com
  • 5. To begin, download the following files: webindexer1.py – this is the file in which you’ll write all of your code. websearch1.py – this completed program is a search engine that will use your index. htmltext.py – this module takes care of parsing HTML into text. smallsites.txt, mitsites20.txt, mitsites50.txt – these files list the URLs of 10, 20 and 50 sites respectively that we will index and use for our searches. ** The use of an index is nothing new. Every search engine before Google used an index too – you have to. Google’s fame and success came mostly due to their rankings (the order of the results). We’ll explore rankings in part 2, but unfortunately, understanding Google’s ranking algorithm requires an understanding of graph theory. So instead, we’ll use an older approach. Let’s take a look at the main program, websearch1.py. This program lets the user repeatedly enter a search string and view the results. This isn’t a difficult program to write, and it’s nothing you haven’t seen before, so I went ahead and wrote the full thing. Take a look and make sure you understand it. It uses two functions which aren’t in the program, build_index and search_multiple_words. Both are part of webindexer1.py, so let’s open that up and take a look. This is a stub file where I’ve defined a bunch of functions for you, and some are implemented whereas others are not. Near the top, we’ve defined a variable called index, which is initially set to an empty dictionary. Below that, I’ve implemented a few helper functions to take care of some of the logistics. At the bottom is the build_index function. It retrieves all the sites listed in FILENAME (initially set to the smallest file), reads them and finally indexes them. We’ll have to implement the function index_site, which does the actual indexing. programminghomeworkhelp.com
  • 6. Task 1 – Implement the index_site function. If you’re stuck, this is analogous to index_page for a textbook. What does the index at the back of a textbook look like? In terms of a dictionary, what are the keys and what are the values? How will you modify the dictionary if you’re given another page? Hints: “he came, he saw”.split ( ) returns [“he”, “came,”, “he”, “saw”]. Don’t worry about punctuation. Make sure to use only lowercase words, as the search program converts all search strings into lowercase first. Once we’ve indexed our sites, we’re able to search them! We see that the search program calls search_multiple_words in order to handle a multi-word search string. Before we think about multiple words, let’s solve the problem of searching for one word. Task 2 – Implement the search_single_word function. If you’ve designed your index well, this should be pretty trivial. But make sure you’re accounting for all cases! Now that we can handle one word, we’ll use our solution to handle multiple words. The only question is, should we treat a multiple-word search as “sites that have ALL of these words”, or “sites that have ANY of these words”? The latter is considerably easier to implement than the former, and it’s what most search engines do as well, so we’ll do “any”. Task 3 – Implement the search_multiple_words function. The argument words is a list, not a string. Make sure you don’t return duplicate sites in your list! programminghomeworkhelp.com
  • 7. You should now have a working indexer, so run websearch1.py and try it out! By default, FILENAME is set to the smallest file, which lists 10 sites (3 at google, 4 at MIT and 3 at facebook). These sites were chosen specifically because they are small, so they’re fast to load. If your search engine seems to work fine, try mitsites20.txt, which lists the top 20 sites for a Google search of “MIT”. Finally, if you are willing to wait a few minutes, try mitsites50.txt, which lists the top 50 sites for the same search. On the next page, I’ve pasted my output for a few searches from the default smallest file. If your output is quite different, you may have done something wrong. If it’s just slightly different, it may just be a change in the pages (e.g. web.mit.edu) from when I indexed the site to when you did. Here is my output: 6.189 Web Search! (version 1) Building the index... (this may take a while) Done! At any time, you may search for "QUIT" to quit. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - What would you like to search for? people google 6 site(s) found with the terms "people google": programminghomeworkhelp.com
  • 8. http://www.google.com/intl/en/ads/ http://web.mit.edu/ http://www.eecs.mit.edu/ http://www.facebook.com/ http://www.google.com/ http://images.google.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - What would you like to search for? ads 2 site(s) found with the terms "ads": http://www.google.com/intl/en/ads/ http://www.facebook.com/ads/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - What would you like to search for? ADS 2 site(s) found with the terms "ADS": http://www.google.com/intl/en/ads/ http://www.facebook.com/ads/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - What would you like to search for? advertisements No sites found with the terms "advertisements". Try a broader search. programminghomeworkhelp.com
  • 9. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - What would you like to search for? QUIT Thanks for searching! # namesages.py # Stub file for lab 9, problem 1 # # 6.189 - Intro to Python # IAP 2008 - Class 8 NAMES = ["Alice", "Bob", "Cathy", "Dan", "Ed", "Frank", "Gary", "Helen", "Irene", "Jack", "Kelly", "Larry"] AGES = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] # Put code here that will combine these lists into a dictionary # You can rename this function def people(age): """ Return the names of all the people who are the given age. """ # your code here pass # delete this line when you write your code programminghomeworkhelp.com
  • 10. # Testing print people(18) == ["Cathy", "Dan"] print people(19) == ["Ed", "Helen", "Irene", "Jack", "Larry"] print people(20) == ["Alice", "Frank", "Gary"] print people(21) == ["Bob"] print people(22) == ["Kelly"] print people(23) == [] # webindexer1.py # Stub file for lab 9, problem 2 # # 6.189 - Intro to Python # IAP 2008 - Class 8 from urllib import urlopen from htmltext import HtmlTextParser FILENAME = "smallsites.txt" index = {} def get_sites(): """ Return all the sites that are in FILENAME. """ sites_file = open(FILENAME) programminghomeworkhelp.com
  • 11. sites = [] for site in sites_file: sites.append("http://" + site.strip()) return sites def read_site(site): """ Attempt to read the given site. Return the text of the site if successful, otherwise returns False. """ try: connection = urlopen(site) html = connection.read() connection.close() except: return False parser = HtmlTextParser() parser.parse(html) return parser.get_text() def index_site(site, text): """ Index the given site with the given text. """ # YOUR CODE HERE # pass # delete this when you write your code def search_single_word(word): """ Return a list of sites containing the given word. """ programminghomeworkhelp.com
  • 12. # YOUR CODE HERE # pass # delete this when you write your code def search_multiple_words(words): """ Return a list of sites containing any of the given words. """ # YOUR CODE HERE # pass # delete this when you write your code def build_index(): """ Build the index by reading and indexing each site. """ for site in get_sites(): text = read_site(site) while text == False: text = read_site(site) # keep attempting to read until successful index_site(site, text) programminghomeworkhelp.com
  • 13. Solutions # namesages.py # Stub file for lab 9, problem 1 # # 6.189 - Intro to Python # IAP 2008 - Class 8 NAMES = ["Alice", "Bob", "Cathy", "Dan", "Ed", "Frank", "Gary", "Helen", "Irene", "Jack", "Kelly", "Larry"] AGES = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] # Put code here that will combine these lists into a dictionary ages_to_names = {} for i in range(len(NAMES)): name = NAMES[i] age = AGES[i] if age in ages_to_names: ages_to_names[age].append(name) else: ages_to_names[age] = [name] # the LIST containing the name programminghomeworkhelp.com
  • 14. # You can rename this function def people(age): """ Return the names of all the people who are the given age. """ if age in ages_to_names: return ages_to_names[age] return [] # Testing print people(18) == ["Cathy", "Dan"] print people(19) == ["Ed", "Helen", "Irene", "Jack", "Larry"] print people(20) == ["Alice", "Frank", "Gary"] print people(21) == ["Bob"] print people(22) == ["Kelly"] print people(23) == [] # webindexer1.py # Stub file for lab 9, problem 2 # # 6.189 - Intro to Python # IAP 2008 - Class 8 from urllib import urlopen from htmltext import HtmlTextParser programminghomeworkhelp.com
  • 15. FILENAME = "smallsites.txt" index = {} def get_sites(): """ Return all the sites that are in FILENAME. """ sites_file = open(FILENAME) sites = [] for site in sites_file: sites.append("http://" + site.strip()) return sites def read_site(site): """ Attempt to read the given site. Return the text of the site if successful, otherwise returns False. """ try: connection = urlopen(site) html = connection.read() connection.close() except: return False parser = HtmlTextParser() parser.parse(html) return parser.get_text() programminghomeworkhelp.com
  • 16. def index_site(site, text): """ Index the given site with the given text. """ words = text.lower().split() for word in words: if word not in index: # case 1: haven't seen this word ever index[word] = [ site ] # make a new list for the word elif site not in index: # case 2: haven't seen word on this site index[word].append(site) # add this site to this word's list # case 3: have included site for word # do nothing (ignore this word) def search_single_word(word): """ Return a list of sites containing the given word. """ if word not in index: return [] return index[word] def search_multiple_words(words): """ Return a list of sites containing any of the given words. """ all_sites = [] for word in words: sites = search_single_word(word) for site in sites: if site not in all_sites: all_sites.append(site) return all_sites programminghomeworkhelp.com
  • 17. def build_index(): """ Build the index by reading and indexing each site. """ for site in get_sites(): text = read_site(site) while text == False: text = read_site(site) # keep attempting to read until successful index_site(site, text) programminghomeworkhelp.com