Skip to main content

Section 14.6 Write Code Questions - Parsons for Select

Activity 14.6.1.

Create a function called cur_stud_link(soup) that takes a soup object and returns the URL that links to Current Students in the Navigation Bar. The soup object is created from the file UMich-8-16-2026.html which is a saved version of “https://umich.edu/” from 2026. Click on the following link to view the source:link. For example, cur_stud_link(soup) should return 'https://umich.edu/web/20260808043645/https://umich.edu/current-students/'.

Activity 14.6.2.

Create a function called headings(soup) that takes a soup object and returns a list of the text from all h2 tags in the soup. The soup object is created from the file MOOC-Wikipedia-8-20-2026.html which is a saved version of “https://en.wikipedia.org/wiki/Massive_open_online_course” from 2026. Click on the following link to view the source: link For example, headings(soup) should return a list of 14 headings starting with ['Contents', 'History', 'Equity and access', ...].

Activity 14.6.3.

Create a function called coursera_dict(soup) that takes a soup object and returns a dictionary with Country as keys and Percentage as values. The soup object is created from the file ’WikipediaMOOC-Jan-12-2018.html’ which is a saved version of “https://en.wikipedia.org/wiki/Massive_open_online_course” from 2018. Click on the following link to view the source: link For example, coursera_dict(soup) should return a dictionary like: {'United States': '27.7%', 'India': '8.8%', 'Brazil': '5.1%', ...}.

Activity 14.6.4.

Create a function called keywords(soup) that takes a soup object and returns a list of Python keywords. The soup object is created from the file PythonKeywords.html which is a saved version of “https://www.w3schools.com/python/python_ref_keywords.asp” from 2026. Click on the following link to view the source: link. For example, keywords(soup) should return a list that starts with: ['and', 'as', ...].

Activity 14.6.5.

Create a function called movies(soup) that takes a soup object and returns a list of the top box office movies. The soup object is created from the file top-box-office-8-2026.html which is a saved version of “https://www.imdb.com/chart/boxoffice/” from Aug 7-9th 2026. Click on the following link to view the source: link. For example, movies(soup) should return a list that starts with: ['Spider-Man: Brand New Day', 'The Odyssey', 'One Night Only', ...].

Activity 14.6.6.

Write a function called bsi_list(soup) that takes in a parameter soup and returns a list of the section names and subsection names under Programs-Bachelor of Science in Information. The soup object is created from the file BSI-Aug-3-2023.html which is a saved version of “https://www.si.umich.edu/programs/bachelor-science-information” from Aug 3rd 2023. Click on the following link to view the source: link. For example, bsi_list(soup) should return a list that starts with: ['How do I apply?', 'Current U-M students', 'Transfer students', ...].

Activity 14.6.7.

Create a function called bsi_dict(soup) that takes in a parameter soup and returns a list of the section names and subsection names under Programs-Bachelor of Science in Information. The soup object is created from the file BSI-Aug-3-2023.html which is a saved version of “https://www.si.umich.edu/programs/bachelor-science-information” from Aug 3rd 2023. Click on the following link to view the source: link. For example, bsi_list(soup) should return a dictionary that starts with: [.

Activity 14.6.8.

Create a function called envelope_address that takes in a parameter url and uses BeautifulSoup to web scrape and return the address text in the footer as a list. For example, envelope_address('https://www.si.umich.edu/programs/bachelor-science-information') should return a list like: ['School of Information', 'University of Michigan', ...]. Since we are scraping a live site the results may be different.

Activity 14.6.9.

Create a function called names(soup) that takes in a parameter soup, and returns a list with the faculty names. The soup object is created from the file FacultyUMSI-7-30-2025.html which is a saved version of “https://www.si.umich.edu/people/directory/faculty/e” from July 30th 2025. Click on the following link to view the source: link. For example, names(souop) should return ['Paul Edwards', 'Ron Eglash', ...].

Activity 14.6.10.

Create a function called program_email that takes in a parameter url, uses BeautifulSoup to web scrape the program names under Email Addresses and Admissions (BSI program, MSI program, etc.) and their associated email addresses, and returns a dictionary with the program names as keys and the email addresses as values. For example, program_email('https://www.si.umich.edu/about-umsi/contact-us') should return something like {'BSI program': '[email protected]', 'MSI program': '[email protected]', ...}. Since we are scraping a live site the results may be different.
You have attempted of activities on this page.