So my assignment is this: “Using your knowledge of square roots in addition to standard double precision accuracy with your language, what is the square root of the sum of the first 10^5 square roots?
sqrt( sqrt(0) + sqrt(1) + sqrt(2) + ... + sqrt(99999) + sqrt(100000) )
Enter the number rounded to the nearest whole number
I’ve created a script:
from math import sqrt
def sumsqrt():
return sqrt(sum(map(sqrt, range(100001))))
def main():
print sumsqrt
if __name__ == '__main__':
main()
However, when I run this script in Terminal, this is the output:
mcbaby$ python cs28.py
<function sumsqrt at 0x652b0>
So I just decided to run Python in Terminal, and do it there. I did pretty much the same thing, except it worked.
>>> from math import sqrt
>>> sqrt(sum(map(sqrt, range(100001))))
4591.5148887832138
I was hoping somebody could help explain what’s going on. Thanks!
Change
to