diff options
author | hardythe1 | 2012-04-10 16:03:56 +0530 |
---|---|---|
committer | hardythe1 | 2012-04-10 16:03:56 +0530 |
commit | 8cc77ab42c84befb966090a8f6466dbfcf41e265 (patch) | |
tree | 75cc2a729f898885637827ea5fb8707361e2f2d3 /TDD/getting_started_with_tdd | |
parent | 4bb01fba846707e586e701581ec473e17925e975 (diff) | |
download | sdes-stscripts-8cc77ab42c84befb966090a8f6466dbfcf41e265.tar.gz sdes-stscripts-8cc77ab42c84befb966090a8f6466dbfcf41e265.tar.bz2 sdes-stscripts-8cc77ab42c84befb966090a8f6466dbfcf41e265.zip |
added self evaluation questions
Diffstat (limited to 'TDD/getting_started_with_tdd')
-rw-r--r-- | TDD/getting_started_with_tdd/tdd1.tex | 69 | ||||
-rwxr-xr-x | TDD/getting_started_with_tdd/tdd1_script.rst | 8 |
2 files changed, 66 insertions, 11 deletions
diff --git a/TDD/getting_started_with_tdd/tdd1.tex b/TDD/getting_started_with_tdd/tdd1.tex index f056ce5..042c5c4 100644 --- a/TDD/getting_started_with_tdd/tdd1.tex +++ b/TDD/getting_started_with_tdd/tdd1.tex @@ -254,7 +254,7 @@ def fibonacci(n): \begin{itemize} -\item Undestand the basic steps involved in Test driven development. +\item Understand the basic steps involved in Test driven development. \item Design a TDD approach for a given \texttt{fibonacci} function. \end{itemize} @@ -267,20 +267,75 @@ def fibonacci(n): \begin{enumerate} -\item ? +\item Design a TDD approach for a \texttt{factorial} function. \vspace{8pt} -\item ? +\item Design a TDD approach for an \texttt{armstrong} function. \end{enumerate} \end{frame} -\begin{frame} + +\begin{frame}[fragile] \frametitle{Solutions} \label{sec-10} +\begin{enumerate} +\vspace{15pt} +\item +{\tiny +\begin{lstlisting} +def factorial(n): + if n < 0 : + return None; + if n == 1: + return 1 + else: + return n * factorial (n - 1) +if __name__ == '__main__': + f = factorial(3) + if f != 6 : + print 'Test Failed...' + exit (1) + f = factorial(-5) + if f != None : + print 'Test Failed...' + exit (1) + print 'All tests passed...' +\end{lstlisting} +} +\end{enumerate} +\end{frame} - +\begin{frame}[fragile] +\frametitle{Solutions} +\label{sec-10} \begin{enumerate} -\item \vspace{15pt} -\item +\item +{\tiny +\begin{lstlisting} +def armstrong(n): + sum = 0 + temp = 0 + remainder = 0 + temp = n + while temp > 0 : + remainder = temp % 10 + sum = sum + remainder * remainder * remainder + temp = temp / 10 + if n == sum: + return True + else: + return False +if __name__ == '__main__': + is_armstrong = armstrong(0) + if is_armstrong != True: + print "this is not armstrong" + exit(1) + is_armstrong = armstrong(371) + if is_armstrong == True: + print "this is armstrong" + exit(1) + print 'All tests passed...' +\end{lstlisting} +} \end{enumerate} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/TDD/getting_started_with_tdd/tdd1_script.rst b/TDD/getting_started_with_tdd/tdd1_script.rst index 9da1613..88c1227 100755 --- a/TDD/getting_started_with_tdd/tdd1_script.rst +++ b/TDD/getting_started_with_tdd/tdd1_script.rst @@ -175,9 +175,9 @@ This brings us to the end of the tutorial.In this tutorial, .. R14 Here are some self assessment questions for you to solve - 1. - 2. + 1. Design a TDD approach for a factorial function. + 2. Design a TDD approach for an armstrong function. .. L14 @@ -186,9 +186,9 @@ Here are some self assessment questions for you to solve .. R15 And the answers are, - 1. + 1. {{{ show answer slide-1 }}} - 2. + 2. {{{ show answer slide-2 }}} .. L15 |