Posted: Fri Dec 31, 2010 5:04 pm Post subject: Please Be Gentle With Ur Help Older Godz
Hello, Im new to Python and programming in general and i have been going slowly thru the 'how to think like a computer scientist python edition' slowly. I reached this exercise which wants you to calculate the sum of the squares of each digit in an integer. Is there a built in function for doing this in python or is it doable somehow using the knowledge I already got up until this point??? If so ... don't tell me ill figure it out somehow. anywayz thanks
Sponsor Sponsor
Tony
Posted: Fri Dec 31, 2010 5:12 pm Post subject: RE:Please Be Gentle With Ur Help Older Godz
Is there a build in function that does sum of squares? No. But there are methods for raising an integer to any power (including 2) and methods for collecting a bunch of numbers together (such as in a sum).
Posted: Fri Dec 31, 2010 5:12 pm Post subject: Re: Please Be Gentle With Ur Help Older Godz
ChamerZ @ Fri Dec 31, 2010 5:04 pm wrote:
is it doable somehow using the knowledge I already got up until this point???
This is sorta hard to answer without somehow figuring out the knowledge you already have. I suggest posting what code or ideas you have already.
ChamerZ
Posted: Fri Dec 31, 2010 5:30 pm Post subject: Re: Please Be Gentle With Ur Help Older Godz
McKenzie @ Fri Dec 31, 2010 5:12 pm wrote:
ChamerZ @ Fri Dec 31, 2010 5:04 pm wrote:
is it doable somehow using the knowledge I already got up until this point???
This is sorta hard to answer without somehow figuring out the knowledge you already have. I suggest posting what code or ideas you have already.
i cant post it right now because its on the other computer .. but basic mundane stuff (i basically just discovered how to do the while loop). So there's no built in function? ok cool this is gonna be fun
ChamerZ
Posted: Fri Dec 31, 2010 5:33 pm Post subject: Re: RE:Please Be Gentle With Ur Help Older Godz
Tony @ Fri Dec 31, 2010 5:12 pm wrote:
Is there a build in function that does sum of squares? No. But there are methods for raising an integer to any power (including 2) and methods for collecting a bunch of numbers together (such as in a sum).