Primes by Python

The point of the following post is not necessarily the content, but the format. I just installed the SyntaxHighlighter plugin for WordPress, and I wanted to test it out. So, the story goes, yesterday I was trying to get my Python touch back (I haven’t had time to write code in quite a while), and thought it would be cool to be able to be able to post code in an aesthetically pleasing manner, if I ever write any code worth publishing (but not quite good enough to distribute as software). Anyway, here goes.


# A quick function to determine if a given number is prime
def isprime(num):
lst=[]
for n in range(2,num/2+1):
if round(num/n)*n==num:
lst.append(n)
if len(lst)==0:
print "Yeah, it's prime"
return True
else:
print "Nope, actually it has factors", lst
return False

After publishing this and looking at the result, I realize that the highlighting works, but there is no automatic indentation! As indentation is critical with Python, I think I’ll be searching for another plugin that can handle this.

0 Responses to “Primes by Python”


  1. No Comments

Leave a Reply