# file: message.py print "When that Aprill with his shoures soote"; print "The droghte of March ath perced to the roote,"; print "And bathed every veyne in swich licour"; print "Of which vertu engendered is the flour...";
> python message.py When that Aprill with his shoures soote The droghte of March ath perced to the roote, And bathed every veyne in swich licour Of which vertu engendered is the flour... >
# calculate.py import math print "2 + 3 =", 2+3 print "log(1e23) =", math.log(1e23) print "2*sin(3.1414) = ", 2*math.sin(3.1414)
> python calculate.py 2 + 3 = 5 log(1e23) = 52.9594571389 2*sin(3.1414) = 0.000385307177203 >
# now.py import datetime now = datetime.datetime.now() print "Now is", now.strftime("%d-%m-%Y"), "at", now.strftime("%H:%M") print "or, more precisely, %s" % now
> python now.py Now is 02-02-2004 at 19:55 or, more precisely, 2004-02-02 19:55:43.046953 >
This page based on Some Simple Scripts.