4_resized-554x368.png

Python 101 - Lesson 4

11-13 yrs old

14-18 yrs old

Computer Science

Technology

ANIMALS ARE FRIENDS Lists and methods

13
avatar Submitted By: Minecraft Education

September 8, 2020

Skills

  • Creativity
  • Critical Thinking

Learning Objectives

  • Use lists to simplify solutions, generalizing computational problems instead of repeatedly using simple variables. 3A-AP-14
  • Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs. 2A-AP-13
  • Create clearly named variables that represent different data types and perform operations on their values. 2B-AP-11

Guiding Ideas

In this lesson the students will learn:

- the concept of lists.

- how to create lists.

- how to use methods with lists.

- how to modify and sort lists.

- zero-based numbering.

- how to use underscores when creating variable and list names.

- how to spawn mobs.

Tell the students that they need to help CodingMine with the development of their new software that is going to be used by an animal hospital. Veterinarians need help to easily identify and categorize animals, as well as prescribing different treatments and dietary requirements. The students will help in the development of this project by using lists.

 

 

Student Activities

Coding Concepts:

- Lists

- Zero-based numbering

- Methods

User Interface. In this lesson the students will:

- use the button Q on the keyboard to drop items that they are holding in the hot bar.

- see displayed world coordinates in the top left-hand corner.

Syntax / Operators:  Square brackets [ ], underscore_

Coding activities: (30 min)

1. Activity1: Animal categorizing

Explain to the students that the developer needs their help to make a list of animals and then spawn the different animals’ types in their correct pens, at predefined locations.

2. Activity 2: Dietary requirement

Explain to the students that the veterinarian needs their help to write some code that will control a food making machine to make food for three different dogs with diverse dietary requirements The first dog will need everything that is already in the list. The second dog will need additional vitamins and the third dog will need the beef removed from the list. Explain to the students that they will need to use two methods to manipulate the list of foods, append and pop. Tell the students that to give the dogs their food they will need to drop it in their bowls.

3. Activity 3: What is the cat's name?

Explain to the students that the data scientist needs their help to write a few pieces of code that will use the sort and reverse methods to make changes to a list of cat names that they will be given. The first code has to change the last cats name to shadow. The second code has to sort the cat names alphabetically. The third code has to reverse all of the cat names in the list. The students will then have to create an code to write out a specific cat name in the chat each time, by changing the positional value in the given say command. Then they will have to select that cat from the line-up.

Performance Expectations

Ask the students about the skills that they have learned during the lesson, to reinforce the concepts.

Q. What is a list?

A. A list is a collection of strings, numerical values, variables, mobs or items.

Q. What do we use instead of spaces when naming a list or variable?

A. Underscore.

Q. What syntax do you place around a list’s content?

A. Square brackets.

Q. What four methods can we use with lists?

A. Reverse, append, sort, pop.

Skills

  • Creativity
  • Critical Thinking