Title: Lesson 3: Statements and functions
Course: Basic scripting and programming > Section: Course Content

Become more familiar with the if-statement, the for-statement, and the function definition.

Objectives:

- Introduction to the flow of a program: conditions, forks and loops
- Introduction of the range function
- Introduction to the creation and the use of functions and “fruitful” functions (functions that return value)

Entrance requirements:

- Lesson 1 and 2

Required materials:

- Computer with Python
- The course book “Think Python”, chapter 3, 4, 5 and 6

Learning outcomes:

 At the end of this lesson the student:

- knows about functions and functions calls
- knows about type-conversion functions
- knows about importing and using mathematical functions
- knows how to define functions
- is aware of the flow of execution
- knows about parameters and arguments of functions
- knows what local and global variables are
- knows about the for-statement
- knows about the modulus operator
- knows about Boolean expressions, logical operators and if-statements
- knows about the else-clause of if-statements and how to chain conditions
- knows about return values of functions
- knows about incremental software development
- knows how to compose statements and expressions
- knows about Boolean functions
- and is able to apply all of the above

Learning activities:

- Read sections 3.1 to 3.9 (functions)
- Read section 4.2 (for-statement, range)
- Read 5.1 to 5.7 (if-statement)
- Read sections 6.1 to 6.4 (fruitful functions)

Tasks:

Do the following exercises:

- Exercises 3.1 to 3.3
- Use the for-statement and the range function to print the following table:
0 0
1 1
2 4
…
9 81
10 100
- Exercises 5.1 to 5.3

Optionally, you can try to do the complete chapter 4.
The remainder of the chapters 5 and 6 will be treated in lesson 4!

SUBMIT all your answers in a PDF document!

Planned time frame for this lesson:

5 hours