This assignment should be written in PYTHON programming language
Please write python programs to answer the following questions. Everything should be dynamically scraped from the live websites using the Beautiful Soup interface.
Texas Dept of Criminal Justice (relevant url: http://www.tdcj.state.tx.us/death_row/dr_executions_by_year.html): Accept two integers as input. You can assume that these values represent a valid starting and ending year within the range of the years in the table. Process the html and find the total number of executions in Texas between the starting year and the ending year (inclusive of the start and end years).
Example: Enter starting year: 1990 Enter ending year: 2000 Total executions: 206
import requests from bs4 import BeautifulSoup page = requests.get('https://www.tdcj.texas.gov/death_row/dr_executions_by_year.html') soup = BeautifulSoup(page.text, 'html.parser') rows = soup.select('.overflow table tr')[1:-1] executions = {} for link in rows: x = link.find('th') y = link.findAll('td')[-2] executions[int(x.text)] = int(y.text) #print(executions) start = int(input('Enter starting year: ')) end = int(input('Enter ending year: ')) total = 0 for y in range(start, end + 1): if y in executions: total += executions[y] print('Total executions:', total)
Hi. please find the answer above.. i have given comments so that it
is very easy for you to understand the flow. In case of any doubts,
please ask in comments. If the answer helps you, please upvote.
Thanks!
This assignment should be written in PYTHON programming language Please write python programs to answer the...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...