Merge branch 'master' into master

This commit is contained in:
Luke Weiler
2020-10-19 09:39:55 -04:00
committed by GitHub
7 changed files with 71 additions and 13 deletions

View File

@@ -71,4 +71,8 @@ from .multiplyComplexNumbersFunc import *
from .geomProgrFunc import *
from .geometricMeanFunc import *
from .harmonicMeanFunc import *
from .binary2sComplement import *
from .euclidianNormFunc import *
from .angleBtwVectorsFunc import *
from .absoluteDifferenceFunc import *
from .vectorDotFunc import *
from .binary2sComplement import *

View File

@@ -0,0 +1,10 @@
from .__init__ import *
def absoluteDifferenceFunc (maxA = 100, maxB = 100):
a = random.randint(-1*maxA, maxA)
b = random.randint(-1*maxB, maxB)
absDiff = abs(a-b)
problem = "Absolute difference between numbers " + str(a) + " and " + str(b) + " = "
solution = absDiff
return problem, solution

View File

@@ -0,0 +1,16 @@
from .euclidianNormFunc import euclidianNormFunc
import math
from .__init__ import *
def angleBtwVectorsFunc(v1: list, v2: list):
sum = 0
for i in v1:
for j in v2:
sum += i * j
mags = euclidianNormFunc(v1) * euclidianNormFunc(v2)
problem = f"angle between the vectors {v1} and {v2} is:"
solution = math.acos(sum / mags)
# would return the answer in radians
return problem, solution

View File

@@ -0,0 +1,7 @@
from .__init__ import *
def euclidianNormFunc(v1: list):
problem = f"Euclidian norm or L2 norm of the vector{v1} is:"
solution = sqrt(sum([i**2 for i in v1]))
return problem, solution

View File

@@ -0,0 +1,11 @@
from .__init__ import *
def vectorDotFunc(minVal=-20, maxVal=20):
a = [random.randint(minVal, maxVal) for i in range(3)]
b = [random.randint(minVal, maxVal) for i in range(3)]
c = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
problem = str(a) + " . " + str(b) + " = "
solution = str(c)
return problem, solution