CSC110 / assignments / a3 / a3.tex
a3.tex
Raw
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[utf8]{inputenc}
\usepackage[margin=0.75in]{geometry}

\title{CSC110 Fall 2022 Assignment 3: Loops, Mutation, and Applications}
\author{Yehyun Lee}
\date{\today}

\begin{document}
\maketitle

\section*{Part 1: Data Analysis with Toronto Health}

Complete this part in the provided \texttt{a3\_part1.py} file.
Do \textbf{not} include your solutions in this file.

\section*{Part 2: Loops and Mutation Debugging Exercise}

\begin{enumerate}
\item[1.]
test\_star\_wars passed, however, test\_legally\_blonde and test\_transformers failed.

\item[2.]
For both test\_legally\_blonde and test\_transformers, AssertionError occurs because actual[1] and expected\_intensity value is different or not close enough.
We're expected to have actual[1] value same or close to expected\_intensity. So then, why are we not getting the same value or close to expected\_intensity?\\

This is caused by two errors in code.\\

First error(specifically for function test\_legally\_blonde):\\
test\_legally\_blonde failed due to the function called ``clean\_text". This is because text have some capital words! So when it calls ``str.lower(text)" in line 83, we're expecting it to convert text to lowercase, so that we're able to find all WORD\_TO\_INTENSITY(since all WORD\_TO\_INTENSITY is lowercase, we need to convert text to lowercase). However, str.lower(text) gives copy of lowercase text; it does not make variable text to lowercase.
Meaning, we need to assign it to variable text by changing it to: text = str.lower(text). If we make the following change, it will be able to identify all WORD\_TO\_INTENSITY.\\

Second error(specifically for function test\_transformers):\\
test\_transformers failed due to the function called ``count\_keywords".
We're expected to count how many times same keyword occurs and return it.
In function count\_keywords when word first appears, it add 1 to accumulator.
However, when word appears again, there's no code that add additional 1 to accumulator.
(Note how there's if statement for adding 1 to accumulator when word first appears, but does not add 1 when it appears again.)
We can simply fix this by adding else statement and code that add 1 to accumulator.\\

I made changes accordingly. 

\item[3.]
Reason why function test\_star\_wars passed in original error code is simple. It does not have uppercase words nor have same word appear again; they simply appear once only.
Thus, it does not violate two errors that I mentioned above: having uppercase word and repeated keyword. Thus, it passed in original error code.
\end{enumerate}

\section*{Part 3: Chaos, Fractals, Point Sequences}

Complete this part in the provided \texttt{a3\_part3.py} starter file.
Do \textbf{not} include your solutions in this file.

\end{document}