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.
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
3) in controller default write
def hello: return "hello "+request.vars.name
and call it with: http://127.0.0.1:8000/Test/default/hello?name=Massimo
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: http://127.0.0.1:8000/Test/default/hello?a=3?b=6
Lesson learned: when you call a function a function you can pass parameters as input
5) in controller default write
def hello:
if request.vars.name: return "hello "+request.vars.name
else: return "hello whoever you are"
Lesson learned: if...else
work in progress...