Learning Computer Programming Lesson Plan


Goals

edit
  • Learn how to program the computer
  • Be a free-opensource community member

Objectives

edit
  • Learn some basic programming concepts and constructs: Variables, If, For and Functions
  • Learn what a flowchart is
  • How to make a flowchart for writing programs

Variables (1m)

edit

What is a variable?
x, university, car

Assignment NOT equality
x=5.2, university="Queen's"

Drill (1m)

Think of other examples of variables? z, first-name, school, person 
x=3+7 ?
count=4 
x=2+count ? 
x=2
y=x+8 ? 
x=x+3 ?


Flow Control

edit

IF statement (2m)

edit

What makes computers look intelligent?

Simple check

age=20
IF (age < 18)
   Print "Sorry, you are still young"

More intelligence

age=20

IF(age < 18)
    Print "Sorry, you are still young"
ELSE
    Print "You can drive a car"

Looping: For statement (1m)

edit

Execute commands many times

'What does the next statement do?'

FOR i=1  TO   i=100   DO
    Print "I want to drive a car"

Functions (divide and conquer) (3m)

edit

What is a function?
A subprogram (sub-code). Think of it as a small program you want it to solves you small problems.

output value = FUNCTION( input parameters)

How does it work?

  • call it and give it "orders"
  • it processes, cooks, crunches... (in a bit of time)
  • Gives you the stuff back
 height= sin(30)
 height= height * 10
 Print "The height of the building is "  height

What are advantages of functions?

  • Some functions are ready for you to use (sin, cos, time, print)
  • Make large programs easier ( user defined functions )
  • Team work (several programmers work on different parts of a project)
  • debugging (easier to debug and fix)

FLOWCHART

edit

Essential components of a basic flowchart (1m)

START END ENTER PRINT PROCESS DECISION
File:Termination.PNG File:Termination.PNG        


Example of a flowchart (3m)

 


Advantages of flowcharting? (2m)

  • You do not need a programming language to "write down" a program. You visually write a program.
  • You can add details any time later.
  • Visually, understand the problem better. You can spot missing points.
  • Translate the flowchart into a program (think of pseudo-code).
  • Translate the flowchart into any programming language (abstraction).

Example of a flowchart (3m)  

Flowchart exercise (10m) Make a simple flowchart to/for

Questions

edit
  1. Write a flowchart of buying a bottle of water from a vending machine?
  2. Write a flow chart of a program to compute a factorial of a number?
  3. Write the program in a programming language, e.g. Python?


  • With the goal of promoting free opensource community, what would you (currently) do to learn a new programming language?
    • Use a free opensource OS, Linux (recommended)
    • Use free Book/Tutorials. Ex:Wikibooks project),
    • Use a free opensource compiler Ex: www.python.org
    • Use a free opensource editor. Ex: Emacs, Eclipse, etc
    • Subscribe to a programming language Newsgroup/Language-specific Mailing list. Ex: comp.lang.python
    • Participate in a community project. Ex: coding. Others (documentation, report bugs, donate,promote).
    • Participate in a programming contest (if you have previous programming experience) Ex: Google summer code contest.Get hired?

Feedback

edit

(you can submit answers to the following questions electronically on the course website with the case-sensitive password:I.lovE.PyThOn)

  • What did you like to know more about that was covered today?
  • What is it that you felt was not clear today? be specific and give examples where possible?
  • Is there something that you wish be covered?
  • From a scale of 1-5, how would you rate the lab session?
  • Comments: any positive criticism that would help make future lab sessions better?

Resources:

edit