2012 CSE-BEACON camp1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed for.

Slides:



Advertisements
Similar presentations
Create a Simple Game in Scratch
Advertisements

Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Create a Simple Game in Scratch
30 min Scratch July min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)
Mission Technology Introduction to Scratch! June 2007.
Scratch for Storytelling Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
1 An intro to programming concepts with Scratch Session 3 of 10 sessions Repetition and variations.
Write Your First Computer Game!. Coding: Programming Languages Just like you can speak Chinese to someone who understands Chinese to tell them what to.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
MSU/CSE 260 Fall Integer Representations & Base Conversion Section 3.6.
Learn… Create… Program. Manipulation of Multiple Media Connects with youth culture Scratch is a new graphical programming language designed to support.
Session 5 of 10 Review + Multiple Sprites
1 An introduction to programming concepts with Scratch.
An intro to programming concepts with Scratch Session 2 of 10 sessions I/O, variables, simple computing.
1 An introduction to programming concepts with Scratch (in 5 hours + homework)
1 An intro to programming concepts with Scratch Session 1 of 10 sessions Looks and Motion.
ITEC Winter An intro to programming concepts with Scratch Quick intro for college citizens. George Stockman MSU CSE.
What is Scratch? Scratch as Logo Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Fish Chomp. The screen where you can see what happens when you play your game is called the STAGE. The SCRIPT BANK is where the types of instructions.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
Illuminating Computer Science CCIT 4-6Sep
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
Code Club Session 2 Dance Party. What will we learn ?  How to change the background  How to create animations  How to make objects talk to each other.
Introduction to Scratch!
Scratch Programming. Objectives for Today Finish your online design math problem. Name the basic terms used in Scratch. Create the beginning of a simple.
We will be creating a spaceship that simulates real movements in space. The spaceship will fire a laser beam that can destroy targets. The spaceship will.
Exploring Computer Science 2/23/15 2/23 Develop a Scratch story project -Brainstorming 2/24 Develop a Scratch story project –Developing 2/25 Develop a.
Exploring Computer Science 2/16/15
Objects and Methods in Scratch 1. 2 Scratch environment Stage is at upper right (where actors act and information is displayed) Sprite is another name.
2012 CSE-BEACON camp1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed for.
EV3 Workshop Oct 3, 2015 Instructor: Chris Cartwright
Introduction to Scratch Scratch as Logo Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
Scratch Another computer programming language Developed by MIT in 2003
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Computer Programming Modeling a Passive Solar Home.
24 Background Building 25 Computing Terminology, and Speed/Velocity Module 4 Notes: Sensing, Or Operator, Conditional Logic 28 Module 4 Algorithms,
Variables and Random Numbers Computer App Session 4.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Unit 1: Computing Fundamentals. Computer Tour-There are 7 major components inside a computer  Write down each major component as it is discussed.  Watch.
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
1 CSC 221: Computer Programming I Fall 2009 Introduction to programming in Scratch  animation sprites  motion, control & sensing  costume changes 
ICT/COMPUTING RULES Only use software allowed by the teacher
Computer Programming Modeling a Passive Solar Home.
Computer Programming with Scratch JAOIT 8. Scratch Scratch is a programming language that makes it easy to create your own interactive stories, animations,
Teaching Kids Programming with Chromebook Digital Convergence Lab, NIU.
Phase 3: Game Creation. Phase 3: Game Creation Outcomes (Slide 1) I can create a flowchart to solve a problem, for example to make a cup of tea. I can.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Introducing Scratch Learning resources for the implementation of the scenario
Using MIT Scratch for Programming and Control Programming 9.
Introduction to Scratch
Scratch for Interactivity
Scratch Unit Overview We are going to look at computer programming and how to create your very own computer game The piece of software we will be using.
Spanish Mad libs with Scratch
Scratch for Interactivity
Introduction to Object-Oriented Programming
Learn… Create… Program
Learn… Create… Program
An intro to programming concepts with Scratch
Learn… Create… Program
Learn… Create… Program
Creating a Simple Game in Scratch
CSC 221: Introduction to Programming Fall 2018
Presentation transcript:

2012 CSE-BEACON camp1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed for learners 10 years old up to 100.

Materials for hands on activities 2012 CSE-BEACON camp2 1)a set of cards with numbers, say, 42, 17, 43, 55, 20, 32, 12 2)A set of cards with binary place values: 1, 2, 4, 8, 16 3) Scratch downloaded from 4) for tutorials for homeworkwww.learnscratch.org 5) for this and other ppt setswww.cse.msu.edu/~stockman

2012 CSE-BEACON camp3 What is an algorithm? Algorithms for average and min An algorithm for sorting

2012 CSE-BEACON camp4 Algorithm for computing the average of two numbers Let the first number be A; say A=12 And the second number be B; say B=15 To compute the average _____________ So the average of 12 and 15 = ________ WHAT IS THE AVERAGE ALGORITHM?

2012 CSE-BEACON camp5 What is an algorithm? An algorithm computes some output from the given input using precise steps that a machine can follow (machine or other agent)

Hands on activity: finding MIN Organize into 2-person teams Team has “person A” and “person B” Each team has a stack of cards There is one number on each card No one looks at numbers yet 2012 CSE-BEACON camp6

7 problem: finding min Person B is the “worker” for A. Person A has cards, but cannot look at the numbers. A must find the min of all cards. B can look at only 2 numbers at a time -- B returns to A the smaller smaller first. HOW CAN PERSON A FIND THE MIN? Shuffle the cards A and B switch roles: new person A finds MIN

2012 CSE-BEACON camp 8 review: team finding the min Person A can look at no numbers! No numbers can be seen by A, EVER! Person B can look at only two numbers on cards given by person A. Person B gives back to A first the card with the smaller number (if numbers are = then it doesn’t matter which is given first) Person A must find the min and show it to the instructor WITHOUT EVER SEEING IT A and B should switch roles and repeat.

Thought Questions If A has 10 cards with numbers, how many times does A call on B? _____ If A has 100 cards, how many times does A call on B? _____ If A has N cards, how many times does A call on B? _____ Finding the MIN of a list of numbers has “complexity” _______ 2012 CSE-BEACON camp9

Thought Question Suppose A has 2 assistants – B and C Can A find the MIN any faster? HOW? Computers and computer programs can be structured to do more than one operation at a time CSE-BEACON camp10

2012 CSE-BEACON camp11 Problem: how to sort? Use set of cards for each team. How can A sort using B as comparer? TRY IT: instructor will check your final output

2012 CSE-BEACON camp 12 Sorting two-person activity This is a 2-person exercise. Person A CANNOT see the numbers – EVER! To solve the sorting puzzle, person A must form an ordered list of cards, which the instructor will check for order (this is the OUTPUT). Person B can only compare two numbers by seeing the numbers. Person B gives A the smaller number card first (precise operations). Person A can only ask Person B which of two cards has the smaller number. Person A never ever looks at any numbers. To solve the sorting puzzle, person A must start from an unordered list of cards (this is the INPUT).

2012 CSE-BEACON camp13 Sorting thought questions How many times will A call on B to sort 10 numbers? _____ How many calls to sort 100 numbers? _____ How many calls to sort N numbers? _____ There are many sorting algorithms. Some are fast when N is small but slow when N is big. Some are the opposite. Computer scientists learn these algorithms and many others.

Algorithms often do operations over and over Called “looping” Also called “iteration” or “repetition” “Recursion” is a related idea – first select the MIN from the list and then “recurse” on the rest of the list 2012 CSE-BEACON camp14

2012 CSE-BEACON camp15 Binary Information Coding 1. Only 2 symbols: WHY? 2. Can we code numbers, characters, music, images, movies, car designs using just 2 symbols?

Coding activities 1. Guessing the number of fingers in decimal 2. Guessing 1 finger versus 0 fingers 3. Encoding small integers using binary cards 4. Coding using animate versus inanimate objects (“My teacher plays rock, paper, scissors with me.”) * Instructor quickly brings, say, 7 fingers from behind the back. Students make errors in guessing the number. Few errors in 0 versus 1 discrimination CSE-BEACON camp16

Fundamental coding principle Can rep 2 “things” with 1 bit: yes/no; smiley/sad; high/low; odd/even Can rep 4 “things” with 2 bits; 00:clubs; 01:diamonds; 10:hearts; 11:spades Can rep 8 things with 3 bits CSE-BEACON camp17

Fundamental coding principle Each time we add one more bit, we __________ the number of binary strings There are _____ binary strings of length N=7 (think about ASCII code) There are thus ______ possible binary strings of length N bits 2012 CSE-BEACON camp18

2012 CSE-BEACON camp19 ASCII code for characters CHAR CODE A a B b C c * %

How many characters does a computer need to use? Old Univac system used 6 bit char – a design disaster: _____ symbols max IBM 8-bit code enabled ____ symbols (digits, caps, small letters, punctuation, graphic symbols, bell, null, etc.) Unicode uses 16 bits to code all of the above and international characters: ______ symbols CSE-BEACON camp20

2012 CSE-BEACON camp21 CD has many tracks of spots Shiny spot is 0 Burned spot is 1 5 billion spots total 700 MB total 44,000 x 16 spots for just 1 second of high fidelity music Laser reads shiny versus dull spots CD CD spins What’s a “CD”?

Even parity to detect errors To the 7-bit ASCII code, append one parity bit to have an even # of 1 bits Sender always sends an even number of bits If some disturbance causes a bit to change, receiver gets an odd number or 1-bits in the char code. If error, receiver asks for retransmit CSE-BEACON camp22

Bit strings as numbers Binary Places Decimal equivalent CSE-BEACON camp23

2012 CSE-BEACON camp24 Binary Ops easy for machine Addition has few rules. Multiplication has few rules These can be carried out in nanoseconds by computer circuits 0+0 = = 1+0 = = 0 with 1 carry 0x0 = 0x1 = 0 1x0 = 0 1x1 = 1

1 is 0 is What number? CSE-BEACON camp

0 is 1 is What number? ____ What number? ____ What number? CSE-BEACON camp

0 is 1 is What number? ______ CSE-BEACON camp

Binary coding in a computer Symbol 0 can be represented by +5V and 1 by -5V 0 can be darkness and 1 lightness, as used on CDs and DVDs or in optical fibers 2012 CSE-BEACON camp28

2012 CSE-BEACON camp29 Conversion of decimal to binary: Algorithm #1 Let D1 be a decimal integer Let R1 = remainder of D1 divided by 2; R1 is the 1’s bit Let D2 be the dividend of D1/2 Let R2 = remainder of D2 divided by 2; R2 is the bit in the 2’s place. & so on

Decimal to binary conversion 2012 CSE-BEACON camp30 INPUT: a decimal number OUTPUT: a binary number PRECISE STEPS: repeated division by 2; recording the remainder TERMINATES?: always (why?) CORRECT?: why?

Guessing games 2012 CSE-BEACON camp31 Guessing birthdays: just day of month Guessing month and day Guessing face value of cards Guessing suit and face value

32 Programming concepts via Scratch Free download of software available at Video tutorials for learning available at CSE-BEACON camp

33 What can we do with Scratch? Learn some computing concepts. Learn some practical algorithms. Use Scratch as computing tool. Have fun with Scratch creating stories, games, art CSE-BEACON camp

34 Start scratch and let’s go! In the lab, Click on the cat icon Scratch programming environment comes up First do simple things 2012 CSE-BEACON camp

35 Explore Scratch environment Stage is at upper right (where actors act and information is displayed) Sprite is another name for actor. Instruction menus/panel at left (instructions for the actors) A script is another name for program or method; a script tells the actor what to do. Programming area in center; here is where we construct scripts for the sprites 2012 CSE-BEACON camp

The VARIABLES Menu Implement an average algorithm Make a variable “FIRST” and set it to 12 Make a variable “Second” and set to 15 Make variable “Average” Use OPERATIONS Menu to set the Average to (FIRST+SECOND)/2 Test Scratch and algorithm 2012 CSE-BEACON camp36

Square root by repetition Guess sqrt(N) to be 1.0 Set root1 = 1.0 (first factor) Set root2 = N/root1 (second factor) root1 is not likely to = root2 Reset root1 to the average of root1 and root2 (it will be in between them, why?) Reset root2 = N/root1 Repeat all of the above until root1 and root2 are “very close” 2012 CSE-BEACON camp37

Algorithm study is RICH! Algorithm to find your BEST mate? What if you had the coding of genes for all possible mates? Algorithm to make bet on Big 10 game? Algorithm to find best molecule to bond with a given input molecule? Algorithm to bond 2 molecules to create “best properties” CSE-BEACON camp38

Information theory is RICH SETI: Search for Extra Terrestrial Intelligence Jodi Foster movie “Contact” What are the chances that a random signal from space codes “I love you”? Or “X^2+Y^2 = R^2”? 2012 CSE-BEACON camp39

40 The LOOKS menu Has instructions for setting the color, size, and visibility of a sprite. Costumes will be used later CSE-BEACON camp

41 The “hello” script (program) Choose the Looks menu Click on the “say hello” lego block Check your sprite behavior at the right Then click “say hello for 2 secs” Your very first Scratch program! 2012 CSE-BEACON camp

42 Try some other looks operations (click on menu items) Change color effect by 25 Change color effect by 25 again Hide Show Change size by 10 Change size by 10 again Set size to 100% 2012 CSE-BEACON camp

43 Let’s write a script to Say “hello” for 2 seconds Then change color by 25 Then think “Hmm..” for 4 seconds Then change color by 75 Then change size by 200 Drag each instruction from the menu to the center script area. Connect them into a single block. Edit the parameters to get the numbers we want CSE-BEACON camp

44 Our script (program) 2012 CSE-BEACON camp

45 A sequence or block is a simple script or program The first instruction is done first The second instruction is done second The last instruction is done last. (if any one instruction is done, then every on of them is done) 2012 CSE-BEACON camp

46 The WAIT instruction WAIT is needed to slow down the acting so we can see or hear it properly (computers are too fast sometimes) Get the wait instruction from the CONTROL menu. Ignore the other menu options for now. Insert a wait in our looks script 2012 CSE-BEACON camp

47 3 second pause between changing color and size 2012 CSE-BEACON camp

48 Student exercise: write a script to do the following Double the size of the sprite Wait 2 seconds Change the color of the sprite to green Wait 4 seconds Change the whirl effect to 100 Say “That’s all folks!” 2012 CSE-BEACON camp

49 The MOTION menu How to locate and orient a sprite; and, how to move a sprite CSE-BEACON camp

50 Position on the stage Using the Looks menu, shrink our cat to 25%. Click on the Motion menu. Click to check the box for x- position and y- position Drag your cat around and note its x-y position CSE-BEACON camp

51 Exercises: goto instruction (do you know about coordinates?) In the Motion menu, drag the “goto xy” instruction to the script panel. Edit the coordinates and click to see the sprite’s position A) goto x=200, y=0 B) goto x=-200, y=0 C) goto x=200, y=-100 Where does the cat go? 2012 CSE-BEACON camp

52 The “glide-to” instruction Drag the “glide-to” instruction into your script panel. Edit the coordinate values and click to see where your sprites goes CSE-BEACON camp

53 Exercise Create a script to glide the sprite along the sides of a triangle. The first vertex of the triangle is (-100, -100). The second vertex is (200, -100). The third vertex is (50, 100). Make sure you complete the triangle. Change the speed of gliding and run again. New feature: click on Pen Down in the Pen Menu and run it again 2012 CSE-BEACON camp

Exercise: A fun looping program Position your sprite at the lower left Put the pen down Do the following forever Rotate +5 degrees Move around an equilateral triangle as before (turning 120 degrees each angle) 2012 CSE-BEACON camp54

Exercise: bat flying randomly 2012 CSE-BEACON camp55 Make a bat fly by flapping between 2 bat “costumes”. Use random values of coordinates x and y. Use arrows keys to control the bat’s position. * Use a forever loop to make the bat continue to fly when the flag is clicked * See if you can create a “score” variable and use it to count how many times the user clicks on the bat.

Exercise: find the MIN of a list Explore how to create a list variable Explore how to input numbers to the list Explore how to pass through the list to set a variable MIN to the minimum in the list Some hints follow 2012 CSE-BEACON camp56

Make list L and also a variable for its Length Our list CSE-BEACON camp

Ask the user for list length after the user hits key ‘L’ CSE-BEACON camp

Repeat Length times, ask the user for item k of the List The user has given 3 items and is being asked for item k= CSE-BEACON camp