This example neatly prints the multiplication table with dimensions the user entered.<br><br><br>diff --git a/data/GSOC examples/multiplication table b/data/GSOC examples/multip<br>new file mode 100644<br>index 0000000..4601f01<br>
--- /dev/null<br>+++ b/data/GSOC examples/multiplication table <br>@@ -0,0 +1,69 @@<br>+import time<br>+import os<br>+<br>+print "This will draw the multiplication table with dimensions of your choice."<br>+print "Feel free to modify and drawing speed and other variables."<br>
+<br>+# how many numbers per second? Default is 5.<br>+drawing_speed = 5<br>+<br>+# raw_input() will get whatever text you enter with your keyboard.<br>+# int() will give an error if it can't turn that text into a number.<br>
+try:<br>+ print "How many numbers wide?"<br>+ x = int(raw_input())<br>+<br>+ print "How many numbers high? "<br>+ y = int(raw_input())<br>+# If there's an error in the "try:" block of code, the following will happen.<br>
+# The program will print an error message and quit.<br>+except:<br>+ print "That is not a valid number."<br>+ sys.exit()<br>+<br>+# In case everything went well, the program didn't quit and is now here.<br>
+# The following will create two lists of numbers, each starting with 1 and<br>+# ending with whatever you entered as x ("row" list) and y ("column" list).<br>+# Practice: By default, both lists start with 1. What if we changed that?<br>
+row = range(1, x+1)<br>+column = range(1, y+1)<br>+<br>+# From now on, everything we want to print on the screen we'll store <br>+# in the "output" variable. First we make it an empty string, and then add to i<br>
+# whatever we want to print.<br>+output = ""<br>+# the first printed line, for decoration:<br>+# add the beginning of it<br>+output += "|-------|--" <br>+# for each number in a row, add eight dashes and mark the end of line with \n<br>
+# \n is called a 'newline' and it makes your console start writing a new line.<br>+output += len(row) * "--------" +"\n" <br>+# What the second line starts with. \t marks one tab.<br>+output += "|\t|\t"<br>
+<br>+# Now, we would like to print the first row of numbers, which<br>+# represent the factors we'll multiply. Add each number from "row"<br>+# to the output string. str(number) turns a number to characters<br>
+# (like number 42 to characters '4' and '2')<br>+for number in row:<br>+ output += str(number) + "\t"<br>+<br>+# add another decorative line<br>+output += "\n" + "|-------|--" + len(row) * "--------" + "\n"<br>
+<br>+# for each number in the first column, multiply it with each number in the <br>+# first row. One by one, add the results to "output" and print it.<br>+for factor1 in column:<br>+ output += "| " + str(factor1) + "\t|\t"<br>
+ for factor2 in row:<br>+ output += str(factor1*factor2) + "\t"<br>+ # clear the screen from what was last printed (old output) so <br>+ # we can print the new output (with one result added)<br>
+ os.system('clear')<br>+ print output<br>+ # Pause the program. If "drawing_speed" is 5, it will pause for <br>+ # 1/5 seconds (0.2 seconds), which gives us five characters <br>
+ # per seconds.<br>+ time.sleep(1.0 / drawing_speed)<br>+ # mark the end of the line<br>+ output += "\n"<br><br>