Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Čermák Petr
Prm1
Commits
e598b583
Commit
e598b583
authored
Sep 26, 2019
by
Mareš Martin
Browse files
Úvod: Další kousky
parent
89d1fd8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
01-uvod/01-uvod.tex
View file @
e598b583
...
...
@@ -15,58 +15,67 @@
\titlepage
\end{frame}
\def\<
{
\color
{
red
}}
\def\>
{
\color
{
black
}
>>>
\color
{
blue
}}
\def\py
#1#2#3
{
%
{
\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}
\<
1+1
\>
2
\py
{
1+1
}{
2
}{}
\<
2+3*4+1
\>
15
\py
{
2+3*4+1
}{
15
}{}
\<
2+3 * 4+1
\>
15
\py
{
2+3 * 4+1
}{
15
}{}
\<
(2+3)*(4+1)
\>
25
\py
{
(2+3)*(4+1)
}{
25
}{}
\<
2**10
\>
1024
\py
{
2**10
}{
1024
}{}
\<
2**100
\>
1267650600228229401496703205376
\end{semiverbatim}
\py
{
2**100
}{
1267650600228229401496703205376
}{}
\end{frame}
% ----------------------------------------------------------------------
\begin{frame}
[fragile]
{
Python jako kalkulačka: cel
á čísla
}
\begin{frame}
{
Desetinn
á čísla
}
\begin{semiverbatim}
\<
1+1
\>
2
\py
{
1/3
}{
0.3333333333333333
}{
Výsledek je spočítán s omezenou přesností
}
\<
2+3*4+1
\>
15
\py
{
1/3*3
}{
1.0
}{
Pozor, tohle není přesná jednička.
}
\<
2+3 * 4+1
\>
15
\py
{
1/3*3 > 0
}{
True
}{
Vskutku, je o kousek větší.
}
\<
(2+3)*(4+1)
\>
25
\py
{
1/(2**100)
}{
7.888609052210118e-31
}{
Notace s mantisou a exponentem:
$
m
\cdot
10
^
e
$
.
}
\<
2**10
\>
1024
\end{frame}
% ----------------------------------------------------------------------
\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
\>
1267650600228229401496703205376
\end{semiverbatim}
\py
{
a=1
\\
b=1
\\
a+b
}{
2
}{}
\end{frame}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment