Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. (8.0 points) (a) (6.0 pt) Oh no! Kunal is writing up a new Data 100 discussion worksheet in LaTeX, but he made some mistakes.

image text in transcribedimage text in transcribed

3. (8.0 points) (a) (6.0 pt) Oh no! Kunal is writing up a new Data 100 discussion worksheet in LaTeX, but he made some mistakes. All of his summations are supposed to end at r, but some of them end at m instead. Here is a sample of lines in his document, with the LaTeX directly rendered next to each one. "$\mu = \sum_{i = 1}^{m} x_i$" u = = x; "$\sigma^2 = \sum_{i=1}^{r} (x_i - \mu)^2$" o2 = 211(; H)2 "$L (\theta) = \prod_{i=1}^{m} f(x_i | \theta)$" L(O) = 11-f(x0) "$\sum_{j=0}^{m} {r \choose j} p^j (1-p)^{r-j} = 1$" % =0 (3)pi (1 p)'-j = 1 "$m = 100$" m = 100 "The sum goes from 1 to m." The sum goes from 1 to m. Given the above strings, write a regular expression to find the offending character. That is, your regex should match the character that should be r, but is not. If there are no mistakes in the LaTeX, your regex should not return a match. Your regex will be graded on whether or not the following code executes correctly, assuming all of the above strings have been loaded into a list called strings. You only need to worry about these test cases do not worry about any other edge cases not considered in the examples. import re pattern = for string in strings: print (re.findall(pattern, string)) ['m'] [] ['m'] [] [] pattern (b) (2.0 pt) Assume that the regex you wrote above works correctly. How do we replace the matched character in string with r? re.sub (pattern, "r", string) re.replace(pattern, "r", string) string.replace(pattern, "r") None of the above

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

Step: 3

blur-text-image

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

1. What might have led to the misinformation?

Answered: 1 week ago