\documentclass[11pt]{article}

\newcommand{\thedocument}{\textmacro{Lab 1: Introduction to \LaTeX}}
\newcommand{\theauthor}{\textmacro{(Your name here!)}}
\usepackage{csc208}

\begin{document}

\begin{titlepagecontent}
Labs in this course will normally consist of \texttt{.tex} files for you to
fill in with your partner. If you use Overleaf, you can import this file (along
with \texttt{csc208.sty}) into a new project to get started. When you are done,
please turn in a completed PDF of your work by the appropriate deadline. Please
make sure that your PDF successfully compiles on overleaf without errors.
Otherwise, your PDF may not be malformed or otherwise missing portions of your
work.
\end{titlepagecontent}

\newpage

%%%%% Problem 1: Introduction to LaTeX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem{Introduction to \LaTeX}

At this point, you should have created an Overleaf account and worked through
the ``Learn \LaTeX in 30 minutes'' tutorial found on the site:
\begin{enumerate}
  \item \url{https://www.overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes}
\end{enumerate}

Overleaf's documentation (\url{https://www.overleaf.com/learn}) also serves as
an excellent resource for learning how to do specific things in \LaTeX as the
need arises. I recommend going to it as a first resource when you want to do
something in a document.

Use what you learned from the tutorial in addition with information you
gather from Overleaf's documentation to accomplish the following tasks:

\begin{enumerate}
  \item Typeset the quadratic formula. You can remind yourself what this is
    at the following Wikipedia page:
    \begin{itemize}
      \item \url{https://en.wikipedia.org/wiki/Quadratic_equation}.
    \end{itemize}
    Make sure to use display math mode (rather than inline mode) and ensure
    that your document uses the same symbols as the Wikipedia article.

  \item Typeset your recursive Python \verb|sum| function from last class using
    the \verb|verbatim| environment. \hint{The \LaTeX term for a block of a
    code is a ``code listing''}.
\end{enumerate}

\answerbelow

%% TODO: put your solutions to the tasks here

\newpage

%%%%% Problem 2: More Python Practice %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem{More Python Practice}

In our first class period, we began introducing the Python programming language
by mapping some of the basic constructs from Scheme into Python. Let's practice
writing some more Python code to get a better feel for the language.

Hop into VSCode and implement and verify the following functions in a new
Python file. Rather than turning in the Python file, though, typeset your
functions when you are done as your answer to this problem. Make sure to use
the \verb|verbatim| environment to do so and that your code stays within the
margins of the page, potentially using line breaks and/or multiple
\verb|verbatim| environments as necessary.

\begin{enumerate}[label=(\alph*)]
  \item \verb|cToF(deg)| takes the temperature \verb|deg| in Celsius and returns
    the temperature in \verb|fahrenheit|.
  \item \verb|gradeToLetter(gpa)| takes a \verb|gpa|, a number assumed to be in
    the range \( 0 \) through \( 4 \) and returns a letter grade as a string
    for this GPA according to the following scale:
    \begin{itemize}
      \item Greater than or equal to \( 3.5 \): \verb|A|
      \item Between \( 2.5 \) (inclusive) and \( 3.5 \) (exclusive): \verb|B|
      \item Between \( 1.5 \) (inclusive) and \( 2.5 \) (exclusive): \verb|C|
      \item Between \( 0.5 \) (inclusive) and \( 1.5 \) (exclusive): \verb|D|
      \item Less than \( 0.5 \): \verb|F|
    \end{itemize}
\end{enumerate}

\answerbelow

%% TODO: fill in your code.

\newpage

%%%%% Problem 3: Basic Python Tracing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem{Basic Python Tracing}

In CSC 151, you learned about a \emph{substitutive model of computation} for
Racket/Scheme programs where we model how a program evaluates as an extension
of basic arithmetic. as our first foray into the world of program correctness.

\begin{defn}
  \textbf{(Substitutive evaluation)}. Expressions take \emph{repeated steps of
  evaluation} until they evaluate to a final value. A step of evaluation
  consists of:
  \begin{enumerate}
    \item \emph{Finding} the next subexpression to evaluate, respecting
      precedence and associativity of relevant operators.
    \item \emph{Evaluating} that subexpression to a value.
    \item \emph{Substituting} the value for the subexpression that produced it
      in the overall expression.
  \end{enumerate}
\end{defn}

As we talked discussed today, we will employ a similar model for Python
programs as our first foray into the world of program verification. Let's
review this model now and next week we will further adapt it to the particulars
of Python in our future classes.

For each Python expression, give its step-by-step evaluation to a final value.
To typeset your steps, use the \verb|verbatim| environment to format your
derivation as follows.

\begin{verbatim}
    1 + (2 - 3) * 4
--> 1 + -1 * 4
--> 1 + -4
--> 3
\end{verbatim}

Note how each line of the derivation is indented with a long arrow (\verb|-->|)
denoting that the previous expression \emph{steps} to the next expression.

\begin{enumerate}
  \item \verb|(3 * 5 - 20 / 2) ** ((2 + 8) - 6)|
  \item \verb|(8 + 3 * 2 - 1 / 5)|
  \item \verb|s[0] + str(len(s)) + s[2]| where \verb|s = "abc"|.
\end{enumerate}

\begin{itemize}
  \item The \verb|**| operator is the exponentiation operator, \ie,
    \verb|x ** y| is equivalent to \( x^y \).
  \item Regarding strings, the indexing operation \verb|s[0]| returns the
    character at the given position of the string, \( 0 \)-indexed. In this
    case \verb|s[0]| returns the first character of the string \verb|s|.
  \item \verb|len(s)| returns the length of the string \verb|s| as a number.
  \item \verb|str(v)| returns the string representation of the value \verb|v|.
\end{itemize}

Make sure to check your work in Python by creating a source file and using
\verb|print| to see the results or use the Python REPL directly.

\answerbelow

%% TODO: fill in your derivations here!

\end{document}
