Starter You have been asked to write a program to store the names of everybody in a class. Assuming there are 20 pupils in the class, how would you do.

Slides:



Advertisements
Similar presentations
Computer Science 101 Lists in Python. The need for lists Often we need many different variables that play a similar role in the program Often we need.
Advertisements

Arrays. Topics Tables of Data Arrays – Single Dimensional Parsing a String into Multiple Tokens Arrays - Multi-dimensional.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C.
Lecture 23 – Python dictionaries 1 COMPSCI 101 Principles of Programming.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
Computer Science 101 Lists in Python. The need for lists Often we need many different variables that play a similar role in the program Often we need.
Arrays. Introduction This chapter serves as an introduction to the important topic of data structures. Arrays are data structures consisting of related.
Two dimensional arrays in Java Computer Science 3 Gerb Objective: Use matrices in Java.
Python Arrays. An array is a variable that stores a collection of things, like a list. For example a list of peoples names. We can access the different.
C Programming – Part 3 Arrays and Strings.  Collection of variables of the same type  Individual array elements are identified by an integer index 
CSCI 161 Lecture 14 Martin van Bommel. New Structure Recall “average.cpp” program –Read in a list of numbers –Count them and sum them up –Calculate the.
For Friday Read No quiz Program 6 due. Program 6 Any questions?
Magic 8 ball. "Design and write a python program that emulates a Magic Eight Ball. Your program should continually prompt the user to enter a question.
Python For Kids – Week 2 Subtitle. Variables  A variable is a container in which a data value can be stored within the computer’s memory  The data can.
Arrays.
Two-Dimensional Arrays
Arrays Low level collections.
More on Lists.
Arrays (in Small Basic)
Array An “average.cpp” program
Chapter 8 Arrays Objectives
Chapter-7 part3 Arrays Two-Dimensional Arrays The ArrayList Class.
Arrays … The Sequel Applications and Extensions
Creation, Traversal, Insertion and Removal
Introduction to Matrices
Chapter 8 Arrays Objectives
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Arrays November 8, 2017.
Data Structures – 1D Lists
ArrayLists.
Introduction To Programming Information Technology , 1’st Semester
ARRAYS 1 GCSE COMPUTER SCIENCE.
Mini Python Project Lesson 3.
Multidimensional Arrays
Javascript Arrays.
Chapter 11 Data Structures.
Topics discussed in this section:
Programming We have seen various examples of programming languages
Starter As the teacher is calling out the register think about what sort of program you would write to duplicate the process that the teacher has just.
Just Basic Lessons Mr. Kalmes.
Arrays ICS2O.
MSIS 655 Advanced Business Applications Programming
Array Creation ENGR 1181 MATLAB 02.
How many objects can you create by drawing in the circles?
Programming Control Structures with JavaScript Part 2
Arrays I Handling lists of data.
Arrays ICS2O.
Multi-Dimensional Arrays
Dr Tripty Singh Arrays.
Python Lists.
Chapter 8 Arrays Objectives
Programming In Lesson 4.
Java SE 7 One and Multi Dimensional Arrays Module 6
Learning Intention I will learn how to use an array to store data in a program.
Dr. Sampath Jayarathna Cal Poly Pomona
Arrays.
And now for something completely different . . .
Expand Brackets Low C C B
Just Basic Lessons Mr. Kalmes.
C++ Array 1.
Arrays & Loops.
Introduction to Dictionaries
Arrays & Loops.
Python List.
Lists basics A container is a construct used to group related values together and contains references to other objects instead of data. A list is a container.
What about −(−6) ? What quantity is in the box?.
Tuple.
Presentation transcript:

Starter You have been asked to write a program to store the names of everybody in a class. Assuming there are 20 pupils in the class, how would you do this?

Lists & Arrays Python

Objectives 2.3.2 Understand the need for and be able to select and use data structures one-dimensional arrays two-dimensional arrays

What are Arrays? If we think of variables as a box. Arrays are a collection of boxes. Array - list of homogeneous items Each “box” has an address starting at 0. We call the address it’s INDEX [0] ‘Alf’ [1] ‘Betsy’ [2] ‘Charlie’ [3] ‘David’

Printing Lists Individual elements may be printed by using the name of the list and then the index of the element you wish to print in square [] brackets. Think: What programming construct could you use to print out every element in a list?

Activity 1. Complete Activity 1 the VLE.

More than one dimension? We were working with 1 Dimensional Arrays. These are effectively lists. What about if we had lists….of lists??? [0] [1] [2] [3] [4] What Value is at Scores[1][2]? Jimmy 12 15 17 19 Joanna 9 16 18 20 Jess 5 6 7 John 4 [0] 16 [1] [2] [3]

Activity 1. Complete Activity 2 the VLE.

To store related information Week 2 - Recap What is the purpose of a list? How do you create a list? Add an element? Remove a element? To store related information scores = [35, 62, 98, 54, 21] scores.append(71) scores.pop(2) Teacher note: Random numbers

Plenary If variables are like boxes, what are lists? What methods can we use to add and remove elements to/from a list? What is a list element?