Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a python that that uses regular expressions to extract all the CSE courses from a Computer Science Curriculum webpage It should basically be the

Write a python that that uses regular expressions to extract all the CSE courses from a Computer Science Curriculum webpage

It should basically be the Python equivalent of the following pipeline:

$ curl -sL URL \ | grep -Eo 'CSE [234][0-9]{4}' \ | sed -E -e 's/CSE 2.*/Sophomore/' -e 's/CSE 3.*/Junior/' -e 's/CSE 4.*/Senior/' \ | sort | uniq -c | sort -rn

Skeleton:

import collections import re import requests # Globals URL = # Initialize a default dictionary with integer values counts = None # TODO: Make a HTTP request to URL response = None # TODO: Access text from response object data = None # TODO: Compile regular expression to match CSE courses (ie. CSE XXXXX) regex = None # TODO: Search through data using compiled regular expression and count up all # the courses per class year for course in re.findall(None, None): pass # TODO: Sort items in counts dictionary by value in reverse order and # display counts and class year for year, count in sorted(counts.items(), key=lambda p: p[1]): print(f'{count:>7} {year}')

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_2

Step: 3

blur-text-image_3

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

How many months or years of training or studying did it take?

Answered: 1 week ago