We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byElvin Keach
Modified about 1 year ago
© Jalal Kawash Programming Peeking into Computer Science 1
© Jalal Kawash 2010Peeking into Computer Science Reading Assignment Mandatory: Chapter 5 – Section 5.5 Jalal’s resources: ◦“How to” movies and example programs available at: JT’s resources: ◦www.cpsc.ucalgary.ca/~tamj/203/extras/alice 2
© Jalal Kawash 2010Peeking into Computer Science JT’s Extra: What Is A List? A list is a variable that can be treated as one entity. …but also a list consists of elements and the individual elements can be accessed separately. 3 Example: I need to print out the whole class list Example: I need to fix this one student’s grade
© Jalal Kawash 2010Peeking into Computer Science Objectives At the end of this section, you will be able to: 1. Understand the list structure 2. Create lists in Alice 3. Apply the for all in order construct to lists 4. Apply the for all together construct to lists 5. Use functions to collect user input
© Jalal Kawash 2010Peeking into Computer Science A list of Astronauts in Alice 5
© Jalal Kawash 2010Peeking into Computer Science Lists A list is a tuple of numbered (indexed) objects A list is a variable John 0 Frank 1 Alicia 2 Jenn 3 James 4
© Jalal Kawash 2010Peeking into Computer Science Creating a List in Alice 7
© Jalal Kawash 2010Peeking into Computer Science JT’s Extra: What If A List Weren’t Used? 8 Example 12: ‘How not to’ approach March 3 soldiers forward Without lists: you would create three soldier objects The actions for each list would have to be repeated three times (once per object) A list would allow the soldiers to be grouped together and instructions wouldn’t have to be repeated explicitly
© Jalal Kawash 2010Peeking into Computer Science JT’s Extra: For all in order and together 9 FOR ALL IN ORDER Each list element carries out instructions one element-at-a-time FOR ALL TOGETHER The instructions are performed at the same time by each list element
© Jalal Kawash 2010Peeking into Computer Science JT’s Extra: March Example (Soldiers Again) 10 Example 13: Lists, for all in order, for all together For all in order: body of loop repeats three actions for each list element (soldier) one at-a-time For all together: body of loop repeats three actions for each list element (soldier) simultaneously
© Jalal Kawash 2010Peeking into Computer Science JT: For all INORDER Flowchart 11 i = 0 Start While i < size- of list falsetrue Stop for-all-body Increment I by 1 For all INORDER list JT: for-all-body action(s) to perform, each element list[i] Play sound Each soldier ‘say’ Each soldier moves
© Jalal Kawash 2010Peeking into Computer Science JT’s: For all TOGETHER 12 Start if List is empty true false Stop for-all- body(list) Ffor-all- body(list[n-1])... For all TOGETHER list for-all-body (JT: each simultaneous action) JT’s Extra: perform same action on each list element at same time Example program Play sound Each soldier ‘say’ Each soldier moves
© Jalal Kawash 2010Peeking into Computer Science More Complex Example 13
© Jalal Kawash 2010Peeking into Computer Science world.dance Method 14
© Jalal Kawash 2010Peeking into Computer Science world.dance Method 15
© Jalal Kawash 2010Peeking into Computer Science For all INORDER 16 i = 0 Start While i < size- of list falsetrue Stop for-all- body(list[i]) Increment I by 1 For all INORDER list for-all-body
© Jalal Kawash 2010Peeking into Computer Science For all TOGETHER 17 Start if List is empty true false Stop for-all- body(list) Ffor-all- body(list[n-1])... For all TOGETHER list for-all-body
© Jalal Kawash 2010Peeking into Computer Science For all in Flowcharts 18 Loop rounds times Start Stop x turns backward x turns forward x moves up x rolls left x moves down For all x in spaceTeam INORDER For all x in spaceTeam TOGETHER
© Jalal Kawash 2010Peeking into Computer Science Collecting User Input 19
CS0007: Introduction to Computer Programming The for Loop, Accumulator Variables, Seninel Values, and The Random Class.
Java ArrayLists Why not just use Arrays?. shrink when you remove somethin g. Tell you if it contains what youre looking for instead of looping through.
Flow of Control Chapter 3. Objectives learn about Java branching statements learn about loops learn about the type boolean (optional) learn to use color.
Introduction to Macromedia Director 8.5 – Lingo. Scripting basics Behaviors – Scripts attached to sprites or frames in the Score, referred to as a sprite.
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Computer Science 110. By the end of this unit, you should be able to: Define the term iteration. Use an input box in an application. Write a Do...Loop.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
DE Science Elementary 5-Minute Prep For Human Body Systems of the Body Muscular System.
Lecture 10 Flow of Control: Loops (Part 2) COMP1681 / SE15 Introduction to Programming.
HOW TO USE POWERPOINT By Bryan Kreps. Slide Thumbnails Task Pane Tool Bars Different Views/Play Show.
Container Types in Python. Container Types We’ve talked about integers, floats, and strings… Containers are other built-in data types in Python. –Can.
Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time.
Copyright © 2003 Pearson Education, Inc. Slide 1.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 25 Lists, Stacks, Queues,
AliceWhileLoop1 While Loop in Alice Stephen Cooper Wanda Dann Randy Pausch Barb Ericson Oct 2009.
Linked Lists. Please Read These slides are provided for the use of students enrolled in James Durbanos Data Structures class (CISC 220). They are the.
Don't Panic! Group Challenge. Don't Panic! Group Introduction.
1 l Basics of Recursion l Programming with Recursion Recursion.
Time for Scheduling Scheduling Using the Student Portal in Infinite Campus.
Chapter 5, Slide 1Starting Out with Visual Basic 3 rd Edition Chapter 5 Lists, Loops, Validation, and More.
Unit 4 - I Said Stop!. Introduction New Topics Timing Parallelism Sequence of Operations New Features NXT terminals New Functions Wait For.
1 Arrays, Strings and Collections  Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software Engineering.
Chapter 8: Arrays. Introduction to Arrays Primitive variables are designed to hold only one value at a time. Arrays allow us to create a collection.
Unit 5 Same Song, Second Verse Programming Loops Introduction to C Programming.
More on Psuedo-Code Sangeetha Parthasarathy 1/23/01.
1 Register Allocation Consists of two parts: register allocation What will be stored in registers Only unambiguous values register assignment Which register.
A Third Look At ML 1. Outline More pattern matching Function values and anonymous functions Higher-order functions and currying Predefined higher-order.
GRADE 1 Curriculum Work Group. Agenda Present the pacing calendar Unit 1 Review unit plan document Work groups Essential Resource List for Grade 1.
Adding User Interactions actionscript 3.0. Common event-handling tasks Writing code to respond to events Stopping code from responding to events Working.
SimpleGameInAlice1 Barb Ericson Georgia Institute of Technology June 2008 Creating a Simple Game in Alice.
© 2016 SlidePlayer.com Inc. All rights reserved.