Skip to content
Snippets Groups Projects
Commit e598b583 authored by Martin Mareš's avatar Martin Mareš
Browse files

Úvod: Další kousky

parent 89d1fd8b
No related branches found
No related tags found
No related merge requests found
...@@ -15,58 +15,67 @@ ...@@ -15,58 +15,67 @@
\titlepage \titlepage
\end{frame} \end{frame}
\def\<{\color{red}} \def\py#1#2#3{%
\def\>{\color{black}>>> \color{blue}} {\tt\color{black}>>> \color{blue}#1}\\%
{\tt\color{red}#2}\\%
\def\tmp{#3}\ifx\tmp\empty\else
\smallskip
{\color{teal}#3}\\%
\fi
\medskip
}
% ---------------------------------------------------------------------- % ----------------------------------------------------------------------
\begin{frame}[fragile]{Python jako kalkulačka: celá čísla} \begin{frame}{Python jako kalkulačka}
\begin{semiverbatim} \py{1+1}{2}{}
\<1+1
\>2
\<2+3*4+1 \py{2+3*4+1}{15}{}
\>15
\<2+3 * 4+1 \py{2+3 * 4+1}{15}{}
\>15
\<(2+3)*(4+1) \py{(2+3)*(4+1)}{25}{}
\>25
\<2**10 \py{2**10}{1024}{}
\>1024
\<2**100 \py{2**100}{1267650600228229401496703205376}{}
\>1267650600228229401496703205376
\end{semiverbatim}
\end{frame} \end{frame}
% ---------------------------------------------------------------------- % ----------------------------------------------------------------------
\begin{frame}[fragile]{Python jako kalkulačka: celá čísla} \begin{frame}{Desetinná čísla}
\begin{semiverbatim} \py{1/3}{0.3333333333333333}{Výsledek je spočítán s omezenou přesností}
\<1+1
\>2
\<2+3*4+1 \py{1/3*3}{1.0}{Pozor, tohle není přesná jednička.}
\>15
\<2+3 * 4+1 \py{1/3*3 > 0}{True}{Vskutku, je o kousek větší.}
\>15
\<(2+3)*(4+1) \py{1/(2**100)}{7.888609052210118e-31}{Notace s mantisou a exponentem: $m\cdot10^e$.}
\>25
\<2**10 \end{frame}
\>1024
% ----------------------------------------------------------------------
\begin{frame}{Celočíselné dělení}
\py{7//3}{2}{}
\py{7\%3}{1}{Zbytek po dělení}
\py{-7//3}{-3}{Zaokrouhlujeme dolů, nikoliv k nule}
\py{-7\%3}{2}{Vždy platí {\tt (a//b)*b + (a\%b) = a}}
\end{frame}
% ----------------------------------------------------------------------
\begin{frame}{Proměnné}
\<2**100 \py{a=1\\b=1\\a+b}{2}{}
\>1267650600228229401496703205376
\end{semiverbatim}
\end{frame} \end{frame}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment