This practice will be retired on May 31, 2020.

**Heads up!** To view this whole video, sign in with your Courses account or enroll in your free 7-day trial.
Sign In
Enroll

Start a free Courses trial

to watch this video

My solution!

We're looking for feedback on this new type of practice workshop. When you're finished, could you please review the workshop by filling out this short form?

#### Required Downloads

Okay, so I said there were two ways to do this. 0:00 One was, we can break this down into the individual steps and 0:02 that makes it fairly easy. 0:06 So here I got the distance between x, I use the subtraction operator to get that 0:07 distance, and then we square the distance so we multiply this value by itself. 0:12 We repeat that for the y values. 0:18 We add those two together. 0:21 And then we put them here in the square root, between these parenthesis here, 0:22 like I mentioned to get the final value. 0:27 So the distance between our two points is 4.47 whatever the units. 0:29 Now, the other way to do it was all in one single line using the correct precedence 0:34 and using parentheses to define that precedence accordingly. 0:39 So, I've added a comment here so it doesn't execute but 0:42 if I remove this, you'll see that the code runs and it is the exact same value but 0:45 this is all in one line. 0:49 Now obviously, I would go with this approach if I were you, 0:51 because this is a bit more readable. 0:55 So until you understand what's going on here, this is all unnecessary. 0:57 And there's ways down the road, once you learn how to write more code, 1:01 there's ways to improve this, so it's not so unreadable, basically. 1:05 Okay, so hopefully, you got that right. 1:09

You need to sign up for Treehouse in order to download course files.

Sign up