From 534f8a13fae962056ae7ffe2cfb80ff40a36ca63 Mon Sep 17 00:00:00 2001 From: Chris Ball Date: Tue, 21 Aug 2007 00:03:19 +0000 Subject: Add a set of sample files. --- (limited to 'data') diff --git a/data/graphics/jump b/data/graphics/jump new file mode 100644 index 0000000..aec5896 --- /dev/null +++ b/data/graphics/jump @@ -0,0 +1,35 @@ +# both of these functions should be in the 'basic' package or some such +def clear_scr(): + print '\x1B[H\x1B[J' # clear screen, the hard way. +def wait(): + import time + time.sleep(0.1) + +# jumping man! +# having to escape the backslash is rather unfortunate +# i didn't have to do that in C64 BASIC +for i in xrange(0,50): + clear_scr() + print "\\o/" + print "_|_" + print " " + wait() + + clear_scr() + print "_o_" + print " | " + print "/ \\" + wait() + + clear_scr() + print " o " + print "/|\\" + print "| |" + wait() + + clear_scr() + print "_o_" + print " | " + print "/ \\" + wait() + diff --git a/data/math/apples b/data/math/apples new file mode 100644 index 0000000..ee726c7 --- /dev/null +++ b/data/math/apples @@ -0,0 +1,15 @@ +print "Let's do math!" + +print "On Monday I picked 22 apples. On Tuesday I picked 12." + +print "Now I have: ", 22 + 12 + +print "My brother says he picked twice as many apples last week." + +print "This means he picked: ", (22 + 12) * 2 + +print "I have 3 friends I would like to give apples." + +print "One third of my apples is about: ", (22 + 12) / 3 + +print "Or, more exactly: ", (22.0 + 12.0) / 3.0 diff --git a/data/math/pascal b/data/math/pascal new file mode 100644 index 0000000..4d600f4 --- /dev/null +++ b/data/math/pascal @@ -0,0 +1,19 @@ +# Pascal's triangle +lines = 8 + +vector = [1] + +for i in range(1,lines+1): + vector.insert(0,0) + vector.append(0) + +for i in range(0,lines): + newvector = vector[:] + for j in range(0,len(vector)-1): + if (newvector[j] == 0): + print " ", + else: + print "%2d" % newvector[j], + newvector[j] = vector[j-1] + vector[j+1] + print + vector = newvector[:] diff --git a/data/math/times1 b/data/math/times1 new file mode 100644 index 0000000..9355f1f --- /dev/null +++ b/data/math/times1 @@ -0,0 +1,2 @@ +for i in range(1,13): + print i, "x 4 =", (i*4) diff --git a/data/math/times2 b/data/math/times2 new file mode 100644 index 0000000..b764ac0 --- /dev/null +++ b/data/math/times2 @@ -0,0 +1,3 @@ +number = input("Which times table? ") +for i in range(1,13): + print i, "x", number, "=", i*number diff --git a/data/python/function b/data/python/function new file mode 100644 index 0000000..18e8e91 --- /dev/null +++ b/data/python/function @@ -0,0 +1,5 @@ +def square(x): + print x * x + +square(3) +square(4) diff --git a/data/python/if b/data/python/if new file mode 100644 index 0000000..dcc9544 --- /dev/null +++ b/data/python/if @@ -0,0 +1,7 @@ +number = input("Enter a number: ") +if number > 5: + print "Greater than 5" +elif number < 5: + print "Less than 5" +else: + print "Number is 5!" diff --git a/data/string/hello1 b/data/string/hello1 new file mode 100644 index 0000000..fc83ab2 --- /dev/null +++ b/data/string/hello1 @@ -0,0 +1 @@ +print "Hello everyone!" diff --git a/data/string/hello2 b/data/string/hello2 new file mode 100644 index 0000000..bb52fc2 --- /dev/null +++ b/data/string/hello2 @@ -0,0 +1,2 @@ +name = raw_input("Type your name here: ") +print "Hello " + name + "!" -- cgit v0.9.1