Skip to content

Instantly share code, notes, and snippets.

@edthrn
Last active May 13, 2019 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edthrn/7b4d30865c0a643f609b6d694f5b83b4 to your computer and use it in GitHub Desktop.
Save edthrn/7b4d30865c0a643f609b6d694f5b83b4 to your computer and use it in GitHub Desktop.
TODO

Guidelines

Implement a Vector class. It should take an undefenite amount of parameters and behave like this:

>>> v1 = Vector(5, 9, -8, 2, 13, -23, 0, 0, 12)
>>> v2 = Vector(6, 8)
>>> v3 = Vector(-1, 1, 1, -1)
>>> v4 = Vector(0, 0, 0)

>>> v2
Vector(6.0, 8.0)

>>> v1[2:6]
Vector(-8, 2, 13, -23)

>>> abs(v2)
10

>>> v2 == Vector(6, 8)
True

>>> for elmt in v3:
....    print(elmt)
-1
1
1
-1

>>> if v4:
...     print('yes')
... else:
...     print('no')
'no'

>>> v1[0] = 12  # Assignation is forbidden!
Error!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment