Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.

Slides:



Advertisements
Similar presentations
Why not just use Arrays? Java ArrayLists.
Advertisements

Lists, Loops, Validation, and More
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Mike Scott University of Texas at Austin
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Chapter 24 Lists, Stacks, and Queues
Visual Lists By Chris Brown under Prof. Susan Rodger Duke University July 2012.
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
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?
CS0004: Introduction to Programming Select Case Statements and Selection Input.
TE Sessions Supported by: Basic Concepts of Programming November 3, 2012.
PIIT Computer Science Summer Camp - Alice July 11, 2012 Brenda Parker Computer Science Department MTSU.
Events Chapter 7. Interactivity The real world is interactive User determines order of actions instead of programmer.
Events Chapter 7. Interactive Real world is interactive User determines order of actions instead of programmer.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Introduction to Computing Science and Programming I
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Microsoft ® Office Excel ® 2007 Training Get started with PivotTable ® reports [Your company name] presents:
Data Structures Introduction Phil Tayco Slide version 1.0 Jan 26, 2015.
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Summer Computing Workshop. Session 4 Loops  At the heart of their functionality, loops enable blocks of code to be executed more than once  Loops represent.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Branching and Looping Examples, cont’d. Remember the generic triple jump world…
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Python November 28, Unit 9+. Local and Global Variables There are two main types of variables in Python: local and global –The explanation of local and.
Summer Computing Workshop. Session 2 Input in Scratch  Multi-Character input - This is used when the user is prompted to enter a number or word.  Problems.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Python Programming Chapter 6: Iteration Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
Key Applications Module Lesson 21 — Access Essentials
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.
Summer Computing Workshop. Introduction  Boolean Expressions – In programming, a Boolean expression is an expression that is either true or false. In.
Animating Objects in Groups: Using Arrays and Lists By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
I Power Higher Computing Software Development High Level Language Constructs.
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Selection Statements. Introduction Today we learn more about learn to make decisions in Turing ▫Nested if statements, ▫case statements.
Nonvisual Arrays by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
CS190/295 Programming in Python for Life Sciences: Lecture 6 Instructor: Xiaohui Xie University of California, Irvine.
Input Boxes, List Boxes, and Loops Chapter 5. 2 Input Boxes Method for getting user’s attention to obtain input. InputBox() for obtaining input MessageBox()
Data Handling in Algorithms. Activity 1 Starter Task: Quickly complete the sheet 5mins!
Computer Science 1000 Algorithms III. Multiple Inputs suppose I ask you to write a program that computes the area of a rectangle area = length * width.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 4-1 Lecture Objectives To understand: –what values can be stored in a Boolean.
Chapter 7 Continued Arrays & Strings. Arrays of Structures Arrays can contain structures as well as simple data types. Let’s look at an example of this,
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
Loops Brent M. Dingle Texas A&M University Chapter 6 – Section 6.3 Multiway Branches (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
By Melissa Dalis Professor Susan Rodger Duke University June 2011
Let's Race! Typing on the Home Row
Microsoft Word - Formatting Pages
Conditions and Ifs BIS1523 – Lecture 8.
Introduction to TouchDevelop
Arrays
Introduction to Problem Solving and Control Statements
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Using Lists and Functions to Create Dialogue
Presentation transcript:

Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop

Session 7

Pre-Project Design an Alice program that not only determines the mean of a collection of numbers supplied by the user stored in an array, but also finds the median and range.

What is a List? A list is very similar to an array. It contains multiple variables of the same type. Arrays have a definite size which must be set before the program starts. Lists are different and allow the programmer to add elements to the list dynamically. This means a list can grow in size while the program is running. Say we wanted to ask the user for as many numbers as they want to enter. With an array, eventually we would run out of space. However, a list grows as the user adds data. This gives us a little more flexibility when programming.

Lists Go ahead and make a list by creating a new variable. Change array to list and check the box to the left of list (the same way we did to create an array). Now that we have a list created, drag it to your method to display the lists methods. The below menu will be displayed. Keep the menu up so we can follow along:

Insert Methods for Lists This is an insert at beginning of list method which can add items to the beginning of the list. The first box represents the number to be inserted into the list and the second box shows which list will be affected. The insert at end of list method is similar to the previous method except it inserts an item at the end of the list. The boxes are exactly the same. This is an insert at position method which allows the list to act similar to an array. Like arrays, lists in Alice index their elements. This block allows us to insert something anywhere we want in the list depending on the index value. The first box represents the number being inserted, the second represents the position (index) at which we want to insert the item, the 3rd box is the same as before.

Remove Methods for Lists This is a remove item from beginning of list which removes the first item from the list; the second item then becomes the first. This is a remove item from end of list method. It does exactly what it says. This is a remove item from position method which, for example, removes item from index 2. Item 3 becomes item 2, item 4 becomes item 3, etc. This is a remove all items from list method which allows the user to clear the list.

Dynamic Size of Lists The following example will show the dynamic capability of a lists size. We will use a loop to take input from the user. Drag a while loop to your method, place an ask user for yes or no function in the conditional part of the while loop. Now enter something such as Would you like to add a number to the list?

Dynamic Size of Lists We want to insert an item at the beginning of the list. To do this, drag the list inside the while loop and choose the appropriate method. Place an ask user for a number function inside the number part of the previously placed method. The default question will work fine. This loop will allow the programmer to prompt the user to enter as much input as desired and store the input into a list.

Step Through a List Now lets use a loop to step through the list. To test this we will make the camera say each number. Drag a loop under the while loop and select anything for now. Drag the list into the number area of the loop to replace what was previously chosen. This will bring up the lists functions. Select the size of list function (refer to slide notes for more details).

Step Through a List cont. Now drag a camera say method into the loop. Place a what as a string function (world object) as the string parameter in the say method. Select anything for now. Drag the list and place it into the function what as a string. From this menu, mouse-over the ith item from list function, mouse-over expressions and choose index. Lets test!

For All In Order Loop Alice has conveniently created a loop specifically designed to step through a list. The for all in order loop does exactly that. Delete the current for loop and everything it contains. Drag a for all in order loop and place it where your previous loop was located. Mouse-over expressions and choose your list.

For All In Order Loop Place a camera say method inside our for all in order loop, mouse-over expressions and select item_from_list. Test your program. Notice it steps through the list exactly as the previous loop did. Either loops will work in a situation like this.

For All Together Loop A for all together loop is similar to a do together container. Like the for all in order loop, a list is needed. If we use this loop with our previous example, it would print all the words in the list to the screen at the same time. This seems useless when used like this but if we wanted multiple object to do something at the same time, we could put them into a list and use this loop. To better understand this, lets do a small example. Create a new project and add 5 bird objects. We plan to make all 5 birds fly away at the same time.

For All Together Loop We could use a do together container and place the fly away methods of the bird objects inside it but using a for all together loop may be easier. Create a new list of type object and name it birds. This list will hold our birds we previously created. Create new items for the list and assign the birds previously created to the items of the list (remember, the list must be of type object for us to hold objects in it).

For All Together Loop Now place a for all together loop in your program, mouse-over expressions and choose your list. Drag one of the bird objects fly away method and place it in the for all together loop (not the fly method, the fly away method), mouse-over expressions, mouse-over item_from_birds, and select (the number is a parameter for this method signifying how fast to make the bird fly away)

For All Together Loop Lets test this project. Notice all birds fly away at the same time. Discussed earlier was a way of doing the same thing with a do together container. Think about how this might be accomplished.

Project 7 Design an Alice program that not only determines the mean of a collection of numbers supplied by the user, but also finds the median and range. This time, use lists instead of arrays. If you have completed the project, feel free to have the program find the mode as well.

Day 4 Questions What three types of Boolean logical functions do we cover? Boolean logic deals with true or false values. ( true/__false) Where are Boolean expressions most commonly used? Can two blocks run at the same time? If so, how could this be accomplished? What is the difference between an array and a list in Alice? If you wanted to store 20 numbers supplied by the user, should an array or list be used? Is it possible to rearrange(sort) items in a list? In the following array, find and write down the value with an index of 3. [2, 41, 16, 7, 10]

Answer Key What three types of Boolean logical functions do we cover? And, or, not Boolean logic deals with true or false values.( X true/__false) Where are Boolean expressions most commonly used? conditional branches/ while loops Can two blocks run at the same time? If so, how could this be accomplished? Yes, through the use of a do together block What is the difference between an array and a list in Alice? Array cannot change size and is faster, a list is dynamic and is slightly slower If you wanted to store 20 numbers supplied by the user, should an array or list be used? since the size is known ahead of time an array should be used Is it possible to rearrange(sort) items in a list? Yes In the following array, find and write down the value with an index of 3. [2, 41, 16, 7, 10] 7