Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- to_dict = input('Введіть координати у форматі "x=<...>, y=<...>": ')
- coords = [to_dict[0], to_dict[to_dict.find(',')+2]]
- c_values = [to_dict[to_dict.find('x')+2:to_dict.find(',')], \
- to_dict[to_dict.find('y')+2:]]
- our_dict = dict(zip(coords, c_values))
- def vector_len(coords):
- from math import sqrt
- suma_kvad = 0
- for value in our_dict.values():
- value = float(value)
- suma_kvad += value**2
- length = sqrt(suma_kvad)
- for key, value in our_dict.items():
- value = float(value)
- our_dict[key] = value/length
- return our_dict['x'], our_dict['y']
- print('Орт вектора:', vector_len(coords))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement