Project Euler Problem 4 in Python
I've decided to take up Python as a hobby. Why? In school, we use Macs. Netbeans is hard to close quickly, but the terminal has almost instant loading. I can basically just type "python test.py" and there you go, the file is running. Plus, I've always wanted to use Vim. (I actually use MacVim; the built in Vim has no syntax highlighting, full screen mode, etc.) So to learn Python faster, I'm doing all of the Project Euler problems when class gets really slow.
import time starttime = time.time() def isPalindrome(s): if s == s[::-1]: return True else: return False i = 100 j = 100 greatest = 0 while (i <= 999): while (j <= 999): product = i * j if (product > greatest and isPalindrome(str(product))): greatest = product j += 1 j = 100 i += 1 print "Greatest value found: " + str(greatest) finishtime = time.time() print "Execution time: " + str(finishtime - starttime) + " seconds"
If you have any suggestions for how I could improve this, I'd appreciate it.
If you have a good syntax highlighting plugin for Wordpress, that'd be good too.