Presentation is loading. Please wait.

Presentation is loading. Please wait.

How many objects can you create by drawing in the circles?

Similar presentations


Presentation on theme: "How many objects can you create by drawing in the circles?"— Presentation transcript:

1 How many objects can you create by drawing in the circles?
Learning Objectives Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Starter How many objects can you create by drawing in the circles?

2 Get Started! Learning Objectives
Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Get Started! Hand your sheet to the person next to you. Read out all of the items on your list (in order?) Did you remember them all? Were they in order? Which ones did you forget? Add a number [0],[1],[2]… each time your partner remembers an item correctly

3 Index Item Parrallel List
Learning Objectives Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Our Key Terms Index Array Item Parrallel List One Dimensional

4 What Is An Array? Array Learning Objectives Add this to your Glossary
Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context What Is An Array? Add this to your Glossary Array “A data structure, similar to a variable that can hold more than one value of the same data type.”

5 We’ve removed 4 variables and replaced them with one array
Learning Objectives Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Data Abstraction? Abstraction is the removal of unnecessary detail to make a problem easier to solve. How is an array an abstraction? Image1 = “cat” Image 2 = “dog” Image3 = “dinner” Image4 = “ball” OR Images = [“cat”, “dog”, “dinner”, “ball”] We’ve removed 4 variables and replaced them with one array

6 Design your array Learning Objectives
Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Design your array In pseudocode, we use square brackets to identify an array. Add each of your objects to an array of strings using pseudocode. Hint: myObjects = [ ] myObjects = [“cat”, “puppy”, “breakfast”, “ball” ]

7 Code your array Learning Objectives
Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Code your array In python, we still use square brackets to identify an array. Add each of your objects to an array of strings using python and output them individually.

8 Code your array Learning Objectives
Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Code your array In python, we still use square brackets to identify an array. Add each of your objects to an array of strings using c# and output them individually.

9 mins 5 2 1 6 10 10 9 8 3 4 7 Get Programming! Learning Objectives
Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Get Programming! Now you designed your items and have seen how an array can be created, create your own array of programming terms. Add as many terms to your array as possible! How will you output your array? One by one, or at random? Comment your code to explain your choice 5 2 1 6 10 10 9 8 3 4 7 mins Time: 10 minutes total! (timer starts automatically)

10 The first item was overwritten, so the data was lost!
Learning Objectives Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Swapping Items Swapping items in an array is seen in sorting algorithms. What would the following code output? myObjects = [“cat”, “dog”, “dinner”, “ball”] myObjects[1] = myObjects[0] myObjects[0] = myObjects[1] OUTPUT myObjects The first item was overwritten, so the data was lost! [“cat”, “cat”, “dinner”, “ball”]

11 A temporary variable holds the item so they can be swapped
Learning Objectives Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Swapping Items Swapping items in an array is seen in sorting algorithms. How could we fix this? myObjects = [“cat”, “dog”, “dinner”, “ball”] myObjects[1] = myObjects[0] myObjects[0] = myObjects[1] OUTPUT myObjects temp = myObjects[0] myObjects[0] = myObjects[1] myObjects[1] = temp A temporary variable holds the item so they can be swapped

12 mins 5 2 1 6 10 10 9 8 3 4 7 Get Programming! Learning Objectives
Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Get Programming! Change your program to include the option for the user to swap the current term with the next term in the list. What will you do if the item is the last in the list? How will test if the items have been swapped? Comment your code to explain your choice 5 2 1 6 10 10 9 8 3 4 7 mins Time: 10 minutes total! (timer starts automatically)

13 mins 5 2 1 6 10 10 9 8 3 4 7 Arrays in Real Life Learning Objectives
Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Arrays in Real Life Investigate different places where you may need to store related data in a list. In pairs, make a list of as many places where this might be useful and the reasons why an array may or may not be appropriate. Array: “A data structure, similar to a variable that can hold more than one value of the same data type.” 5 2 1 6 10 10 9 8 3 4 7 mins Time: 10 minutes total! (timer starts automatically)

14 Learning Objectives Explain how multiple data items are stored in an array Design algorithms to write to and read data from an array Explain the use of different types of array dependent on context Homework Download and complete the Arrays revision placemat. Remember your notes should use: Well presented full sentences with Point, Explain, Example


Download ppt "How many objects can you create by drawing in the circles?"

Similar presentations


Ads by Google