Students will be able to...
- Define and identify: return, None.
- Explain and demonstrate the difference between printing and returning.
- 3.3 Slide Deck
- Do Now
- Lab - War (Card Game) (docx) (pdf)
- Associated Reading
- Read through the do now, lesson, and lab so that you are familiar with the requirements and can assist students.
- Video Resources
Duration | Description |
---|---|
5 Minutes | Do Now |
10 Minutes | Lesson |
35 Minutes | Lab |
5 Minutes | Debrief |
Duration | Description |
---|---|
5 Minutes | Do Now |
40 Minutes | Lab |
5 Minutes | Debrief |
- Students experiment with a function that returns a value, but they must add a print command to output that value.
- Ask students about what they think the difference between returning and printing is.
- Get a volunteer to describe how they rewrote the code in the Do Now to get a value output.
- Ask a student to write the code on the board.
- Discuss the concept of the function contract again, explaining that the functions we will work with have both inputs and outputs.
- One student volunteer represents the
give_card
function. - This students holds the deck of cards and stands by the board.
- On the board display the
give_card
function in code that only prints the value of a randomly chosen card. - Students 'call' the student and request cards, which then the student follows the instructions and draws ('prints') the card on the board.
- Display a new
give_card
function that returns a card instead. - Have students 'call' the function, however this time have the
give_card
student pass out the card when a student calls him/her. - Debrief the activity and talk about what was learned.
- Given a shuffled deck list, students will create a program that plays the game 'War' with the user.
- Check student progress and completion of the lab, wrap up by taking any final questions.
The optional bonus functionality mentioned in the lab is to add the additional code to allow players to start a new 'War' game at the end of the current game. As an extension activity, ask students to research the shuffle function and the functions associated with it.