This is the blog for Matt Hollingsworth. I'm from Ojai, California. I've worked in comics for 22 years as a color artist.

This blog will largely be used to show my daily life as I live in Samobor, Croatia and as I travel around the region. Lots and lots of photos! Leave me a comment, will you?

All content on this blog is copyright 2013 Matthew Dale Hollingsworth and cannot be copied or used for any purpose without my consent.

Thursday, April 05, 2007

A stranger on MySpace recently approached me. They are taking a class which includes some Python programming. Apparently, they must have done a keyword search on MySpace for "Python Programming", found me, then asked for help.

The assignment was to list only leap years. I didn't do a "perfect" program for her, because I didn't want to do her assignment FOR her. She had to make a function of this, so I didn't do that for her. And I left her the problem of trying to figure out how to have that zero year without just dropping it into the list. But I figured this would get her head around making lists and sorting data, so it couldn't hurt too much. Besides, it was fun to program for a few minutes. I haven't done much programming since I've been in Croatia.

So, this time, instead of getting the Croatian language, you get the Python language:

#!/usr/bin/python

#written by matt hollingsworth
#04.04.2007

#short script to count every four years and print the year out
#evidently leap years don't land right ON the century mark, except for
#every four centuries, so I need to remove the centuries

century_list = ["0"]

for item in range(0, 3000, 4):
....comparison = str(item)[-2:]
....if comparison == "00":
........century_list.append(item)
....else:
........print item

#now go through our list of centuries and also show only every fourth item

list_length = len(century_list)

#print century list to see how we're doing

print century_list

for item in range(0, list_length, 4):
....print century_list[item]


2 comments:

michael said...

I liked your article, and it really taught me a lot about myspace, but what's up with the background?

Matt Hollingsworth said...

Thanks. Uh, what background? Here? That's just my blog background. On MySpace? That's some of my comics work. I work in comics, doing color art for Marvel Comics.