Sep-29-2016, 10:47 PM
Some homework that I have been struggling on mainly because I am unsure how to proceed. I have all the formulas I need but I haven't been able to find a useful online tutorial for how to get the necessary information out of a 2-tuple.
Thanks!
print (pathLength2d ([(0,0), (1,1)]))
import math def length (v): """ Length of a vector in 2-space. Params: v (2-tuple) vector in 2-space Returns: (float) length """ number = 0 for i in range(len(str(v))): number += v[i]**2 return math.sqrt(number)I know that's an error as it's trying to multiply an index of (0,0) by itself. I'm not asking for a full out solution, but a pointer in the right direction.
Thanks!