I'm having trouble on the 2.3 Math Module exercise. Maybe it's because I'm not great at math, but I have no idea what the angle_test or ceiling_test functions should look like. Any help?
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Just took a quick look at problem statement. angle_test and ceiling_test are not functions. They are just variables being assigned values. Looks like part 2 is only there to get some practice using the functions imported with the math module. The only one that should give you pause is the base 7 log. Normally, we think in terms of base 10 log or base e log. But the documents for the log function describes how to specify the base (default base is e, the natural log function).
I'm struggling with this too because I don't understand the instruction for 2.3 part 2:"Underneath your function definition, computer the following values using multadd and print out the result." I'm just not sure what's being asked for. You can get the output they want with this statement, but it doesn't use your multadd function:
print "sin(pi/4) + cos(pi/4)/2 is: ", (math.sin(math.pi/4)+ math.cos(math.pi/4)/2)
You can use your multadd function. It looks rather contrived, though. I guess you could try it without using multadd and then repeat it forcing the use of multadd.
angle_test = multadd( 0.5, cos(...), sin(...)
ceiling_test = multadd( 2.0, log(...), ceil(...))
I, personally, don't see much value in using multadd here, but I'll go through the exercise just to confirm that my multadd function produces the correct result.
Not the answer you are looking for? Search for more explanations.
Okay, so I get: angle_test= multadd(math.sin(math.pi/4), 0.5, math.sin(math.pi/4))
print "sin(pi/4) + cos(pi/4)/2 is: \n", angle_test
Seems a long way to go. I guess I was overthinking it, thanks. Oddly the ceiling function comes out at 16.55etc rather than 17.55etc. as in their example.
Thanks, I've gotten the angle_test one to work, just trying to get syntax correct for the ceiling_test, but I'm getting there.
So my answer isn't right, but it's at least working. I understand the concepts so I'm moving on :)
exchaoordo, I had the same result - 16.55... instead of 17.55...
I realised that being exactly 1.0 off the right answer must have had something to do with the ceiling function rounding up, combined with the truncation that happens when you divide with integers rather than floats.
Changing one of my integers (19) to a float (19.0) gave me the correct answer:
print multadd(math.log(12,7), 2.0, math.ceil(276/19))
print multadd(math.log(12,7), 2.0, math.ceil(276/19.0))