User:Sdudah/python
Goals
- Learn how to program the computer
- Be a free opensource community member
Objectives
- 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)
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
IF statement (2m)
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)
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) (2m)
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

Essential components of a basic flowchart (1m)
START | END | ENTER | PROCESS | DECISION | |
---|---|---|---|---|---|
start | end | enter | process | decision |
Example of a flowchart (1m)
If you heard of flowcharting, why would you use a flowchart for?
- you do not need a programming language to "write down" a program. You visually write a program.
- Helps you get the big picture.
- 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).
Flowchart exercise: Make a simple flow chart to/for
Questions
- Write three computer programming languages you know or heard of?
Ex: C, C++, Java, Python
- With the goal of promoting free opensource community, what would you (currently) do to learn a new programming language?
Possible answers:
- Free opensource OS, Linux (recommended)
- Free Book/Tutorials. Ex:Wikibooks project),
- Free opensource compiler Ex: www.python.org
- Free opensource editor. Ex: Emacs, Eclipse, etc
- Programming language Newsgroup/Language-specific Mailing list. Ex: comp.lang.python
- Participate in a community project. Ex: coding. Others (documentation, report bugs, donate,promote).
- Programming contest (if you have previous programming experience) Ex: Google summer code contest.Get hired?
Feedback
(you can submit answers to the follwoing 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 exmaples 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:
- Course Slides
- Examples, past projects
- Assignments/Projects
- Useful links: http://programming-crash-course.com/