Learn Python through Examples

Learn Programming through Examples

Audience

1. Non programmers or programmers with no practical experience
2. Faculty members from various disciplines (mostly non computer science)

Course Objectives:

1. Introductory level Python programming
2. Teach concepts through examples
3. Make them comfortable writing small 5-20 line programs within the first day
4. Make programming fun and engaging
5. Demystify programming (take the fear out of it)

How we plan to teach

1. The instructor will start with a single line of code and gradually build programs
2. Participants will follow along
3. After half an hour participants will get a list of exercises to work on based on the
examples covered

Session-1: Code along session

1. hello world – first program
2. hello you – a greeting based on your name – input
3. Draw a line – a one line graphical program
4. Draw a square – a sequence of instructions
5. Draw a square with loops – teaches variables, control flow and repetition
6. Draw a square function – shows how to create a function
7. Draw a triangle
8. Convert square function to a function to draw a polygon
9. Draw multiple polygons of same shape
10. Draw multiple polygons of different shapes

Session-1: Practice and Exercises

1. Draw a house
2. Draw a scene
3. Draw an arbitrary shape
Session-2: Code along session
11. convert_temp – convert centigrade to Fahrenheit and reverse
12. convert_units – a generic version of temperature converter for any units. Teaches
integers, floating points, function definition, and invocation
13. sum_of_n – the sum of n numbers. Teaches while loop
14. sum_of_range – the sum of a given range of numbers – for loop
15. random_integers – generates a set of random integers – teaching random module and
randint function
16. stats1 – given a set of random numbers calculate minimum, maximum, sum, average
(also teaches lists)

Session-2: Practice/Exercises

1. Use random number generator to draw shapes
2. Random shapes, sizes, locations
3. Do these objects collide? A simple collision detection program
4. Animations

Session-3: Strings and Things

1. find – find a substring in a string
2. find2 – find a substring using a different function – index
3. lookup – a list to look up numbers and convert them to strings
4. lookup – introduction to dictionaries (a faster way to lookup)
5. words2nums – convert a string describing an amount to its numerical equivalent
6. string2words – splitting a string into words
7. wordfrequecy – calculating the frequency of words given some text
8. histogram – using wordfrequency function print a histogram of words
9. duplicates – removing duplicate words in a string
10. A drawing bot – A simple command based drawing program

Session-3: Practice/ Exercises

1. Drawbot-2: Expand the drawing bot to include more shapes

Session-4: Data Types

1. Lists – List operations
2. List of Lists – Nested lists
3. Sets – various set operations on lists
4. Dictionaries – Various uses of dictionaries
5. Converting lists to dictionaries and vice versa
Session-4: Practice/Exercises

1. DrawBot 3: Rewrite DrawBot-2 to use lists and dictionaries

Wrap Up

1. Idea Storming session on useful mini-projects to work on till the next workshop
2. How to build a useful Micro Application