Hackety Hack Krystal Salerno What is Hackety Hack

  • Slides: 23
Download presentation
Hackety Hack! [Krystal Salerno]

Hackety Hack! [Krystal Salerno]

What is Hackety Hack? Hackety Hack is a cool Ruby-based program that makes it

What is Hackety Hack? Hackety Hack is a cool Ruby-based program that makes it really easy and fun to learn coding! You can get it at home and work on it too! www. hackety. com

Let’s get started! 1. Click on Start 2. Click All Programs 3. Open Hackety

Let’s get started! 1. Click on Start 2. Click All Programs 3. Open Hackety Hack 4. Click on the Hackety Hack program If you can’t find it, let us know!

The basics We are going to make a simple program that just says hello!

The basics We are going to make a simple program that just says hello! alert “Hello Krystal!” Click on Run in the bottom corner and watch!

What is a variable? Variables are things that we can change for the computer

What is a variable? Variables are things that we can change for the computer to read name = “Krystal” alert “My name is ” + name Click Run!

Asking questions: We can have the computer ask us questions too! name = ask

Asking questions: We can have the computer ask us questions too! name = ask “What is your name? ” alert “Your name is ” + name Click on Run!

Let’s draw! We can make the computer draw shapes with a few commands. Let’s

Let’s draw! We can make the computer draw shapes with a few commands. Let’s use Turtle to draw a simple square.

Let’s draw! Turtle. start do forward 50 turnright 90 end Click Run and see

Let’s draw! Turtle. start do forward 50 turnright 90 end Click Run and see what happens.

Let’s draw! So we only got a line, and a square has 4. How

Let’s draw! So we only got a line, and a square has 4. How can we fix it? Let’s copy this 4 times forward 50 turnright 90

Turtle. start do forward 50 turnright 90 end Let’s draw!

Turtle. start do forward 50 turnright 90 end Let’s draw!

Let’s draw! This takes too long to do, especially with more sides, so we

Let’s draw! This takes too long to do, especially with more sides, so we can tell the computer to repeat itself. When we do this we call it a loop. We can also change the colors of the background and the line Turtle makes!

Loopity Loop Turtle. start do background maroon pencolor honeydew 4. times do forward 50

Loopity Loop Turtle. start do background maroon pencolor honeydew 4. times do forward 50 turnright 90 end

Loopity Loop See how much nicer that makes it! Let’s play with the numbers

Loopity Loop See how much nicer that makes it! Let’s play with the numbers we have after forward and turnright and see what happens.

Strings and Integers Who knows what the difference between “ 1000” and 1000 is?

Strings and Integers Who knows what the difference between “ 1000” and 1000 is?

Strings and Integers “ 1000” is a string (The quotes “” are the key)

Strings and Integers “ 1000” is a string (The quotes “” are the key) 1000 is an integer Strings are words or letters, must have quotes Integers are only whole numbers

Strings and Integers If we tried to do a math problem with this: “

Strings and Integers If we tried to do a math problem with this: “ 1000” + 1 = … The computer would give us an error, we tried adding the word “one thousand” and 1, it won’t work. . .

Strings and Integers If we want to change “ 1000” to 1000, then we

Strings and Integers If we want to change “ 1000” to 1000, then we need to use a special command. to_i and to_s will do the trick! “ 1000”. to_i = 1000. to_s = “ 1000”

Lets Try It! Clear your editor, and let’s ask a question sides = ask

Lets Try It! Clear your editor, and let’s ask a question sides = ask “How many sides? ” Then let’s see how we can use this in the Turtle program!

Lets Try It! sides = ask “How many sides? ” Turtle. start do sides.

Lets Try It! sides = ask “How many sides? ” Turtle. start do sides. to_i. times do forward 50 turnright 40 end

Ask More Questions sides = ask “How many sides? ” steps = ask “How

Ask More Questions sides = ask “How many sides? ” steps = ask “How much should we turn? ” Turtle. start do sides. to_i. times do forward 50 turnright steps. to_i end

Ask More Questions sides = ask “How many sides? ” Turtle. start do sides.

Ask More Questions sides = ask “How many sides? ” Turtle. start do sides. to_i. times do forward 50 turnright 360/sides. to_i end

Calculators We can make small calculators with this too! number 1 = ask “First

Calculators We can make small calculators with this too! number 1 = ask “First number? ” number 2 = ask “Second number? ” alert number 1. to_i + number 2. to_i

/FITCAlliance @FITC_Alliance FITC Group Follow us on Social Media! #FITC & visit fitc. cci.

/FITCAlliance @FITC_Alliance FITC Group Follow us on Social Media! #FITC & visit fitc. cci. fsu. edu