Commit 36bfc8ab authored by cermak's avatar cermak
Browse files

fix

parent 755fad8d
Pipeline #24986 passed with stage
in 35 seconds
{
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0-final"
},
"orig_nbformat": 2,
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Soubor má 9 řádků, 67 slov a 403 tisknutelných znaků.\n"
]
}
],
"source": [
"\n",
"# Spočítejte, kolik je v souboru řádků, slov a viditelných znaků (tedy bez mezer a konců řádků)\n",
"\n",
"with open(\"lipsum.txt\", encoding=\"utf-8\") as f:\n",
" radku = slov = znaku = 0\n",
" for line in f:\n",
" radku += 1\n",
" for s in line.split():\n",
" slov += 1\n",
" znaku += len(s)\n",
"print(f\"Soubor má {radku} řádků, {slov} slov a {znaku} tisknutelných znaků.\")\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# Zkopíruje soubor do jiného souboru, aby řádky šly v opačném pořadí\n",
"\n",
"# 1) hloupý postup, který načte původní soubor do paměti\n",
"\n",
"with open(\"lipsum.txt\", encoding=\"utf-8\") as f:\n",
" lines = f.readlines()\n",
"with open(\"lipsum-back.txt\", mode=\"w\", encoding=\"utf-8\") as f:\n",
" for line in reversed(lines):\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# 2) chytrý postup, který čte soubor odzadu, využívá externí knihovnu \n",
"# to samé by si šlo naprogramovat pomocí seeku, ale proč když už to někdo udělal.reversed\n",
"\n",
"from file_read_backwards import FileReadBackwards\n",
"\n",
"with FileReadBackwards(\"lipsum.txt\", encoding=\"utf-8\") as frb:\n",
" with open(\"lipsum-back.txt\", mode=\"w\", encoding=\"utf-8\") as f:\n",
" for line in frb:\n",
" f.write(line + \"\\n\")\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"0\n0\n57\n0\n0\n59\n0\n0\n0\n55\n"
]
}
],
"source": [
"# Najděte na každém řádku všechna čísla (oddělená mezerami) a vypíše jejich součet; slova, která nejsou čísly, ignoruje.\n",
"\n",
"def safe_int(s):\n",
" try:\n",
" return int(s)\n",
" except ValueError:\n",
" return 0\n",
"\n",
"with open(\"lipsum.txt\", encoding=\"utf-8\") as f:\n",
" for line in f:\n",
" print(sum(map(safe_int, line.split())))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
]
}
\ No newline at end of file
Donec aliquet nulla luctus, elementum magna vel, molestie mi.
Phasellus vehicula sem id interdum blandit.
Maecenas aliquam dapibus nisi, sit amet hendrerit purus feugiat sed.
Suspendisse at interdum orci.
Suspendisse cursus ipsum sit amet massa mattis, ut tempor tortor rutrum.
Nullam pulvinar mauris at diam faucibus venenatis.
Integer pharetra neque ac aliquam egestas.
Aenean mollis fermentum eros id posuere.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
ahoj
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
th 7892
he 7044
in 4298
er 4147
an 3939
re 3518
ha 3506
ou 3465
on 3203
at 3115
nd 3068
hi 2580
en 2544
is 2430
it 2422
ed 2395
or 2320
as 2258
to 2227
ar 2022
es 2011
st 2003
ve 2000
me 1905
te 1893
ng 1870
of 1848
le 1816
se 1692
ll 1546
ea 1503
ne 1468
ti 1468
nt 1446
ho 1436
ro 1422
wa 1411
al 1361
ur 1287
wh 1282
de 1273
no 1239
be 1229
yo 1225
co 1204
ut 1197
we 1155
ch 1147
si 1121
om 1119
ow 1093
ce 1070
ad 1044
wi 1039
ri 1036
ee 1005
ma 997
el 988
ic 982
fo 974
ot 954
et 929
mo 908
us 898
un 895
so 887
ra 868
ai 859
ly 857
ld 854
li 854
il 852
la 852
oo 852
im 850
ta 849
ir 848
ul 846
sh 822
id 798
io 793
ca 792
ac 786
lo 786
po 777
ry 759
do 758
av 741
ke 719
gh 701
pe 690
ss 663
tr 661
di 659
ol 659
rt 646
ge 641
ec 635
ct 631
sa 631
ns 630
nc 608
pr 599
ig 586
ay 583
wo 569
mi 561
rs 556
up 556
am 549
bu 544
my 537
ht 519
fr 508
em 507
pl 499
ev 496
ni 491
ie 486
os 479
vi 478
ba 473
su 471
ts 467
pa 456
bl 441
if 435
fe 425
ap 424
fa 419
tt 414
ck 397
ag 396
ab 391
fi 390
iv 383
rd 383
rr 367
tu 365
bo 359
na 359
ex 344
rn 344
da 332
gr 325
ug 320
cr 313
ey 305
wn 301
go 294
mp 291
tl 290
ef 288
ye 287
ov 285
ga 283
ep 279
dr 276
od 269
sp 268
cl 264
uc 264
rk 261
ny 257
sk 255
op 254
rl 254
by 246
rv 245
ak 244
ds 244
mu 241
kn 240
br 238
ei 231
ru 231
ci 229
sc 225
lm 219
cu 217
ok 216
pp 215
ty 212
gu 207
nk 207
oc 204
qu 202
aw 199
ew 197
nl 196
rg 195
hu 190
ff 188
pi 184
ue 184
rm 178
ft 176
gl 175
gi 173
fu 166
hr 164
oi 160
lu 159
nr 159
tw 159
af 150
ui 147
ls 146
au 145
ib 145
dy 144
ki 144
lf 143
pt 143
ys 140
ia 137
ob 137
nn 135
pu 135
um 132
ms 128
og 128
je 126
va 126
xp 125
cc 119
lt 116
ub 115
eg 114
ud 113
mb 111
oa 110
ip 105
fl 104
vo 103
ks 100
mr 100
rc 98
sw 98
bi 95
nb 95
nf 95
tm 95
ua 94
du 93
hy 92
sl 91
dl 90
oj 90
ym 90
lk 88
ik 85
dd 83
nv 83
ps 83
sm 76
mm 74
eo 73
xa 69
rp 67
tc 67
wr 65
gs 64
gg 63
xt 62
gn 61
ws 60
ju 59
lp 59
bt 58
xc 58
oy 57
nu 55
bs 54
yt 54
ze 54
ph 53
py 51
oe 50
dg 49
yi 48
az 45
eh 45
lv 44
rf 43
wl 43
kl 41
eb 37
jo 34
eq 33
dv 32
lr 32
rh 32
lw 31
cy 30
sy 28
ja 27
bj 25
ix 24
iz 24
nq 24
rw 24
xe 24
gy 23
oh 23
ya 22
ek 21
tp 21
xi 21
hs 20
zi 20
sb 19
sf 19
uf 19
dn 18
eu 18
sn 18
vy 18
dm 17
hb 17
sq 17
bb 16
nw 16
ax 15
ky 15
yr 15
yp 14
bv 13
iu 13
nh 13
tn 13
zl 13
zz 13
bm 12
hl 12
kf 12
mn 12
nj 12
tf 12
uz 12
ww 12
hn 11
df 10
gt 10
lc 10
ox 10
rb 10
ao 9
cq 9
ku 9
nx 9
pg 9
yl 9
ka 8
ml 8
np 8
ah 7
fy 7
sg 7
uo 7
yw 7
hm 6
mf 6
nm 6
dw 5
hh 5
pm 5
pw 5
wy 5
xh 5
yz 5
za 5
ae 4
ej 4
fw 4
hf 4
hw 4
km 4
ln 4
nz 4
xu 4
zy 4
bd 3
dh 3
hd 3
iq 3
lh 3
pd 3
ré 3
sd 3
tb 3
wb 3
wd 3
wu 3
xf 3
yc 3
yh 3
zo 3
cs 2
dj 2
ez 2
fs 2
gz 2
ii 2
kg 2
ko 2
lb 2
lg 2
mc 2
mh 2
mt 2
sr 2
tê 2
uv 2
ux 2
vu 2
wc 2
xo 2
yb 2
yn 2
ér 2
êt 2
aj 1
bh 1
bn 1
cn 1
dq 1
dt 1
dé 1
gb 1
gm 1
gw 1
kw 1
næ 1
nœ 1
oz 1
pn 1
sz 1
td 1
tj 1
tx 1
té 1
wf 1
wk 1
wt 1
xb 1
xq 1
xy 1
yg 1
zk 1
zv 1
éb 1
éc 1
œa 1
\documentclass{beamer}
\title{Programování 1.12: Standardní knihovna}
\title{Programování 1.12: (Ne)Standardní knihovny}
\input ../slidemac.tex
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment