From 64977f7d1251aaeb22975be4df5b77ba20ab0132 Mon Sep 17 00:00:00 2001 From: mlefter <m.lefter@lumc.nl> Date: Fri, 23 Nov 2018 12:01:20 +0100 Subject: [PATCH] Finished introduction --- .../introduction.tex | 91 +++++++++++++++++-- 1 file changed, 82 insertions(+), 9 deletions(-) rename introduction/{presentation => introduction}/introduction.tex (85%) diff --git a/introduction/presentation/introduction.tex b/introduction/introduction/introduction.tex similarity index 85% rename from introduction/presentation/introduction.tex rename to introduction/introduction/introduction.tex index aa82d33..a0f36eb 100644 --- a/introduction/presentation/introduction.tex +++ b/introduction/introduction/introduction.tex @@ -31,8 +31,23 @@ left=0.1cm, arc=0mm, colframe=black]} - {\end{tcolorbox} -} + {\end{tcolorbox}} + + +\newenvironment{terminal} + {\begin{tcolorbox}[title=terminal, + title filled=false, + fonttitle=\scriptsize, + fontupper=\footnotesize, + enhanced, + colback=monokaibg, + drop small lifted shadow, + boxrule=0.1mm, + left=0.1cm, + arc=0mm, + colframe=black]} + {\end{tcolorbox}} + \newcommand{\hrefcc}[2]{\textcolor{#1}{\href{#2}{#2}}} \newcommand{\hrefc}[3]{\textcolor{#1}{\href{#2}{#3}}} @@ -287,15 +302,73 @@ We'll use Python 3.7 for this course. \end{pframe} -% \subsection{} -% \begin{pframe} -% \begin{itemize} -% \item -% \end{itemize} -% \end{pframe} -\section{Python as a calculator} +\section{Running Python code} + +\begin{pframe} + Two main ways of writing and executing Python code: + \begin{itemize} + \item Interactively: + \begin{itemize} + \item Statement by statement, directly in the interpreter. + \end{itemize} + \item Non-interactively: + \begin{itemize} + \item By editing in a file and running the code afterwards. + \end{itemize} + \end{itemize} +\end{pframe} + +\subsection{The standard Python interpreter} +\begin{pframe} + Start it by typing \textbf{python} on the command line: + \begin{terminal} + \color{white}{ + \begin{lstlisting}[frame=,style=,numbers=none] +$ python +Python 3.7 (default, Nov 12 2018, 13:43:14) +[GCC 5.4.0 20160609] on linux +Type "help", "copyright", "credits" or "license" for more information. +>>> + \end{lstlisting}} + \end{terminal} + \begin{itemize} + \item It shows an interpreter prompt. + \item You can give it Python code to interpret. + \end{itemize} +\end{pframe} + +\subsection{The IPython interpreter} +\begin{pframe} + Similar to the standard Python interpreter, but with: + \begin{itemize} + \item syntax highlighting; + \item tab completion; + \item cross-session history, + \item etc. + \end{itemize} + + Start it by typing \textbf{ipython} on the command line: + \begin{terminal} + \color{white}{ + \begin{lstlisting}[frame=,style=,numbers=none] +$ ipython +Python 3.7 (default, Nov 12 2018, 13:43:14) +Type 'copyright', 'credits' or 'license' for more information +IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help. + \end{lstlisting}} + \begin{pythonin}{python} + \end{pythonin} + \addtocounter{cntr}{-1} + \end{terminal} + \begin{itemize} + \item It shows an interpreter prompt. + \item You can give it Python code to interpret. + \end{itemize} +\end{pframe} + +\section{Python as a calculator} \subsection{Integers} \begin{pframe} -- GitLab