\documentclass{article}

\usepackage{amsmath}
\usepackage{listings}
\usepackage{framed}
\usepackage{amssymb}
\usepackage{graphicx}

\addtolength{\textwidth}{1in}
\addtolength{\evensidemargin}{-0.5in}
\addtolength{\oddsidemargin}{-0.5in}
\addtolength{\textheight}{1in}
\addtolength{\topmargin}{-0.5in}

\begin{document}

\noindent
\centerline{\Large\bf 22C:16 (CS:1210) Quiz 4}

\medskip

\medskip
\hrule

\medskip
\noindent
You have 20 minutes to complete this quiz.

\noindent
\begin{enumerate}
\item
Consider the following expressions. For each expression, first determine whether the expression
is \textit{well-formed} or not. For each well-formed expression, determine if the expression will
be successfully evaluated by Python or not. For each expression that is successfully evaluated,
determine its value and the type of its value.
Assume that the \texttt{math}, \texttt{random}, and \texttt{sys} modules have all been imported prior to
the execution of these expressions.
Also, suppose that the value of \texttt{sys.maxint} is \texttt{9223372036854775807}.
\begin{itemize}
\item[(a)] \verb+len(str(random.randint(10, 20)*22))+
\vspace{0.25in}
\item[(b)] \verb!-sys.maxint-1!
\vspace{0.25in}
\item[(c)] \verb+5 < 8 and (100/(len("0")-1))+
\vspace{0.25in}
\item[(d)] \verb+abs(5 - 25) < 150 and 0.5+
\vspace{0.25in}
\item[(e)] \verb!2/math.trunc(1.5)+200L!
\vspace{0.25in}
\item[(f)] \verb+5 < 8 or (100/(len("0")-1))+
\vspace{0.25in}
\item[(g)] \verb+bin(len(str(10<20)))+
\vspace{0.25in}
\item[(h)] \verb!4L*len("Problem1")/(len("Exam1")%3)+2.0!
\vspace{0.25in}
\item[(i)] \verb!-4*(-2)**3+-len(str(66))!
\vspace{0.25in}
\item[(j)] \verb+bool(math.sqrt((-1)**100))+
\end{itemize}

\newpage

\item 
Suppose that we have defined a function called \texttt{numFactors} whose header is:

\centerline{\texttt{def numFactors(n):}}

The parameter \texttt{n} is expected to be a positive integer and the function returns the
number of distinct factors of \texttt{n}.
For example, if \texttt{n} were 10, the function would return 4 (since 10 has factors 1, 2, 5, and 10). 

For this problem, we want you to write a function called \texttt{numPrimes} with the following
function header:

\centerline{\texttt{def numPrimes(L, U):}}

You can assume that the parameters \texttt{L} and \texttt{U} are positive integers and \texttt{L}
is no greater than \texttt{U}.
This function should return the number of primes that are between \texttt{L} and \texttt{U},
inclusive of \texttt{L} and \texttt{U}.
This function should call \texttt{numFactors} repeatedly to complete its task.

Here is an example that will help you understand what is being asked of you.\\
\noindent
\textbf{Example.}
The function call \texttt{numPrimes(5, 10)} should return 2 because 
there the two primes in the range $[5, 10]$, namely 5 and 7.

\vspace{4in}
\end{enumerate}

\medskip
\hrule
\end{document}
