QuestionQuestion

# Question 1
# - Write a function that takes in the html file name, 'disney_films', and returns a list of the titles
#       - of the films released in the 1940s.
#       - [ NOTE ] This is the 3rd table in the HTML file.
# - The file_name parameter will not include the file extension.
# - Entries should not include trailing whitespace characters such as "\n", "\t", " ", or "\xa0"
# - Ex.
#       >>> print(forties_list('disney_films'))
#               >>> ['Pinocchio', 'Fantasia', 'The Reluctant Dragon', 'Dumbo', 'Bambi',
#                        'Saludos Amigos', 'Victory Through Air Power', 'The Three Caballeros',
#                        'Make Mine Music', 'Song of the South', 'Fun and Fancy Free', 'Melody Time',
#                         'So Dear to My Heart', 'The Adventures of Ichabod and Mr. Toad']

def forties_list(file_name):
    pass

# Question 2
# - Write a function that takes in the html file name, 'disney_films' and returns a list of lists
#   - with each inner list representing a row in the table which consists of movies released in the 1930's.
#   - [ NOTE ] This is the 2nd table in the HTML file.
# - The file_name parameter will not include the file extension.
# - The first list should include the column headers of that table.
# - Entries should not include trailing whitespace characters such as "\n", "\t", " ", or "\xa0"
# - Ex.
#       >>> print(table_to_list('disney_films'))
#               >>> [['Title', 'US Release', 'Notes'], ['Academy Award Review of Walt Disney Cartoons', 'May 19, 1937', 'Anthology film'],
#                   ['Snow White and the Seven Dwarfs', 'December 21, 1937', '']]

def table_to_list(file_name):
    pass

# Question 3
# - Write a function that takes in the html file name, 'disney_films', and returns the number of films released
#       - in July of 1950.
#       - [ NOTE ] This is the 4th table in the HTML file.
# - Use the 1950's table to answer this question.
# - The file_name parameter will not include the file extension.
# - Ex.
#       >>> print(july_films('disney_films'))
#               >>> 5

def july_films(file_name):
    pass

# Question 4
# - Write a function that takes in the html file name, 'disney_films' and returns a list of all of the
#       - animated films released in the 1940s.
#       - [ NOTE ] This is the 3rd table in the HTML file.
# - Entries should not include trailing whitespace characters such as "\n", "\t", " ", or "\xa0"
# - The file_name parameter will not include the file extension.
# - Ex.
#       >>> print(animated_films('disney_films'))
#               >>> ['Pinocchio', 'Dumbo', 'Bambi', 'Make Mine Music', 'The Adventures of Ichabod and Mr. Toad']

def animated_films(file_name):
    pass

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

# Question 1
# - Write a function that takes in the html file name, 'disney_films', and returns a list of the titles
#       - of the films released in the 1940s.
#       - [ NOTE ] This is the 3rd table in the HTML file.
# - The file_name parameter will not include the file extension.
# - Entries should not include trailing whitespace characters such as "\n", "\t", " ", or "\xa0"
# - Ex.
#       >>> print(forties_list('disney_films'))
#               >>> ['Pinocchio', 'Fantasia', 'The Reluctant Dragon', 'Dumbo', 'Bambi',
#                        'Saludos Amigos', 'Victory Through Air Power', 'The Three Caballeros',
#                        'Make Mine Music', 'Song of the South', 'Fun and Fancy Free', 'Melody Time',
#                         'So Dear to My Heart', 'The Adventures of Ichabod and Mr. Toad']


def forties_list(file_name):
    # read the html file and create BeautifulSoup instance from the text
    with open(f"{file_name}.html", encoding="UTF-8") as file:
       html_file = file.read()

    movies = list()
    soup = BeautifulSoup(html_file, "lxml")
    # find all tables with the class name "wikitable sortable"
    table = soup.find_all("table", attrs={"class": "wikitable sortable"})

    movies_40s_table = table[1].find("tbody")
    table_rows = movies_40s_table.find_all("tr") # a list of rows
    # iterate over all rows in the table
    for row in table_rows:
       cols = row.find_all("td") # a list of columns
       cols = [col.text.strip() for col in cols] # strip all tags and redundant whitespace
       if len(cols) > 2:
            movie_title = cols[1] # movies name correspon to the second item in a list
            movies.append(movie_title)

    return movies...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$25.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Web Development (HTML, XML, PHP, JavaScript, Adobe, Flash, etc.) Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats