7 kyu

Thinkful - Object Drills: Vectors

1,556 of 1,892Grae-Drake

Description:

Create a Vector class with x and a y attributes that represent component magnitudes in the x and y directions.

Your vectors should handle vector additon with an .add() method that takes a second vector as an argument and returns a new vector equal to the sum of the vector you call .add() on and the vector you pass in.

For example:

>>> a = Vector(3, 4)
>>> a.x
3
>>> a.y
4
>>> b = Vector(1, 2)
>>> c = a.add(b)
>>> c.x
4
>>> c.y
6

Adding vectors when you have their components is easy: just add the two x components together and the two y components together to get the x and y components for the vector sum.

Fundamentals
Object-oriented Programming

Stats:

CreatedJan 18, 2017
PublishedJan 18, 2017
Warriors Trained2550
Total Skips22
Total Code Submissions6415
Total Times Completed1892
Python Completions1556
JavaScript Completions365
Total Stars27
% of votes with a positive feedback rating91% of 279
Total "Very Satisfied" Votes234
Total "Somewhat Satisfied" Votes40
Total "Not Satisfied" Votes5
Total Rank Assessments12
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Grae-Drake Avatar
  • ZozoFouchtra Avatar
  • tachyonlabs Avatar
  • hobovsky Avatar
Ad