<!--
title: Unit 4 Lab: Troubleshooting
type: Lab
duration: "01:35"
creator: Susi Remondi
-->
## ![](https://s3.amazonaws.com/python-ga/images/GA_Cog_Medium_White_RGB.png)  {.separator}

<h1>Unit 4 Lab: Carefully Adding a Bit More Logic</h1>

<!--

## Overview
This lesson consists of a hands-on lab during which learners will independently create a working Python program. This lab builds on the previous lab, so starter code (which is the same solution code as the previous lab) is provided for them. You simply need to introduce the lab, make sure they have working starter code and that they can access the lab doc, and be available in case of questions. At the end, go over the solution (located in the `solution-code` folder).


## Learning Objectives
In this lesson, students will:
- Apply what they've learned in Unit 4 to create a working Python program.


## Duration
30 minutes

## Suggested Agenda

| Time | Activity |
| --- | --- |
| 0:00 - 0:05 | Welcome / Set-Up |
| 0:05 - 0:20 | Work Time |
| 0:20 - 1:30 | Q&A + Close |

## Before Class: Preparation
- Before class, complete the lab yourself to ensure you’re familiar with the solution, as well as the various challenges learners might encounter.
- Change the location of the starter code and lab directions.

## In Class: Materials
- Projector
- Internet connection
- Python 3
- Lab directions

-->

---

## Lesson Objectives

- Apply what you’ve learned in Unit 4 to create a working Python program.
- Wrap up Unit 4.
- Q&A and transition.


<aside class="notes">

**Talking Points:**

- Congratulate students on finishing unit 4!

</aside>

---

## You Do: Unit 4 Lab — Troubleshooting

Do you remember the last unit lab? You added structure to your movie app using dictionaries and classes.

In today's lab, you will add error-checking, string formatting, and a `while` loop (but not an infinite one!), slightly restructuring the code as you go.

**Open the [`unit-lab-4-directions`](unit-lab-4-directions.md) file to see the lab and its instructions. Follow the instructions there.**

- *If your solution to the last lab didn't quite work, there's working code provided in the [`starter-code`](starter-code/movie_app.py) folder. Copy that to your local folder and work from there.*

Try your best! Raise your hand if you really need help.


<aside class="notes">

20 MINUTES

**Teaching Tips:**

- Make sure you change the link or point out what PDF to look at, and check the starter code location.
- Make sure all students start with working code — they can get it from the `starter-code` file.
- The lab has instructions and an explanation in it for students to read. Make sure they're all opening the lab instructions OK.
- Stay on this slide until everyone's done or time's up!

**Talking Points:**

- Remember that, throughout the course, there's a lab at the end of each unit. Each lab builds upon the last.
- Does anyone need help with the starter code?
- Right now, let's set up the functions and control flow to print out the values of our variables.

</aside>

---

## Debrief: Unit 4 Lab — Troubleshooting

How did it go?

Let's go over it.

Make sure you understand and that your code works — the Unit 5 lab builds off this one!

<aside class="notes">

**Talking Points:**

- Bring up the solution (located in the `solution-code` directory) and walk students through it. Make sure everyone understands — and that everyone's code is accurate or they know that it isn't.
- The next lab builds off of this one but provides starter code if needed.

</aside>

---

## Unit 4 Wrap-Up

What did we cover?

* Variable scope: Using the global keyword to access global variables.
* The order of scope precedence that Python follows when resolving variable names.
* Creating floats and flooring division.
* Formatting strings.
* Troubleshooting common types of errors.
* Implement basic `try/except` mitigation.
* Adding `print` statements to help debugging.

Questions?

<aside class="notes">

5 minutes

**Teaching Tips:**
- Briefly review the high-level learning objectives for Unit 4.
- As you read each bullet aloud, ask students to give you a "fist to five." See **Talking Points** below.
- Observe student votes for each item and make a mental note to follow up with individuals who are not feeling confident, or find time to reteach topics with which the majority of the class is uncomfortable.
- Take time to go over questions (but remember the parking lot).

**Talking Points:**
- Wow, we've covered a lot! Let's take a minute to review what we've learned so far.
- I'm going to read through the topics for Unit 4. As I do so, I want you to tell me how confident you feel that you've mastered each one, on a scale of 0 to 5.
  * Hold up your fist to indicate 0 — you don't feel confident at all that you mastered this objective.
  * Hold up all five fingers to indicate 5 — you feel super confident. You're an expert!
</aside>
