[Sugar-devel] GSOC: Pippy ideas
Hello everyone, a GSOC candidate here. I got the idea on how I'd like to contribute to your project a few hours ago so I haven't yet managed to write my proposal (evaluate my ideas, consider the technical aspects etc.) and publish it on the Idea Torrent (I'll most likely do that in the next 24 hours) so I would really like to hear your opinions on my still raw idea to know if it's even appropriate. I would like to work on Pippy and do the following: 1) write more examples to at least double the current amount. 2) write an interactive Python tutorial. Learners would be introduced to Python, given lessons to study, encouraged to try experimenting with the code, asked questions which would direct them further (either pointed to their mistakes and the parts of the lesson they should reread, or given the next lesson) etc. Unless I've missed something (I admit, I wasn't very thorough yet), Pippy is basically static - learners are given examples with some comments and an interpreter. This tutorial would facilitate their learning process. The tutorial would be based on constructivist principles (I'm studying to become a teacher of CS and have had additional experience with constructivism, but I'll leave my introduction for the proposal). 3) Instead of preparing a test to check learners' knowledge when they finish a batch of lessons, I would write an adventure game in which the player moves towards the goal by solving Python problems. I'll throw some ideas: the player starts as a level 1 wizard who has just learned a few basic spells (Python commands). He meets enemies which he must defeat by demonstrating his knowledge of Python and programming creativity. At first, he'd have to feed the villagers (just set some "food" variables to a higher number), then perhaps defeat a few goblins (using loops to inflict damage, control statements to heal himself...) and finally slay the ancient dragon by studying his API functions and finding a weakness for which to exploit he'll have to write a DragonSlayer class. Of course, the game would have to be text based (at least for now) since anything else would be too much for one GSOC project. 4) Assist in translating Sugar to Croatian, as it is now only 23% complete. Now, I know that it's quite improbable to bring all of this to a 'production quality' standard and that's one of the reasons why I would appreciate feedback from the group - to know what to focus on and whether these are appealing ideas for Sugar at the moment. I could write the examples easily, but I think that the realistic goal for ideas 2) and 3) would be either to have a high quality tutorial and a basic version of the game, or a good tutorial and a good game (I don't mean "writing the tutorial poorly", just not getting quite as far as I could if I were to only focus on that). I think I'd personally prefer to go with the latter idea because your software is for children up to 12 years old and that somewhat limits how much advanced Python concepts we could teach them. Though, we might stumble into some prodigies that way... I hope you'll have the time to write some feedback soon. Kind regards, Dinko Galetic ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Pippy example - Koch snowflake
Hi, I've added a few new examples to Pippy. They're available in my repository ( http://git.sugarlabs.org/projects/pippy/repos/dgaletic-gsoc2010); I haven't made an .xo since I'm having some problems with my Sugar installation. Since this is about learning Python, in each of them I've tried to have several places where the learner is invited to modify come code. This one draws the Koch snowflake using pygame. The user can decrease/increase the number of triangles with left and right arrows. diff --git a/data/GSOC examples/Koch snowflake b/data/GSOC examples/Koch snowfla new file mode 100644 index 000..2fb218e --- /dev/null +++ b/data/GSOC examples/Koch snowflake @@ -0,0 +1,208 @@ +# This example draws a shape called the Koch snowflake. + +import pippy, pygame, sys +from pygame.locals import * +from random import * +import math + +# always need to init first thing +pygame.init() + +# XO screen is 1200x900 +size = width, height = 1200, 900 + +# create the window and keep track of the surface +# for drawing into +screen = pygame.display.set_mode(size) + +# turn off the cursor +pygame.mouse.set_visible(False) + + +# Set some variables. +# Snowflakes are white! +color = (255,255,255) + +# the center point of the screen +# We need it because we'll place out triangle around it. +center = width / 2, height / 2 + +# Side of an equilateral triangle (the one we start with). +# Here it is defined relative to the resolution of the screen. +# Practice: We could play with other values, absolute (like a = 100) or +# relative (a = height / 2, a = width / 3, etc). What looks best for you? +a = height/1.4 + +# Height of that triangle. +# Just a simple geometry formula, nothing Python-special about it. +h = int(a * math.sqrt(3) / 2) + +# These will be the vertices for the starting triangle. +# The triangle vertices are named like this: +# +#C +# / \ +# A _ B +# +A = center[0]- a/2, center[1] + h/3 +B = A[0] + a, A[1] +# To find the third point, we need slightly more advanced math. +# If you with to understand it, you could try finding some material about trigo +# We use the coordinates of vertice A to calculate where point C will be. +C = A[0] + math.cos(math.pi/3) * a, A[1] - math.sin(math.pi/3) * a + +# This class will allow us to store data about a line. +class Line(object): +def __init__(self, a = A, b = B): +# This is how a line object will remember its points and length. +self.A = a +self.B = b +self.points = [self.A, self.B] + +# We use the Pythagorean theorem to calculate the length of a line +# from the coordinates of its points. +self.length = math.sqrt( (a[0]-b[0])**2 + (a[1]-b[1])**2 ) + +# Projection of the line on the x axis. +# We use it to figure out the angle which the line closes with the x ax +projection_length = b[0] - a[0] + +# If the line is descending, the angle is negative. Trigonometry, again +if b[1] > a[1]: +self.angle = -math.acos(projection_length / self.length) +else: +self.angle = math.acos(projection_length / self.length) + +# To draw new shapes, an old line must be split into its thirds. +def split(self): +third = self.length / 3.0 +self.D = self.A[0] + math.cos(self.angle) * third, \ + self.A[1] - math.sin(self.angle) * third +self.E = self.A[0] + math.cos(self.angle) * 2*third, \ + self.A[1] - math.sin(self.angle) * 2*third +self.points.append(self.D) +self.points.append(self.E) + +# Give a line (from which we'll need the coordinates of its starting point) and +# an angle, calculate the position of a new point - the vertex of out snowflake +# The length of its sides should be 1/3 of the length of the line from which +# it is made. +def calculate_new_point(line, angle): +p = line.D[0] + math.cos(angle + line.angle) * line.length / 3, \ +line.D[1] - math.sin(angle + line.angle) * line.length / 3 +return p + + +# The following function from a single line, like this: +# +# A___B +# +# creates four lines, like this: +# +# F +# A_D/ \E_B +# +def transform_line(line): +line.split() +C = calculate_new_point(line, math.pi/3) +line1 = Line(line.A, line.D) +line2 = Line(line.D, C) +line3 = Line(C, line.E) +line4 = Line(line.E, line. B) +lines = [line1, line2, line3, line4] +return lines + +# For each line in starting_lines, call transform_line(). +# Repeat "depth" times for each line created this way. +def produce_lines(starting_lines, depth): +all_lines = starting_lines +for i in range(depth): +new_lines = [] +for line in all_lines: + new_lines += transform_line(line) +# clearn the old lines first +all_lines = [] +all_lines = new_lines +return all_lines + +# Write the lines on screen. +def draw_lines(lines): +for line in lines: +pygame.draw.line(screen, c
[Sugar-devel] [PATCH] Pippy example - Sierpinski triangle
This Python script draws the Sierpinski triangle. As with my Koch snowflake example, the user can modify the number of triangles using left and right arrows. diff --git a/data/GSOC examples/Sierpinski - graphics b/data/GSOC examples/Sierp new file mode 100644 index 000..449277a --- /dev/null +++ b/data/GSOC examples/Sierpinski - graphics @@ -0,0 +1,146 @@ +# This example draws what is called the Sierpinski triangle. +# First, one black triangle is created. +# After that it is removed and in its place three smaller black triangles are c +# which leaves a white hole (also shaped like a triangle, but upside down!) in +# +# This can continue for any number of steps - you can split the smaller +# triangles into even smaller ones and so on. +# We have, however, limited it to 8 to keep our computers from freezing due to +# too much calculations! If you change it to a higher number, that will probabl +# +# This code is similar to the code in "Koch snowflake" example so you +# could first go through that to understand this example better. + +import pippy, pygame, sys +from pygame.locals import * +from math import sin, cos +from math import pi as Pi + +class Triangle(object): +def __init__(self, first_vertex, length, displacement_angle = 0 ): +# remember your first vertex +self.A = first_vertex +# calculate the other two +self.B = self.A[0] + length * cos(Pi/3 + displacement_angle), \ + self.A[1] - length * sin(Pi/3 + displacement_angle) +self.C = self.A[0] + length * cos(displacement_angle), \ + self.A[1] - length * sin(displacement_angle) +# remember your length +self.length = length +# calculate the midpoints of each line +# m1 for AB, m2 for BC, m3 for CA +# m1 and m3 are calculated the same way as points B and C, but with +# half the length. +self.m1 = self.A[0] + length/2 * cos(Pi/3 + displacement_angle), \ + self.A[1] - length/2 * sin(Pi/3 + displacement_angle) +self.m3 = self.A[0] + length/2 * cos(displacement_angle), \ + self.A[1] - length/2 * sin(displacement_angle) +# m2 is 120 degrees (2*Pi/3) from C, half the length. +# ... but we don't actually need it for anything. +self.m2 = self.C[0] + length/2 * cos(2*Pi/3 + displacement_angle), \ + self.C[1] - length/2 * sin(2*Pi/3 + displacement_angle) + +# create three new triangles from yourself. +def split(self): +new_triangles = [] +new_triangles.append(Triangle(self.A, self.length/2)) +new_triangles.append(Triangle(self.m1, self.length/2)) +new_triangles.append(Triangle(self.m3, self.length/2)) +return new_triangles + +# This is how a triangle draws itself. +def draw(self, screen, color): +points = [self.A, self.B, self.C] +pygame.draw.polygon(screen, color, points) + +# always need to init first thing before drawing +pygame.init() + +# XO screen is 1200x900 +size = width, height = 1200, 800 + +# create the window and keep track of the surface +# for drawing into +screen = pygame.display.set_mode(size) + +# The font we'll use to display the current depth. +font_size = 36 +font = pygame.font.Font(None, font_size) + +black = (0, 0, 0) +white = (255, 255, 255) + +starting_point = (200, 750) +side_length = 800 + +t1 = Triangle(starting_point, side_length) +t2 = Triangle((800, 600), 150) + +depth = 0 + +all_triangles = [t1] +new_triangles = [] + +recalculate = False + +while pippy.pygame.next_frame(): +for event in pygame.event.get(): +if event.type == QUIT: +sys.exit() +# When R arrow is pressed, go one step further. +# This means splitting the existing triangle(s) into new ones. +# Note that all the triangles have to be recalculated before redrawn. +elif event.type == KEYDOWN and event.key == K_RIGHT and depth < 8: +depth += 1 +recalculate = True +# When L arrow is pressed, go one step back, reducing the number of +# triangles. +# Note that all the triangles have to be recalculated before redrawn. +elif event.type == KEYDOWN and event.key == K_LEFT and depth > 0: +depth -= 1 +recalculate = True +elif event.type == KEYDOWN: +sys.exit() +screen.fill(white) +# Display the current step. +msg = "Step: " + str(depth) + "/8" +text = font.render(msg , True, black) +text_box = text.get_rect() +text_box.top = 130 +text_box.left = 50 +# Display the instructions +text2 = font.render("Use left and right arrows.", True, black) +text_box2 = text2.get_rect() +text_box2.top = 100 +text_box2.left = 50 +# Write the instructions and the current step on the screen. +screen.blit(text, text_box) +screen.blit(text2, text_box2) + +# If the depth was changed (L or R pressed), recalc
[Sugar-devel] [PATCH] Pippy example - Opening websites
This example covers some basic functionality of urllib2 - opening a website, reading from it and finding its title. diff --git a/data/GSOC examples/Opening websites b/data/GSOC examples/Opening we new file mode 100644 index 000..97ee16f --- /dev/null +++ b/data/GSOC examples/Opening websites @@ -0,0 +1,64 @@ +# This example demonstrates how urllib2 can be used to open websites and read +# some data from them. + +import urllib2 + +# define a function which will open a bunch of links we give it in a list +def open_sites(links): +sites = [] +for url in urls: +print "Opening: " + url +# try to open that site +try: +site = urllib2.urlopen(url) +except: +# Does an error occur with any of the default urls? +# Practice: If so, could you fix it? +print "An error has occured, skipping " + url +print +raw_input("...press enter key to continue...") +continue +if site.geturl() != url: +print "Careful! Site " + url + " has redirected you to " + site.get +print "Site " + site.geturl() + " is now open." +print +sites.append(site) +raw_input("...press enter key to continue...") +print +return sites + +url1 = "http://www.google.com"; +url2 = "http://www.sugarlabs.org"; +url3 = "www.wikipedia.org" +urls = [url1, url2, url3] + +sites = open_sites(urls) + +print +print "Let's read those sites and find their titles." +print +raw_input("...press enter key to continue...") +print + +for site in sites: +site_content = site.read() +title_at = site_content.find("") + 7 +print "The title of site at " + site.geturl() + " begins at its index " + s +title_ends = site_content.find("", title_at) +title = site_content[title_at:title_ends] +# In Python, \ is the so-called "escape" character. Since some characters h +# special meanings, like " or ' opening and closing a string, we have to te +# the interpreter to ignore such meanings when we wish to put those precise +# characters in a string (or print them). In the following line, we wish to +# print the " character so we "escape" it - by putting \ in before it. +# Practice: What would we have to do to print an escape character \ ? +print "The title is: \"" + title + "\"" +print +# An index of -1 refers to the first element from the end. Thus, this +# comparison checks whether the current element is the last one. +# Practice: Why would we want that? +if site == sites[-1]: +raw_input("...press enter to finish..:") +else: +raw_input("...press enter key to continue...") +print ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Pippy example - multiplication table
This example neatly prints the multiplication table with dimensions the user entered. diff --git a/data/GSOC examples/multiplication table b/data/GSOC examples/multip new file mode 100644 index 000..4601f01 --- /dev/null +++ b/data/GSOC examples/multiplication table @@ -0,0 +1,69 @@ +import time +import os + +print "This will draw the multiplication table with dimensions of your choice." +print "Feel free to modify and drawing speed and other variables." + +# how many numbers per second? Default is 5. +drawing_speed = 5 + +# raw_input() will get whatever text you enter with your keyboard. +# int() will give an error if it can't turn that text into a number. +try: +print "How many numbers wide?" +x = int(raw_input()) + +print "How many numbers high? " +y = int(raw_input()) +# If there's an error in the "try:" block of code, the following will happen. +# The program will print an error message and quit. +except: +print "That is not a valid number." +sys.exit() + +# In case everything went well, the program didn't quit and is now here. +# The following will create two lists of numbers, each starting with 1 and +# ending with whatever you entered as x ("row" list) and y ("column" list). +# Practice: By default, both lists start with 1. What if we changed that? +row = range(1, x+1) +column = range(1, y+1) + +# From now on, everything we want to print on the screen we'll store +# in the "output" variable. First we make it an empty string, and then add to i +# whatever we want to print. +output = "" +# the first printed line, for decoration: +# add the beginning of it +output += "|---|--" +# for each number in a row, add eight dashes and mark the end of line with \n +# \n is called a 'newline' and it makes your console start writing a new line. +output += len(row) * "" +"\n" +# What the second line starts with. \t marks one tab. +output += "|\t|\t" + +# Now, we would like to print the first row of numbers, which +# represent the factors we'll multiply. Add each number from "row" +# to the output string. str(number) turns a number to characters +# (like number 42 to characters '4' and '2') +for number in row: +output += str(number) + "\t" + +# add another decorative line +output += "\n" + "|---|--" + len(row) * "" + "\n" + +# for each number in the first column, multiply it with each number in the +# first row. One by one, add the results to "output" and print it. +for factor1 in column: +output += "| " + str(factor1) + "\t|\t" +for factor2 in row: +output += str(factor1*factor2) + "\t" +# clear the screen from what was last printed (old output) so +# we can print the new output (with one result added) +os.system('clear') +print output +# Pause the program. If "drawing_speed" is 5, it will pause for +# 1/5 seconds (0.2 seconds), which gives us five characters +# per seconds. +time.sleep(1.0 / drawing_speed) +# mark the end of the line +output += "\n" ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Pippy example - file writing and reading
This example demonstrates some basic text file reading and writing. diff --git a/data/GSOC examples/file writing and reading b/data/GSOC examples/fi new file mode 100644 index 000..13b7436 --- /dev/null +++ b/data/GSOC examples/file writing and reading @@ -0,0 +1,41 @@ +import time + +print "This example demonstrates how to create a text file, write something to + +print "How shall we call the file?" +filename = raw_input() + +print "Where would you like to store the file? (can be left empty)" +# Practice: Where does the file get stored if we leave this empty? +directory = raw_input() + +full_name = directory + filename + +print "Please enter the text you would like to store." +text = raw_input() + +# Open the file in the "w"rite mode. +my_file = open(full_name, "w") + +# Let's write the current time to that file. +# \n is the way of saying "i'm finished with that line, move to the next one." +current_time = time.ctime() +my_file.write("The following text was written at: " + current_time + "\n") + +# Write our text to the open file. +my_file.write(text) +my_file.write("\n") + +# Close the file. +my_file.close() + +# Now lets read from that same file. This is how reading is done. +# First: Open the file in "r"ead mode. +my_file = open(full_name, "r") +# Second: Read from it. +from_file = my_file.read() +# Third: Close the file. +my_file.close() + +# Print what we've read. +print from_file ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Pippy example - birthday reminder
This example works as a birthday reminder. It demonstrates the use of dictionaries and several other things (like functions) already covered in the existing examples, but now put in a larger program. PS. I now notice I've pushed this code with "switch" in comments instead of "if-else", I'll change that. Dinko Galetic diff --git a/data/GSOC examples/birthday reminder b/data/GSOC examples/birthday new file mode 100644 index 000..eca9458 --- /dev/null +++ b/data/GSOC examples/birthday reminder @@ -0,0 +1,201 @@ +# The purpose of this example is to demonstrate what is a dictionary in Python. +# This will also cover: +# functions, +# switch, and +# writing to text files. + + +# This function adds a birthday to the list of birthdays. +# Simple, isn't it? +# There's one flaw, though: In case we've already stored the data for that +# person, it will overwrite that data. +def add_birthday(person, day, birthdays): +birthdays[person] = day + +# This does the same as the previous function, but checks if we already have +# the birthday of that person remembered and warns us in that case. +# Practice: This function is not used in this example, only defined. +# Could you change the code so that it is used instead of +# the default "add_birthday" function? +def add_birthday_safer(person, day, birthdays): +if birthdays.has_key(person): +print "You've already entered " + person + "'s birthday as:", +print birthdays[person] +print "Would you like to overwrite that with " + day + " (y/n)?" +response = raw_input("Response: ") +# Practice: Add some more possible answers (like with capital letters) +if response == "n" or response == "no": +# "return" marks the end of the function +return +else: +birthdays[person] = day + +# To change an existing record: just overwrite whatever was there before! +# It will simply add a new record if there wasn't a person with the given name, +# and that is fine. Because of that, we don't have to check if the record exist +def change_birthday(person, day, birthdays): +birthdays[person] = day + +# This function deletes a birthday. +def forget_birthday(person, birthdays): +if birthdays.has_key(person): +del birthdays[person] +else: +print "No such person." + +# This function check if it's anyone's birthday today. +def check_birthdays(birthdays): +# this will get us the today's date in the form ddmm, the same +# as we enter it. We don't need the year, most people have birthdays +# each year. :) +# Practice: Who doesn't? +today = time.strftime("%d%m") + +none_today = True + +for person in birthdays: +bday = birthdays[person] +# How do we know which birthday is it? +# Easy: current year - birth year. +# time.strftime("%Y") gets us the current year, and the birth year +# is written in "bday" variable, from 4th index to the last. +# Since both are written as strings, we have to turn them to numbers +# before we can subtract them, and we do that by passing them to the in +# function. When they are subtracted, turn the result back into a strin +# by passing it to the str() function. +which = str( int(time.strftime("%Y")) - int(bday[4:]) ) + +if bday[0:4] == today: +print "It's " + person + "'s " + which + ". birthday, yay!" +none_today = False + +if none_today: +print "No birthdays today." + +# Practice: Could we make the output of this function nicer? +# For example, change it to the form of dd.mm. instead of ddmmyyy ? +def print_birthdays(birthdays): +for person, day in birthdays.items(): +print person + " was born on " + day + "." +if len(birthdays.items()) == 0: +print "There are no birthdays memorised." + +# This function takes a name and finds that person's birthday. +def find_birthday(name, birthdays): +if birthdays.has_key(name): +print name + "'s birthday is on: " + birthdays[name] +else: +print "You never entered " + name + "'s birthday!" + + +def save_to_file(filename, bdays): +# Warning: If there already exists a file with this name, opening it in "w" +# mode will delete the existing file and create a blank one! +# Opening in "a"ppend mode adds everything to the end of an existing file, +# but we won't use it here. +# Practice: Try writing a program which appends to text files to see how it +f = open(filename, "w") +# Practice: What does s
[Sugar-devel] Python tutorial for Pippy
Hello everyone, I'm currently working on a Python tutorial for Pippy as part of my GSOC project. I've written several lessons and am now wrapping them in Python code to make them interactive. I've attached a prototype of what I'm trying to accomplish and I'm hoping for your reviews (it's also available in my Pippy branch). I imagined the lessons being put in /data/tutorial/ and that they are accessed the same way Pippy examples are. Each such file would just have a few lines of comments to explain what the lesson is about and how to use it, and "import lesson, lesson.run() ". The lesson.py files would be in /library/pippy/tutorial/ or somewhere similar. Comments on ANY part of it would be greatly appreciated, even if it's just a suggestion to use a different variable name in the examples the learner will see, or to (no matter how slightly) modify the way something is explained. It's really important to teach programming as clearly as possible, IMO. Kind regards, Dinko Introduction Description: Binary data # TODO: options to quit, save progress and resume the tutorial. def run(): print """Hello there, and welcome to PyTutor. Before we continue, please tell me your name. You can type it in right here:""" answer = "no" while answer == "no".lowercase(): name = raw_input(">>> ") print "Your name is " + name + ". Did I get it right? You can answer \"yes\" or \"no\"." answer = raw_input(">>> ") while answer.lowercase() != "yes" and answer.lowercase() != "no": print "Please answer \"yes\" or \"no\"." answer = raw_input(">>> ") if answer.lowercase() == "no": print "Please enter your name again: " # TODO: Reading the whole text without guidance. print "Hello again, " + name + """. Before you is a set of lessons about computer programming, or just "programming" for short. I will present them to you and guide you through them. You can also read them yourself without my guidance. If at any time you wish to quit, just type in \"quit\". You can always resume the tutorial later by simply restarting it and introducing yourself again. To continue, just press enter.""" if raw_input(">>> ") == "quit": quit() print """So, the beginning. What is computer programming? In most cases, it is writing down a sequence of tasks that you want your computer to do, and that is what we will be doing. Fox example, you could tell your computer to make some calculations for you. Whenever you see ">>> " on the screen, that means that you can type. *(TODO: explain this differently)?* Try typing "print 10 + 3". """ exactly = True while True: user_input = raw_input(">>> ") if user_input == "quit": quit() elif user_input == "skip": print "Skipping this example, moving on..." break elif user_input == "print 10 + 3": print "13" break elif user_input[0:6] == "print ": exactly = False try: print eval(user_input[6:]) # This or the alternative? # exec(user_input) break except: print "That won't work. Try what I suggested." else: print "You don't have to use the numbers I asked you to, but you should start with \"print \"." print print "Press enter to continue." user_input = raw_input(">>> ") print "Good.", if exactly == False: print "That wasn't exactly what I asked you to type, but it works as well. It's good that you're trying your own examples!", print """Please - try some more! You can use any numbers and other mathematical operations (+, -, *, /, **, % ) as well. A few examples: "print 5 * 5", "print 30 / 3", "print 1 + 2 + 3 + 4 - 5". When you are done trying your calculations, simply type "done" and I will continue.""" user_input = raw_input(">>> ") while user_input != "done": if user_input == "quit": quit() elif user_input == "skip": print "Skipping this example, moving on..." break elif user_input[0:6] == "print ": try: print eval(user_input[6:]) except: print "That won't work. Try something else." else: print "You should start with \"print \" for now. We'll practice other things later." user_input = raw_input(">>> ") print print """Congratulations! If you have never done something like this before, you've just programmed for the first time and written your first short computer program.""" print """\nThere are many examples of programs available in Pippy. If you haven't already tried to run them, you can do that now - type "quit" and you can resume the tutorial later. Bear in mind that most of those programs consist of over a hundred lines of code (what we've tried so far had only one line) and
Re: [Sugar-devel] Python tutorial for Pippy
On Mon, Jun 28, 2010 at 3:47 PM, samir menon wrote: > I have been looking for something like this for quite a while. I am going > to try to teach my little brother, (about 10) , to learn programming, and > this seems like the perfect way to do it. You could not have picked better words to say to a teacher (though "here's a million dollars" would also be nice), so thank you. :) -I am on python 3.1, was this written in 2.6 or something? > Yes, that's right (2.6), it's not a Windows/Linux thing. If you're interested in teaching your brother Python 3.x, lowercase() got replaced with ascii_lowercase(), and "print something" now has to be "print(something)". Python 2.6 supports both "print x" and "print(x)", however I chose the former approach in my tutorial because it's a bit simpler and I can postpone explaining functions a bit. I plan to show that "print(x)" also works, but after the lesson on functions. > Other than that (by looking at your code) I see that this is an awesome > program! [?] > Glad to hear it. Stick around - I'll be posting the rest of my lessons when I get enough thumbs-up on this one. Kind regards, Dinko Galetic <<330.gif>>___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel