Today in another trivia board I'm on, there was this math question:
"Identify a multi-digit number such that when each digit is raised to the power of itself, and the result of each of those is added together you get the original number."
eg: 274 = (2 ^ 2) + (7 ^ 7) + (4 ^ 4)
We were given the hint that it's 4 digits, which was helpful. I quickly wrote this FoxPro script to figure it out for me:
[image: image.png]
But then I thought, I should really figure out how to do this in Python if I'm ever really going to learn. I've run through a few online tutorials, but I still had to google how to do for loops, how to convert integers into strings and then parse that string, how exponentiation worked, even how if statements work. Finally got it to this. [image: image.png]
Just sharing this extremely simple example in case anyone's interested. But glad I went through the exercise.
Eric
--- StripMime Report -- processed MIME parts --- multipart/related multipart/alternative text/plain (text body -- kept) text/html image/png image/png ---
Eric - Blogpost this...
BTW - Images did not come though on message board, at least not to me.
*Matt Slay*
On 01/22/2020 12:11 PM, Eric Selje wrote:
Today in another trivia board I'm on, there was this math question:
"Identify a multi-digit number such that when each digit is raised to the power of itself, and the result of each of those is added together you get the original number."
eg: 274 = (2 ^ 2) + (7 ^ 7) + (4 ^ 4)
We were given the hint that it's 4 digits, which was helpful. I quickly wrote this FoxPro script to figure it out for me:
[image: image.png]
But then I thought, I should really figure out how to do this in Python if I'm ever really going to learn. I've run through a few online tutorials, but I still had to google how to do for loops, how to convert integers into strings and then parse that string, how exponentiation worked, even how if statements work. Finally got it to this. [image: image.png]
Just sharing this extremely simple example in case anyone's interested. But glad I went through the exercise.
Eric
--- StripMime Report -- processed MIME parts --- multipart/related multipart/alternative text/plain (text body -- kept) text/html image/png image/png
[excessive quoting removed by server]
Good idea thanks!
http://saltydogllc.com/a-foxpro-to-python-etude/
E
On Wed, Jan 22, 2020 at 12:33 PM Matt Slay mattslay@jordanmachine.com wrote:
Eric - Blogpost this...
BTW - Images did not come though on message board, at least not to me.
*Matt Slay*
On 01/22/2020 12:11 PM, Eric Selje wrote:
Today in another trivia board I'm on, there was this math question:
"Identify a multi-digit number such that when each digit is raised to the power of itself, and the result of each of those is added together you
get
the original number."
eg: 274 = (2 ^ 2) + (7 ^ 7) + (4 ^ 4)
We were given the hint that it's 4 digits, which was helpful. I quickly wrote this FoxPro script to figure it out for me:
[image: image.png]
But then I thought, I should really figure out how to do this in Python
if
I'm ever really going to learn. I've run through a few online tutorials, but I still had to google how to do for loops, how to convert integers
into
strings and then parse that string, how exponentiation worked, even how
if
statements work. Finally got it to this. [image: image.png]
Just sharing this extremely simple example in case anyone's interested.
But
glad I went through the exercise.
Eric
--- StripMime Report -- processed MIME parts --- multipart/related multipart/alternative text/plain (text body -- kept) text/html image/png image/png
[excessive quoting removed by server]