Learn Coding with Hackety Hack in Ruby: A Fun Introduction to Programming

Slide Note
Embed
Share

Discover Hackety Hack, a beginner-friendly Ruby-based program that makes coding fun and easy. Learn the basics of coding, variables, asking questions, drawing with Turtle, and using loops to simplify repetitive tasks. Start your coding journey today with Hackety Hack!


Uploaded on Sep 28, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Hackety Hack! Written by Krystal Salerno Presented by _______________

  2. 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

  3. Lets 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!

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

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

  6. 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!

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

  8. Lets draw! Turtle.start do forward 50 turnright 90 end Click Run and see what happens.

  9. Lets 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

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

  11. Lets 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!

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

  13. 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.

  14. Strings and Integers Who knows what the difference between 1000 and 1000 is?

  15. 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

  16. 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...

  17. 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 1000.to_s = 1000

  18. 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!

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

  20. 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 end

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

  22. Calculators We can make small calculators with this too! number1 = ask First number? number2 = ask Second number? alert number1.to_i + number2.to_i

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

Related