Download presentation
Presentation is loading. Please wait.
Published byPamela Goodwin Modified over 9 years ago
1
Computer Bugs Original Powerpoint By: Spring LIS4480 Coding Team Jon
2
http://www.youtube.com/watch?v=nKIu9yen5nc Why Coding?
3
PB&J Programming
4
Instructions Work with your group Write instructions for how to make a peanut-butter and jelly sandwich
5
PB&J Program 1.Take a slice of bread 2.If the jar is not open, Open the jar of peanut butter by twisting the lid counter clockwise 3.Pick up a knife by the handle 4.Insert the knife into the jar of peanut butter 5.Withdraw the knife from the jar of peanut butter and run it across the slice of bread 6.Take a second slice of bread 7.Repeat steps 2-5 with the second slice of bread and the jar of jelly 8.Press the two slices of bread together such that the peanut butter and jelly meet
6
Download Hackety! http://goo.gl/PPyvA Michael
7
alert “Hello world!” What happens if we type this and hit run?
8
alert Displays a window “Hello world!” Is a string Think of it as a “string” of letters
9
name = ask “What is your name?” alert “Hello “ + name What is different?
10
name Variable Or nickname ask Displays a window with a text box
11
write a program that tells a joke
12
PB&J 1.Take a slice of bread 2.If the jar is not open, Open the jar of peanut butter by twisting the lid counter clockwise 3.Pick up a knife by the handle 4.Insert the knife into the jar of peanut butter 5.Withdraw the knife from the jar of peanut butter and run it across the slice of bread 6.Take a second slice of bread 7.Repeat steps 2-5 with the second slice of bread and the jar of jelly 8.Press the two slices of bread together such that the peanut butter and jelly meet
13
answer = ask “Is the jar open?” if answer == “No” alert “Open the jar.“ end Try answering with “No” and “no”. What is different?
14
answer = ask “Is the jar open?” if answer == “No” alert “Open the jar.“ end We’re asking if answer is equal to “No”.
15
answer = ask “Is the jar open?” if answer == “No” alert “Open the jar.“ end We’re asking if answer is equal to “No”.
16
answer = ask “Is the jar open?” if answer == “No” alert “Open the jar.“ else alert “Do not open the jar.“ end We can also tell the computer to do something else.
17
answer = ask “Is the jar open?” if answer == “No” alert “Open the jar.“ else alert “Do not open the jar.“ end Try answering with “Yes” and “No”. What is different?
18
Write a guessing game Aaron
19
secret = 42.to_s guess = ask “What is the secret?” Complete the program.
20
secret = 42.to_s guess = ask “What is the secret?” if guess == secret alert “Correct!“ else alert “Wrong!“ end Completed program.
21
alert 1 alert 1 + 1 alert 4 - 1 alert 8 / 2 alert 5 * 1 We can tell the computer to do math too
22
alert 1 alert 2 alert 3 Display the numbers 1, 2, 3
23
alert 1 alert 2 alert 3 alert 4 alert 5 alert 6 alert 7 alert 8 alert 9 What if we wanted to count higher?
24
alert 1 alert 2 alert 3 alert 4 alert 5 alert 6 alert 7 alert 8 alert 9 What if we wanted to count higher?
25
number = 1 9.times do alert number number = number + 1 end Does the same thing as before!
26
number = 1 9.times do alert number number = number + 1 end Make number = 1
27
number = 1 9.times do alert number number = number + 1 end do stuff until end 9 times
28
number = 1 9.times do alert number number = number + 1 end do stuff 9 times, end
29
number = 1 9.times do alert number number = number + 1 end Does the same thing as before!
30
secret = 42.to_s guess = ask “What is the secret?” if guess == secret alert “Correct!“ else alert “Wrong!“ end Can you change the code to ask “What is the secret?” 3 times?
31
secret = 42.to_s 3.times do guess = ask “What is the secret? You get 3 guesses!” end if guess == secret alert “Correct!“ else alert “Wrong!“ end Why does the program keep asking if we guess correctly?
32
secret = 42.to_s 3.times do guess = ask “What is the secret? You get 3 guesses!” if guess == secret break end if guess == secret alert “Correct!“ else alert “Wrong!“ end We need to tell the computer to break, or stop, if the guess is correct.
33
Let’s meet Turtle …not these turtles Michael http://www.youtube.com/watch?v=CMNry4PE93Y
34
Turtle.start do end What happens if you run this program?
35
Turtle.start do forward 100 end We need to tell Turtle to do something.
36
Turtle.start do turnright 90 end What does turnright 90 do?
37
Turtle.start do forward 100 turnright 90 forward 100 end We can combine directions. Can you make Turtle draw a square?
38
Turtle.start do forward 100 turnright 90 forward 100 turnright 90 forward 100 turnright 90 forward 100 turnright 90 end
39
Turtle.start do 4.times do forward 100 turnright 90 end With a loop things get easier!
40
Can you make Turtle draw an octagon?
41
Turtle.start do 8.times do forward 100 turnright 45 end
42
Turtle.start do background darkred pencolor gold 8.times do forward 100 turnright 45 end We can change the color of the background and the pencolor.
43
http://shoesrb.com/manual/Colors.html
44
Code this and customize it! Have fun and be creative! Harrison
45
Creative Contest Draw something using turtle. Don’t be afraid to ask for help! Skittles?
46
Conclusion We hope you enjoyed the lessons please let us know what you learned in the survey! If time is permitting let’s make something! P.S. We are getting graded on this
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.