Question: 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.


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
Get step-by-step solutions from verified subject matter experts
