Warning
This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

Table of Contents

Cvičení 1

01a

01b

Python jako kalkulačka Vybrané příkazy prováděné ve videau:

2+3*4+5
(2+3)*(4+5)
1-2+3
(1-2)+3
1-(2+3)
12/2*3
(12/2)*3
12/(2*3)
2**3**4
(2**3)**4
2**81
7%5
7%-5
-11%-5
7//5
5*(7//5)+7%5
-5*(7//-5)+7%-5
12/3
12//3
float(2**53)
float(2**53+1)
2**1024
float(2**1024)
int(1.9)
int(-1.9)
round(1.9)
round(-1.9)

01c

Řešení kvadratické rovnice

quadratic.py:

a=float(input())
b=float(input())
c=float(input())
D=b**2-4*a*c
if D>=0:
  x_1=(-b+D**0.5)/(2*a)
  x_2=(-b-D**0.5)/(2*a)
  if x_1>x_2:
      x_1, x_2 = x_2,x_1
  print(x_1,x_2)
else:
    print('Rovnice nema realne reseni')

01d

For cyklus

scitani.py:

acc=0
for i in range(1000):
    acc+=i
    if acc>1000:
        acc-=i
        print("Vysledek je",i-1,"soucet je",acc)
        break

continue.py:
for i in range(15):
    if i%2==0:
        continue
    if i%3==0:
        continue
    print(i)

dvojice.py:

end=False
for i in range(1,50):
    for j in range(1,50):
        if (i%3==0) and (j%5==0) and ((i+j)%7==0):
            print(i,j,i+j)
            end=True
            break
    if end:
        break

courses/b3b33alp/cviceni/kratka_videa/c01.txt · Last modified: 2021/09/10 10:11 by stepan