def vrat_bod(bod, debug=False): """Zajistuje vstup od uzivatele ve forme bodu. Args: - bod - vstup funkce - debug - testovací důvod Returns: - vystup - zadane parametry uzivatelem """ x = 0 y = 0 if (not debug): n = f'Zadej bod {bod} souradnici' while True: try: x = float(input(f'{n} x: ').strip()) break except TypeError: print('Je treba zadat ciselnou hodnotu') while True: try: y = float(input(f'{n} y: ').strip()) break except TypeError: print('Je treba zadat ciselnou hodnotu') return Bod(x, y)
def secteni_souradnic(bod1, bod2): """Secte souradnice bodu zadanych uzivatelem. Args: - bod1, bod2 - vstup funkce Returns: - vystup - vysledek souctu dvou bodu """ return Bod(abs(bod1.x - bod2.x), abs(bod1.y - bod2.y))
def test_delka_strany2(): """Test delky stran.""" assert round(delka_strany(Bod(3, 2), Bod(0, -1)), 2) == 4.24
def test_delka_strany(): """Test delky stran.""" assert delka_strany(Bod(2, 2), Bod(-1, -2)) == 5.0
def test_secteni_souradnic2(): """Test souctu souradnic.""" bod = secteni_souradnic(Bod(4, 2), Bod(-2, -0)) assert bod.x == 6.0 and bod.y == 2.0
def test_secteni_souradnic(): """Test souctu souradnic.""" bod = secteni_souradnic(Bod(3, -2), Bod(-1, -2)) assert bod.x == 4.0 and bod.y == 0.0
def test_pythagorova_veta2(): """Test Pythagorovy vety.""" assert round(pythagorova_veta(Bod(3, 3)), 2) == 4.24
def test_pythagorova_veta(): """Test Pythagorovy vety.""" assert round(pythagorova_veta(Bod(3, 4)), 2) == 5.0