computer bugs original powerpoint by: spring lis4480 coding team jon
TRANSCRIPT
Computer Bugs
Computer Bugs
Original Powerpoint By: Spring LIS4480 Coding TeamJonhttp://www.youtube.com/watch?v=nKIu9yen5ncWhy Coding?PB&J Programming
InstructionsWork with your group
Write instructions for how to make a peanut-butter and jelly sandwichPB&J ProgramTake a slice of breadIf the jar is not open,Open the jar of peanut butter by twisting the lid counter clockwisePick up a knife by the handleInsert the knife into the jar of peanut butterWithdraw the knife from the jar of peanut butter and run it across the slice of breadTake a second slice of breadRepeat steps 2-5 with the second slice of bread and the jar of jellyPress the two slices of bread together such that the peanut butter and jelly meet
Download Hackety!http://goo.gl/PPyvAMichael
alert Hello world!
What happens if we type this and hit run?
alertDisplays a window
Hello world!Is a stringThink of it as a string of letters
name = ask What is your name?alert Hello + name
What is different?
nameVariableOr nickname
askDisplays a window with a text box
write a program that tells a jokePB&JTake a slice of breadIf the jar is not open,Open the jar of peanut butter by twisting the lid counter clockwisePick up a knife by the handleInsert the knife into the jar of peanut butterWithdraw the knife from the jar of peanut butter and run it across the slice of breadTake a second slice of breadRepeat steps 2-5 with the second slice of bread and the jar of jellyPress the two slices of bread together such that the peanut butter and jelly meet
answer = ask Is the jar open?if answer == No alert Open the jar.endTry answering with No and no. What is different?
answer = ask Is the jar open?if answer == No alert Open the jar.endWere asking if answer is equal to No.
answer = ask Is the jar open?if answer == No alert Open the jar.endWere asking if answer is equal to No.
answer = ask Is the jar open?if answer == No alert Open the jar.else alert Do not open the jar.endWe can also tell the computer to do something else.
answer = ask Is the jar open?if answer == No alert Open the jar.else alert Do not open the jar.endTry answering with Yes and No. What is different?
Write a guessing game
Aaron
secret = 42.to_sguess = ask What is the secret?
Complete the program.
secret = 42.to_sguess = ask What is the secret?
if guess == secret alert Correct!else alert Wrong!endCompleted program.
alert 1alert 1 + 1alert 4 - 1alert 8 / 2alert 5 * 1
We can tell the computer to do math too
alert 1alert 2alert 3
Display the numbers 1, 2, 3
alert 1alert 2alert 3alert 4alert 5alert 6alert 7alert 8alert 9
What if we wanted to count higher?
alert 1alert 2alert 3alert 4alert 5alert 6alert 7alert 8alert 9
What if we wanted to count higher?
number = 19.times do alert number number = number + 1end
Does the same thing as before!
number = 19.times do alert number number = number + 1end
Make number = 1
number = 19.times do alert number number = number + 1end
do stuff until end 9 times
number = 19.times do alert number number = number + 1end
do stuff 9 times, end
number = 19.times do alert number number = number + 1end
Does the same thing as before!
secret = 42.to_sguess = ask What is the secret?
if guess == secret alert Correct!else alert Wrong!endCan you change the code to ask What is the secret? 3 times?
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!endWhy does the program keep asking if we guess correctly?
secret = 42.to_s
3.times do guess = ask What is the secret? You get 3 guesses! if guess == secret break endend
if guess == secret alert Correct!else alert Wrong!endWe need to tell the computer to break, or stop, if the guess is correct.
Lets meet Turtlenot these turtlesMichaelhttp://www.youtube.com/watch?v=CMNry4PE93Y
Turtle.start do
endWhat happens if you run this program?
Turtle.start do forward 100endWe need to tell Turtle to do something.
Turtle.start do turnright 90endWhat does turnright 90 do?
Turtle.start do forward 100 turnright 90 forward 100endWe can combine directions.Can you make Turtle draw a square?
Turtle.start do forward 100 turnright 90 forward 100 turnright 90 forward 100 turnright 90 forward 100 turnright 90end
Turtle.start do 4.times do forward 100 turnright 90 endendWith a loop things get easier!
Can you make Turtle draw an octagon?
Turtle.start do 8.times do forward 100 turnright 45 endend
Turtle.start do background darkred pencolor gold 8.times do forward 100 turnright 45 endendWe can change the color of the background and the pencolor.
http://shoesrb.com/manual/Colors.html
Code this and customize it! Have fun and be creative!HarrisonCreative ContestDraw something using turtle. Dont be afraid to ask for help!
Skittles?ConclusionWe hope you enjoyed the lessons please let us know what you learned in the survey!
If time is permitting lets make something!
P.S. We are getting graded on this