Starter – Homework What were our findings?. Computer Science 3.1.1 Constants_variables and data types 2.

Slides:



Advertisements
Similar presentations
Outline lecture Revise arrays Entering into an array
Advertisements

CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 8 Arrays.
Arrays. A group of data with same type stored under one variable. It is assumed that elements in that group are ordered in series. In C# language arrays.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
CS107 Introduction to Computer Science Lecture 5, 6 An Introduction to Algorithms: List variables.
Programming Logic and Design Fourth Edition, Comprehensive
CS 106 Introduction to Computer Science I 02 / 19 / 2007 Instructor: Michael Eckmann.
Strings. Sentences in English are implemented as strings in the C language. Computations involving strings are very common. E.g. – Is string_1 the same.
Revision – Data types Design a database structure for a class. This database needs to contain information about their name, exam marks, DOB, exam grades,
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
Lists in Python.
Handling Lists F. Duveau 16/12/11 Chapter 9.2. Objectives of the session: Tools: Everything will be done with the Python interpreter in the Terminal Learning.
chap8 Chapter 8 Arrays (Hanly) chap8 2 Data Structure Simple data types use a simple memory to store a variable. Data Structure: a.
Week 7. Lecture 2 Functions, Arrays, PHP&MySQL. Function with More than one argument and a return statement For a function to return a value, the return.
1 DATA STRUCTURES: LISTS. 2 LISTS ARE USED TO WORK WITH A GROUP OF VALUES IN AN ORGANIZED MANNER. A SERIES OF MEMORY LOCATIONS CAN BE DIRECTLY REFERENCED.
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
Computer Science – Truth Jam Table JamBreadSandwich Yes No YesNo YesNo TeaMilkDrink No Yes NoYes NoYes What am I getting at?
Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Built-in Data Structures in Python An Introduction.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
Advanced Computer Science Lesson 4: Reviewing Loops and Arrays Reading User Input.
Chapter 8 Arrays Instructor: Kun-Mao Chao ( 台大資工 趙坤茂 )
Arrays and Collections Tonga Institute of Higher Education.
Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.
Lists CS303E: Elements of Computers and Programming.
Using Lists Games Programming in Scratch. Games Programming in Scratch Extension – Using Lists Learning Objectives Create a temporary data store (list)
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
ArrayList is a class that implements the List interface. The List interface is a blueprint for its “implementor” classes. There is another implementor.
CHAPTER EIGHT ARRAYS © Prepared By: Razif Razali1.
Python Programing: An Introduction to Computer Science
Starter – Its the small things in life What’s wrong with this code Height = 10 Width = 10 A = Height * Width Print A Remember to check: Spelling Spacing.
Computer Science 101 Python Lists. Literals, Assignment, Comparisons, Concatenation Similar to the behavior of strings so far a = [1, 2, 3] b = range(1,
Lists in Python List methods and functions. List methods MethodSemantics list.append(x)Adds x to the right end of list, changes original list list.sort()Sorts.
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
Lists and Matrices Lists: Variable-Size Arrays Matrices: Arrays of Arrays (Tables) SoftUni Team Technical Trainers Software University
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.
Lists/Dictionaries. What we are covering Data structure basics Lists Dictionaries Json.
ITEC 109 Lecture 21 More on lists. Lists Review Lists –How do you create? –How do you add? –Sum / Average?
Common Elementary Algorithms Some of the basic but frequently used algorithms for manipulating arrays. These algorithms are so important that: a)Some programming.
Lecture 10 Collections Richard Gesick.
Chapter 6: Using Arrays.
Outline lecture Revise arrays Entering into an array
Microsoft Visual Basic 2005: Reloaded Second Edition
Arrays: Checkboxes and Textareas
Containers and Lists CIS 40 – Introduction to Programming in Python
Class06 Arrays MIS 3502 Jeremy Shafer Department of MIS
Data Structures: Lists
Lecture 10 Data Collections
Arrays MIS 3502 Jeremy Shafer Department of MIS Fox School of Business
Creation, Traversal, Insertion and Removal
LESSON 13 – INTRO TO ARRAYS
Data Structures – 1D Lists
ARRAYS 1 GCSE COMPUTER SCIENCE.
Chapter 5: Lists and Dictionaries
Remembering lists of values lists
Just Basic Lessons Mr. Kalmes.
Topics Sequences Introduction to Lists List Slicing
Python Lists.
Topics Sequences Lists Copying Lists Processing Lists
Introduction to Programming with Python
Review of Previous Lesson
Fundaments of Game Design
Topics Sequences Introduction to Lists List Slicing
Just Basic Lessons Mr. Kalmes.
Arrays & Loops.
Arrays & Loops.
COMPUTER SCIENCE PRESENTATION.
Introduction to Computer Science
Presentation transcript:

Starter – Homework What were our findings?

Computer Science Constants_variables and data types 2

Success Criteria You need to be able to explain the function of a one and two dimensional array You need to be able to create an array using a programming language. You need to be able search / amend and manipulate arrays.

Arrays - intro Arrays are a very common data type in computer programs. It allows you to handle data in single lists or double column lists. In Python they are called: Lists.

Arrays - intro It is a common requirement to hold related data as one item. -Could be students in a class -Could be cars within a range

Quick activity

An array: lets start with a one dimensional array(list). Here is an example: Lets assign a value to ‘Car manufacturer’ Car_manufacturer = “Ford” What about the other manufacturers?

An array: lets start with a one dimensional array(list). Car_man = (“Ford”, “Nissan”, “Citroen”)

NOTE!

An array: lets start with a one dimensional array(list). Car_man = (“Ford”, “Citroen”, “Nissan”) The manufacturers are now indexed. Data itemFordCitroenNissanSkodaKiaPeugeot Index012345

An array: lets start with a one dimensional array(list). The manufacturers are now indexed. Data itemFordCitroenNissanSkodaKiaPeugeot Index If I want to use the index Car_maker = Car_man[1] Print Car_maker

An array: lets start with a one dimensional array(list). TASK – Now go away and create me a one dimensional list (array)

An array: lets start with a one dimensional array(list). Extension: sampleList = [1,2,3,4,5,6,7,8] for b in sampleList: print (b)

An array: lets start with a one dimensional array(list)..append(value) - appends element to end of the list.count('x') - counts the number of occurrences of 'x' in the list.index('x') - returns the index of 'x' in the list.insert('y','x') - inserts 'x' at location 'y'.pop() - returns last element then removes it from the list.remove('x') - finds and removes first 'x' from list.reverse() - reverses the elements in the list.sort() - sorts the list alphabetically in ascending order, or numerical in ascending order e.g Array = [1,2,3,4,5,6,7,8] Print Array.pop

An array: lets start with a one dimensional array(list). Extension: These are very important pieces of programming Can you manipulate the list using the previous code? Can you manipulate the list based on numbers input by the user? Can you combine codes to create different results? e.g Array = [1,2,3,4,5,6,7,8] Print Array.pop

Manipulating lists sampleList = [1,2,3,4,5,6,7,8] user_in = input("enter an number between ") sampleList.pop(user_in) print sampleList sampleList.insert(1,5) print sampleList print sampleList.reverse() print sampleList

Computer Science Constants_variables and data types 2

Success Criteria You need to be able to explain the function of a one and two dimensional array You need to be able to create an array using a programming language. You need to be able search / amend and manipulate arrays.

Arrays (lists) can also be 2 dimensional ABCD 1EFGH 2IJKL 3MNOP 4QRST

Here is an example of an array you see and use all the time

0123 0ABCD 1EFGH 2IJKL 3MNOP 4QRST 5UVWX 6Y_.!

DIscussion: So, what’s the point: How can multi-dimensional array be used in this game? What are the programming implications behind this board?

Construct a multidimensional array Create

List task – can you: 1.Start with bag = [] 2.Can you append items in the bag 3.Can you work out how many items in the bag? 4.Can you return a statement – “There are “ “items in the bag” “These include – list items” input("\n\nPress enter to continue.")

List task – can you: 1.Can you create a list based on the numbers input by the user? 2.Can you count the list and feedback information from it?

Homework Show me evidence: What is a list / array used for? Evidence that you can create a list / array Evidence that you can write code to manipulate* a list / array *search, index, add, append, change, print etc etc.