Advertisement
akchonya

a_lab7

Feb 23rd, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. to_dict = input('Введіть координати у форматі "x=<...>, y=<...>": ')
  2. coords = [to_dict[0], to_dict[to_dict.find(',')+2]]
  3. c_values = [to_dict[to_dict.find('x')+2:to_dict.find(',')], \
  4.             to_dict[to_dict.find('y')+2:]]
  5. our_dict = dict(zip(coords, c_values))
  6.  
  7. def vector_len(coords):
  8.     from math import sqrt
  9.     suma_kvad = 0
  10.     for value in our_dict.values():
  11.         value = float(value)
  12.         suma_kvad += value**2
  13.     length = sqrt(suma_kvad)
  14.    
  15.     for key, value in our_dict.items():
  16.         value = float(value)
  17.         our_dict[key] = value/length
  18.     return our_dict['x'], our_dict['y']
  19.  
  20. print('Орт вектора:', vector_len(coords))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement