Students will be able to...
- Define and identify: interpreter, string, integer, float, value, errors, console, expression.
- Use the Python interpreter to evaluate simple math expressions.
- Distinguish between an integer, float, and string.
- 1.02 Slide deck
- Lab - Using the interpreter (docx) (pdf)
- Associated reading - section 1.1
- Ensure all students are able to log into the system.
- Go through the lab so that you are familiar with the requirements/results and can assist students.
Duration | Description |
---|---|
5 Minutes | Do Now |
10 Minutes | Lesson |
15 Minutes | Lab Part 1/Discussion |
20 Minutes | Lab Part 2/Discussion |
5 Minutes | Debrief |
- Display the IDE and asks students to identify the key parts (menu bar items [run, console, +], code panel, console panel).
- After going over the three parts of the IDE have students check that they can still log into their IDE account.
- Have students all bring up their console on their computer.
- The part on right half of the screen is called a console:
- The console is a place where you can interact with a program.
- The interpreter runs Python code.
- To run the Python interpreter, type code into the console and hit "Enter" or click "Run", the code executes immediately.
- Make sure all the students are able to do this and then give out the lab worksheet.
Give students time to work on section 1.
- What does the // do? How is that different from /? And how are those different from %?
- What's the difference between 3.0 and 3?
- Go over the following two terms:
- Floats: a data type, number with a decimal point.
- Integers: a data type, number without a decimal point.
- Now, give students time to work on section 2.
- What happened when you typed in a?
- What do you think that error message mean?
- Go over String: a data type, characters surrounded in single or double quotes.
- Now, give students time to work on section 3.
- What was the difference between the two inputs?
- Strings can be combined using
+
. - What do you think the error message means?
- You can't combine different types!
- Now, give students time to work on section 4.
- What error did you get? What do you think that means?
- What happens when you multiply strings?
- Define expression: a combination of values and operators (and variables)
- Ask students to give an example of an expression.
- Make sure students write down their predictions before going to the interpreter/IDE to check the actual output.
- Discuss any surprising/unexpected results.
- Remind students of adding strings together using
+
. - Talk about how single and double quotes are interchangeable.
- Multiplying strings.
- Order of Operations is the same as what students have learned in math class.
- Discuss why it might be helpful to have an interactive console.
If students are moving quickly, have students practice higher order-of-operations problems. You can also have them practice assigning values to variables.