\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 Quiz 3}
\bigskip
\centerline{\Large\bf Date: Feb 7th, 2012}


\medskip
\hrule

\medskip

\begin{enumerate}
\item Write down the value and type of each of these expressions.
Assume that the \texttt{math} and the \texttt{sys} modules have 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)] \texttt{100L + 200.00}

\vspace{0.5in}

\item[(b)] \texttt{math.ceil(10.97) - math.trunc(11.17)}

\vspace{0.5in}

\item[(c)] \texttt{len(str(10.97))}

\vspace{0.5in}

\item[(d)] \texttt{bin(5) + bin(3)}

\vspace{0.5in}

\item[(e)] \texttt{-1*sys.maxint + 2}
\end{itemize}

\vspace{1.5in}



\noindent
\textbf{Please turn the page over for the second problem.}

\newpage

\item Here is a partly completed program to find the largest \textit{and} the second-largest numbers
in a given sequence of numbers. 
You are required to complete the program by filling in the blanks.
The program starts starts by prompting the user for a positive integer, let us call this $n$,
that represents the length of her sequence.
The program then reads $n$ non-negative integers input by the user (typed one in each line) and outputs the largest and the
second-largest numbers in the given sequence.
\begin{framed}
\begin{verbatim}
n = int(raw_input("Enter a positive integer: "))
print "Now please enter", n, "non-negative integers, one per line"

max = -1
secondMax = max

count = 1
while (count <= n):
    currentNumber = int(raw_input())
    
    # Case 1: The current number is at least as large as the current max
    # FILL IN THE TWO LINES OF CODE BELOW
    if currentNumber >= max:

            _________________________________

            _________________________________
    
    # Case 2: The current number smaller than the current max, but at 
    # least as large as the current secondMax
    # FILL IN THE BOOLEAN EXPRESSION FOR THE IF-STATEMENT BELOW 

    if ______________________________________________:
            secondMax = currentNumber
    count = count + 1

print "The largest number is", max
print "The second largest number is", secondMax
\end{verbatim}
\end{framed}
\vspace{1.5in}
\end{enumerate}
\end{document}
