© Jalal Kawash 2010 4 Programming Peeking into Computer Science 1.

Slides:



Advertisements
Similar presentations
Instructions for families: When introducing a new section:
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?
Roles of Variables with Examples in Scratch
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
Repetition Structures
Top-Down Design CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
© Jalal Kawash 2010 Elementary Set Theory Peeking into Computer Science.
Repeating Actions While and For Loops
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
Fall 2007ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
CS320n –Visual Programming Interactive Programs Mike Scott (Slides 5-1)
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C.
Tell the robot exactly how to draw a square on the board.
© Jalal Kawash Programming Peeking into Computer Science 1.
© Jalal Kawash Programming Peeking into Computer Science 1.
© Jalal Kawash Finite State Machines Peeking into Computer Science.
October 4, 2005ICP: Chapter 4: For Loops, Strings, and Tuples 1 Introduction to Computer Programming Chapter 4: For Loops, Strings, and Tuples Michael.
© Jalal Kawash 2010 Introduction Peeking into Computer Science 1.
© Jalal Kawash 2010 Logic Peeking into Computer Science.
© Jalal Kawash Databases & Data Modelling Peeking into Computer Science.
© Jalal Kawash 2010 Introduction Peeking into Computer Science 1.
© Jalal Kawash 2010 Trees & Information Coding: 3 Peeking into Computer Science.
© Jalal Kawash 2010 Elementary Set Theory Peeking into Computer Science.
© Jalal Kawash 2010 Trees & Information Coding Peeking into Computer Science.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
© Jalal Kawash 2010Peeking into Computer Science George Boole English Mathematician His The Mathematical Analysis of Logic, 1848 is the first.
Roles of Variables with Examples in Python ® © 2014 Project Lead The Way, Inc.Computer Science and Software Engineering.
© Jalal Kawash Programming Peeking into Computer Science 1.
© Jalal Kawash 2010 Graphs Peeking into Computer Science.
© Jalal Kawash 2010 Graphs Peeking into Computer Science.
Computer Science Department LOOPS. Computer Science Department Loops Loops Cause a section of your program to be repeated a certain number of times. The.
Visual Basic Programming
© Jalal Kawash Database Queries Peeking into Computer Science.
Programming: Simple Control Structures Part 2 – Repetition Alice.
Mathematical Expressions, Conditional Statements, Control Structures
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.
More about Strings. String Formatting  So far we have used comma separators to print messages  This is fine until our messages become quite complex:
Loops Robin Burke IT 130. Outline Announcement: Homework #6 Conditionals (review) Iteration while loop while with counter for loops.
Today’s Agenda 1.Collect Pre-Lab 3 2.Alice Programming Assignment 3.Built-in Functions 4.Expressions 5.Control Structure 6.Assign pair programming teams.
Programming: Simple Control Structures
© Jalal Kawash Database Queries Peeking into Computer Science.
© Jalal Kawash 2010 Elementary Set Theory Peeking into Computer Science.
Interactive Programming Alice. Control of flow Control of flow -- how the sequence of actions in a program is controlled. What action happens first, what.
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
UCT Department of Computer Science Computer Science 1015F Iteration
Topic : While, For, Do-While Loop Guided By : Branch : Batch :
Sequencing Learning Objective: to be able to design algorithms that use sequencing.
Chapter 3: Decisions and Loops
Lecture 7: Repeating a Known Number of Times
Learning Objective: to be able to design programs that use sequencing.
ALGORITHMS & FLOWCHARTING II
Control Structures
Programming: Simple Control Structures
Sequencing Learning Objective: to be able to design algorithms that use sequencing.
Chapter 8 Arrays Objectives
Programming: Simple Control Structures
Chapter (3) - Looping Questions.
Design and Implementation
Programming: Simple Control Structures
Topics discussed in this section:
Programming: Simple Control Structures
Chapter 8 Arrays Objectives
George Boole English Mathematician
Programming Dr. Jalal Kawash.
CSC1401 Manipulating Pictures 2
Programming: Simple Control Structures
Presentation transcript:

© 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: ◦ 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[0]) 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[0]) 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