import numpy as np
import matplotlib.pyplot as plt
import math
from ulohy04 import uloha1, uloha1a, uloha2, uloha3, uloha4
for i in range(len(vysledek)):
if vysledek[i]==10:
vysledek[i]="A"
if vysledek[i]==11:
vysledek[i]="B"
if vysledek[i]==12:
vysledek[i]="C"
if vysledek[i]==13:
vysledek[i]="D"
if vysledek[i]==14:
vysledek[i]="E"
if vysledek[i]==15:
vysledek[i]="F"
if vysledek[i]==16:
vysledek[i]="G"
if vysledek[i]==17:
vysledek[i]="H"
if vysledek[i]==18:
vysledek[i]="I"
if vysledek[i]==19:
vysledek[i]="J"
if vysledek[i]==20:
vysledek[i]="K"
if vysledek[i]==21:
vysledek[i]="L"
if vysledek[i]==22:
vysledek[i]="M"
if vysledek[i]==23:
vysledek[i]="N"
if vysledek[i]==24:
vysledek[i]="O"
if vysledek[i]==25:
vysledek[i]="P"
if vysledek[i]==26:
vysledek[i]="Q"
if vysledek[i]==27:
vysledek[i]="R"
if vysledek[i]==28:
vysledek[i]="S"
if vysledek[i]==29:
vysledek[i]="T"
if vysledek[i]==30:
vysledek[i]="U"
if vysledek[i]==31:
vysledek[i]="V"
if vysledek[i]==32:
vysledek[i]="W"
if vysledek[i]==33:
vysledek[i]="X"
if vysledek[i]==34:
vysledek[i]="Y"
if vysledek[i]==35:
vysledek[i]="Z"
if vysledek[i]==36:
vysledek[i]="a"
if vysledek[i]==37:
vysledek[i]="b"
if vysledek[i]==38:
vysledek[i]="c"
if vysledek[i]==39:
vysledek[i]="d"
if vysledek[i]==40:
vysledek[i]="e"
if vysledek[i]==41:
vysledek[i]="f"
if vysledek[i]==42:
vysledek[i]="g"
if vysledek[i]==43:
vysledek[i]="h"
if vysledek[i]==44:
vysledek[i]="i"
if vysledek[i]==45:
vysledek[i]="j"
if vysledek[i]==46:
vysledek[i]="k"
if vysledek[i]==47:
vysledek[i]="l"
if vysledek[i]==48:
vysledek[i]="m"
if vysledek[i]==49:
vysledek[i]="n"
if vysledek[i]==50:
vysledek[i]="o"
if vysledek[i]==51:
vysledek[i]="p"
if vysledek[i]==52:
vysledek[i]="q"
if vysledek[i]==53:
vysledek[i]="r"
if vysledek[i]==54:
vysledek[i]="s"
if vysledek[i]==55:
vysledek[i]="t"
if vysledek[i]==56:
vysledek[i]="u"
if vysledek[i]==57:
vysledek[i]="v"
if vysledek[i]==58:
vysledek[i]="w"
if vysledek[i]==59:
vysledek[i]="x"
if vysledek[i]==60:
vysledek[i]="y"
if vysledek[i]==61:
vysledek[i]="z"
t = []
while True:
try:
n = input()
except EOFError:
break
m = []
k = n.split(' ')
s = ""
cifry = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
for i in range(2):
m.append(int(k[i]))
if m[1] < 0:
m[1] = -m[1]
r = "-"
elif m[1] > 0:
r = ""
elif m[1] == 0:
r = '0'
while m[1] > 0:
s = cifry[m[1] % m[0]] + s
m[1] //= m[0]
t.append(r+s)
for i in range (len(t)):
print(t[i])
import string
chars = string.digits + string.ascii_uppercase + string.ascii_lowercase
def convert(i, base):
if i == 0:
return 0
changingI = abs(i)
answer = []
while changingI != 0:
answer.append(chars[changingI % base])
changingI = changingI // base
if i < 0:
answer.append('-')
answer.reverse()
return "".join(answer)
while True:
try:
line = input()
except EOFError:
break
sline = line.split(" ")
if len(sline) != 2:
break
else:
print(convert(int(sline[1]), int(sline[0])))
def zbyt2str(zbytek):
if zbytek < 10:
zbyteks = str(zbytek)
elif zbytek < 36:
zbyteks = chr(zbytek + 55)
else:
zbyteks = chr(zbytek + 61)
return zbyteks
def prevod(zak,cis):
v = sgn = ""
if cis < 0:
sgn = "-"
cis = - cis
while cis > 0:
zbytek = cis % zak
v = zbyt2str(zbytek) + v
cis = cis//zak
if v == "":
v = "0"
return sgn + v
import sys
for line in sys.stdin:
low_line = line.lower()
try:
[zaks, ciss] = low_line.split()
except ValueError:
break
print(prevod(int(zaks), int(ciss)))
def example1():
x = np.linspace(0, 2, 100)
plt.plot(x, x ** 2)
plt.show()
example1()
def example2():
x = np.linspace(0, 2, 100)
plt.plot(x, x ** 2, label="quadratic")
plt.plot(x, x ** 3, label="cubic")
plt.xlabel("Čas")
plt.ylabel("Počet svišťů")
plt.title("Svišti na cvičišti")
plt.legend()
plt.show()
# plt.savefig("figure.pdf")
example2()
def example3():
x = np.linspace(0, 2, 10)
plt.plot(x, x, 'ro-', label="linear") # Red, dots, line
plt.plot(x, x ** 2, 'b--', label="quadratic") # Blue, dashed line
plt.plot(x, x ** 3, 'g^', label="cubic") # Green, triangles
plt.plot(x, x ** 4, 'ko-', markersize=10, linewidth=4, label="quartic") # Heavy line, big markers
plt.legend()
plt.show()
example3()
def example4():
n = 32
x = np.linspace(0, 2*math.pi, n)
plt.plot(x, np.sin(x), 'o-', color='grey', alpha=0.5)
plt.step(x, np.sin(x), where='pre') # or "mid" or "post"
plt.show()
example4()
def example5():
x = np.linspace(0, math.pi, 10)
y = np.sin(x)
plt.bar(x, y, color='blue', edgecolor='black', width=0.2)
plt.show()
example5()
def example6():
r = np.random.random_sample(100)
plt.hist(r, bins=10, range=(0.,1.), edgecolor='black')
plt.show()
example6()
def example7():
x = np.linspace(0, 2, 100)
plt.fill_between(x, x**2, x**3)
plt.show()
example7()
def example8():
phi = np.linspace(0, 2*math.pi, 100)
r = 1 - np.cos(phi)
plt.polar(phi, r)
plt.show()
example8()
def example9():
x = np.linspace(0, 10, 100)
y = 2**x
# plt.plot(x, y)
plt.semilogy(x, y)
# plt.loglog(x, y)
plt.show()
example9()
def example10():
x = np.linspace(0, 2, 20)
with plt.xkcd():
plt.plot(x, x ** 2, label="quadratic")
plt.plot(x, x ** 3, label="cubic")
plt.xlabel("Čas")
plt.ylabel("Počet svišťů")
plt.title("Svišti na cvičišti")
plt.legend()
plt.show()
example10()
findfont: Font family ['xkcd', 'xkcd Script', 'Humor Sans', 'Comic Neue', 'Comic Sans MS'] not found. Falling back to DejaVu Sans. findfont: Font family ['xkcd', 'xkcd Script', 'Humor Sans', 'Comic Neue', 'Comic Sans MS'] not found. Falling back to DejaVu Sans.
def example11():
x = np.linspace(0, 2, 100)
plt.plot(x, x ** 2)
plt.hlines([1., 2.], xmin=0., xmax=2.)
plt.vlines([1.], ymin=0., ymax=3.)
plt.text(0.1, 1.05, "y=1", fontsize=24)
plt.annotate("y=2", (0.1, 2.05), xytext=(0.15, 2.2), arrowprops={'arrowstyle': '->'}, fontsize=24)
plt.show()
example11()
def example12():
x = np.linspace(0, 2, 100)
plt.subplot(221) # zkratka za (2, 2, 1), což je (#řádků, #sloupců, kolikátý)
plt.plot(x, x)
plt.subplot(222)
plt.plot(x, x**2)
plt.subplot(223)
plt.plot(x, x**3)
plt.subplot(224)
plt.plot(x, x**4)
plt.show()
example12()
def example13():
x = np.linspace(0, 10, 1000)
ax = plt.subplot(311)
plt.plot(x, np.sin(2*math.pi*x))
plt.subplot(312, sharex=ax, sharey=ax)
plt.plot(x, 0.5*np.sin(3*math.pi*x))
plt.subplot(313, sharex=ax, sharey=ax)
plt.plot(x, 0.7*np.sin(5*math.pi*x))
plt.show()
example13()
def example14():
# Založíme obrázek
fig, ax = plt.subplots()
# fig je typu Figure (celý obrázek)
# ax typu Axes (to je jeden graf)
# Nastavíme globální vlastnosti obrázku
fig.set_facecolor('#ccccff')
# Nakreslíme křivku
x = np.linspace(0, 5, 1000)
p, = ax.plot(x, np.cos(2*math.pi*x)) # tuple -> p je typu matplotlib.lines.Line2D
# Nastavíme vlastnosti křivky
p.set_color('red')
p.set_linewidth(2)
# Upravíme textové objekty s čísly u značek na ose x
for tick in ax.get_xticklabels():
tick.set_rotation(55)
plt.show()
example14()
with open("../csv/odpovedi-dotaznik.csv", "r") as f:
nazvy_sloupcu = [x.strip() for x in f.readline().split(',')]
matice_dat = np.loadtxt("../csv/odpovedi-dotaznik.csv", skiprows=1, delimiter=',')
print(nazvy_sloupcu)
matice_dat
['Obtiznost teoreticky ukol', 'Obtiznost prakticky ukol', 'Vtip', 'Vyska', 'Oblibeny mesic', 'Narozeni']
array([[ 3. , 1. , 4. , 190. , 5. , 5. ], [ 3. , 2. , 3. , 168. , 5. , 2. ], [ 3. , 3. , 2. , 160. , 3. , 3. ], [ 2. , 2. , 3. , 170. , 7. , 4. ], [ 3. , 1. , 4. , 4. , 6. , 12. ], [ 4. , 3. , 3. , 168. , 5. , 8. ], [ 3. , 3. , 3. , 168. , 5. , 12. ], [ 4. , 3. , 3. , 165. , 5. , 5. ], [ 2. , 2. , 2. , 179.5, 7. , 6. ], [ 3. , 3. , 1. , 168. , 2. , 2. ], [ 2. , 1. , 2. , 172. , 6. , 6. ], [ 2. , 3. , 2. , 176. , 4. , 4. ], [ 2. , 2. , 3. , 165. , 8. , 4. ], [ 2. , 2. , 3. , 180. , 6. , 5. ]])
uloha1(matice_dat)
uloha1a(matice_dat)
uloha2(matice_dat)
uloha3(matice_dat)
uloha4(matice_dat)