Merge pull request #229 from Souvikdeb2612/master

Added the functions for sector area, mean and median
This commit is contained in:
Luke Weiler
2020-10-19 10:33:38 -04:00
committed by GitHub
4 changed files with 27 additions and 0 deletions

View File

@@ -77,3 +77,5 @@ from .absoluteDifferenceFunc import *
from .vectorDotFunc import * from .vectorDotFunc import *
from .binary2sComplement import * from .binary2sComplement import *
from .matrixInversion import * from .matrixInversion import *
from .sectorAreaFunc import*
from .meanMedianFunc import*

View File

@@ -0,0 +1,13 @@
.__init__ import *
def meanMedianFunc(maxlen = 10):
randomlist = random.sample(range(1, 99), maxlen)
total = 0
for n in randomlist:
total = total + n
mean = total/10
problem = f"Given the series of numbers {randomlist}. find the arithmatic mean and mdian of the series"
randomlist.sort()
median = (randomlist[4]+randomlist[5])/2
solution = f"Arithmetic mean of the series is {mean} and Arithmetic median of this series is {median}"
return problem, solution

View File

@@ -0,0 +1,10 @@
.__init__ import *
def sectorAreaFunc(maxRadius = 49,maxAngle = 359):
Radius = random.randint(1, maxRadius)
Angle = random.randint(1, maxAngle)
problem = f"Given radius, {Radius} and angle, {Angle}. Find the area of the sector."
secArea = float((Angle / 360) * math.pi*Radius*Radius)
formatted_float = "{:.5f}".format(secArea)
solution = f"Area of sector = {formatted_float}"
return problem, solution

View File

@@ -109,3 +109,5 @@ absoluteDifference=Generator("Absolute difference between two numbers", 71, "Abs
vectorDot = Generator("Dot Product of 2 Vectors", 72, "a . b = ", "c", vectorDotFunc) vectorDot = Generator("Dot Product of 2 Vectors", 72, "a . b = ", "c", vectorDotFunc)
binary2sComplement = Generator("Binary 2's Complement", 73, "2's complement of 11010110 =", "101010", binary2sComplementFunc) binary2sComplement = Generator("Binary 2's Complement", 73, "2's complement of 11010110 =", "101010", binary2sComplementFunc)
invertmatrix = Generator("Inverse of a Matrix", 74, "Inverse of a matrix A is", "A^(-1)", matrixInversion) invertmatrix = Generator("Inverse of a Matrix", 74, "Inverse of a matrix A is", "A^(-1)", matrixInversion)
sectorArea=Generator("Area of a Sector", 75,"Area of a sector with radius, r and angle, a ","Area",sectorAreaFunc)
meanMedian=Generator("Mean and Median", 76,"Mean and median of given set of numbers","Mean, Median",meanMedianFunc)