## Chapter 4, Lesson 4 Teacher Guide URL Hidden from students

# Chapter Four: Making Decisions

## Teacher Notes - Lesson Four: More Complex Expressions

In this lesson, students will learn how to use parentheses ( and ) to guide the evaluation order of complex expressions. Without parentheses, expressions are evaluated in a default order based on internal Python rules, and that may not match your expected results. Use of parentheses makes code clearer to read for humans and specifies exactly how things should be executed by the computer.

### Lesson Objectives

- Demonstrate how evaluation order is unclear with no parentheses are used
- Learn how parentheses can be added clearly define the execution order of logical and mathematical expressions
- Review mathematical, comparison and logical operators
- Study example of complex expressions with parentheses

### Teaching

*Activity #1: Lesson Video*

Students may optionally view the lesson video, either individually or as a class. The lesson video will introduce and re-enforce the main lesson concepts.

*Activity #2: Lesson Text*

Students must read the lesson text. The lesson text contains full details about the specific topic and is required reading.

*Activity #3: Class Discussion*

In a class discussion, make sure your students understand the basic points of the lesson. They should be able to answer the following questions:

- What could go wrong if you write a lengthy expression with no additional guidance given to Python?
- How do you use parentheses help to clarify logical expressions and enforce certain execution orders?
- What is the difference between mathematical, conditional and logical operators, and when is each appropriate to use?
- Is it possible to mix different types of operators in the same expression?
- How do you break a long statement across multiple lines, if desired?

*Activity #4: Work with Me Exercise*

In this exercise, students will complete a "raffle" program that will examine input ticket numbers and declare a winning ticket based on a series of logical expressions. Students are expected to begin writing more of the programs on their own at this point, and they should be comfortable writing simple **if**/**else** logic and **print**() statements. Click on the "Solution" button on the code panel to see our solution code. It is not necessary to break a long statement across multiple lines, though we have demonstrated doing so. Students may come up with creative alternative solutions that produce the same results (e.g. a series of simple, nested "if" statements).

### Assessment

Today's lesson includes an online quiz that should be completed by your students. Please see your Professional Development links for instructions on giving quizzes.

End of Lesson