Some of the information here may be outdated, please check the book instead

We use to teach introductory programming courses by covering in the order loops, conditionals, function calls and classes. networking and web development are considered advanced topics. Here I am proposing an alternate model based on the fact that students already have familiarity with the user interface of web applications, their workflow, and the basic networking concepts associated to the internet. Moreover I believe that MVC is more important than OOP.

Lesson 1: Function calls

1) download web2py, start it, create an app called Test

2) in controller default write

def hello: return "hello world"

Lesson learned: when you visit a US a function is called, the function produces an output

Lesson 2: Parameter passing

3) in controller default write

def hello: return "hello "

and call it with:

4) in controller default write

def add(a,b): return a+b
def hello: return "hello a+b="+str(add(request.vars.a,request.vars.b))

and call it with:

Lesson learned: when you call a function a function you can pass parameters as input

Lesson 3: Conditionals

5) in controller default write

def hello:
   if return "hello "
   else: return "hello whoever you are"

Lesson learned: if...else

work in progress...

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.