01-uvod.tex 1.75 KB
Newer Older
Martin Mareš's avatar
Martin Mareš committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usetheme{Warsaw}
\title{Programování 1: Úvod do Pythonu}
\author[Martin Mareš]{Martin Mareš\\\texttt{mj@ucw.cz}}
\institute{Katedra Aplikované Matematiky\\MFF UK Praha}
\date{2019}
\begin{document}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{}
\setbeamerfont{title page}{family=\rmfamily}

\begin{frame}
\titlepage
\end{frame}

Martin Mareš's avatar
Martin Mareš committed
18
19
20
21
22
23
24
25
26
\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
}
Martin Mareš's avatar
Martin Mareš committed
27
28
29

% ----------------------------------------------------------------------

Martin Mareš's avatar
Martin Mareš committed
30
\begin{frame}{Python jako kalkulačka}
Martin Mareš's avatar
Martin Mareš committed
31

Martin Mareš's avatar
Martin Mareš committed
32
\py{1+1}{2}{}
Martin Mareš's avatar
Martin Mareš committed
33

Martin Mareš's avatar
Martin Mareš committed
34
\py{2+3*4+1}{15}{}
Martin Mareš's avatar
Martin Mareš committed
35

Martin Mareš's avatar
Martin Mareš committed
36
\py{2+3 * 4+1}{15}{}
Martin Mareš's avatar
Martin Mareš committed
37

Martin Mareš's avatar
Martin Mareš committed
38
\py{(2+3)*(4+1)}{25}{}
Martin Mareš's avatar
Martin Mareš committed
39

Martin Mareš's avatar
Martin Mareš committed
40
\py{2**10}{1024}{}
Martin Mareš's avatar
Martin Mareš committed
41

Martin Mareš's avatar
Martin Mareš committed
42
\py{2**100}{1267650600228229401496703205376}{}
Martin Mareš's avatar
Martin Mareš committed
43
44
45
46
47

\end{frame}

% ----------------------------------------------------------------------

Martin Mareš's avatar
Martin Mareš committed
48
\begin{frame}{Desetinná čísla}
Martin Mareš's avatar
Martin Mareš committed
49

Martin Mareš's avatar
Martin Mareš committed
50
\py{1/3}{0.3333333333333333}{Výsledek je spočítán s omezenou přesností}
Martin Mareš's avatar
Martin Mareš committed
51

Martin Mareš's avatar
Martin Mareš committed
52
\py{1/3*3}{1.0}{Pozor, tohle není přesná jednička.}
Martin Mareš's avatar
Martin Mareš committed
53

Martin Mareš's avatar
Martin Mareš committed
54
\py{1/3*3 > 0}{True}{Vskutku, je o kousek větší.}
Martin Mareš's avatar
Martin Mareš committed
55

Martin Mareš's avatar
Martin Mareš committed
56
\py{1/(2**100)}{7.888609052210118e-31}{Notace s mantisou a exponentem: $m\cdot10^e$.}
Martin Mareš's avatar
Martin Mareš committed
57

Martin Mareš's avatar
Martin Mareš committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
\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é}
Martin Mareš's avatar
Martin Mareš committed
77

Martin Mareš's avatar
Martin Mareš committed
78
\py{a=1\\b=1\\a+b}{2}{}
Martin Mareš's avatar
Martin Mareš committed
79
80
81
82
83
84

\end{frame}

% ----------------------------------------------------------------------

\end{document}