- screenshots of scores will be posted in comments
- screenshots of completed sections will be posted in comments
- Did you run into any issues?
- How do you open Atom from your Terminal?
- What is the file extension for a Ruby file?
- What is the Atom shortcut for hiding/ showing your file tree view?
- What is the Atom shortcut for quickly finding a file (fuzzy finder)?
- screenshots of your terminal after each exercise will be posted in comments
Day One Questions:
- What does pwd stand for, and how is this command helpful?
- What does hostname tell you, and what shows up in YOUR terminal when you type hostname?
IRB
- How do you start and stop irb?
- What might you use irb for?
Variables
- How do you create a variable?
- What did you learn about the rules for naming variables?
- How do you change the value of a variable?
Datatypes
- How can you find out the class of a variable?
- What are two string methods?
- How can you change an integer to a string?
Strings
- Why might you use double quotes instead of single quotes in Ruby?
- What is this used for in Ruby: #{}?
- How would you remove all the vowels from a string?
Input & Output
- What do 'print' and 'puts' do in Ruby?
- What does 'gets' do in Ruby?
- Add a screenshot in the comments of the program you created that uses 'puts' and 'gets', and give it the title, "I/O".
Numbers & Arithmetic
- What is the difference between integers and floats?
- Complete the challenge, and post a screenshot of your program in the comments with the title, "Numbers".
Booleans
- What do each of the following symbols mean?
- ==
-
=
- <=
- !=
- &&
- ||
- What are two Ruby methods that return booleans?
Conditionals
- What is flow control?
- What will the following code return?
apple_count = 4
if apple_count > 5
puts "Lots of apples!"
else
puts 'Not many apples...'
end
- What is an infinite loop, and how can you get out of one?
- Take a screenshot of your program and terminal showing two different outputs, and post it in the comments with the title, "Conditionals".
nil
- What is nil?
- Take a screenshot of your terminal after working through Step 4, and post it in the comments with the title, "nil".
Symbols
- How can symbols be beneficial in Ruby?
- Does naming symbols use the same rules for naming variables?
- Take a screenshot of your terminal after working through Step 4, and post it in the comments with the title, "Symbols".
Arrays
- What method can you call to find out how many elements are in an array?
- What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]?
- What do 'push' and 'pop' do?
Hashes
- Describe some differences between arrays and hashes.
- What is a case when you might prefer an array? What is a case when you might prefer a hash?
-
- Take a screenshot of your terminal after working through Step 2, and post it in the comments with the title, "Hashes".
- Were you able to get through the work? Did you rush to finish, or take your time?
- What are you most looking forward to learning more about?
- What topics would you most like to see reinforced by instructors?
- What is most confusing to you about what you've learned?
- What questions do you have for your student mentor or for your instructors?
(Note: You will most likely only get to the following sections if you have more than a week for your pre-work. If you are doing the one week pre-work schedule, you may delete this section of the Gist.)
- Loops: Take a screenshot of your "Challenge" program, and post it as a comment in your Gist.
- What challenges did you try for "Summary: Basics"? Post a screenshot of one of your programs.
- Functions: How do you call a function and store the result in a variable?
- Describe the purpose of the following in Ruby classes: initialize method, new method, instance variables.
- How to Write a Program: Screenhero with your student mentor and share your program. Write a bit about what you found most challenging, and most enjoyable, in creating your program.
- screenshots will be posted in comments
- What are your three biggest takeaways from working through this book?
- screenshots will be posted in comments
- What are your two biggest takeaways from working through this tutorial?
- What is one question you have about Git & GitHub?
- Describe your thinking on effective workflow. What shortcuts do you think you'll find most useful? What would you like to learn or practice that will most help you improve your speed and workflow?
As you complete each section, respond to the related questions below (mostly taken directly from the tutorial exercises):
- 1.3: By reading the "man" page for echo, determine the command needed to print out “hello” without the trailing newline. How did you do it?
- 1.4: What do Ctrl-A, Ctrl-E, and Ctrl-U do?
- 1.5: What are the shortcuts for clearing your screen, and exiting your terminal?
- 2.1: What is the "cat" command used for? What is the "diff" command used for?
- 2.2: What command would you use to list all txt files? What command would you use to show all hidden files?
- 3.1: How can you download a file from the internet, using the command line?
- 3.3: Describe two commands you can use in conjunction with "less".
- 3.4: What are two things you can do with "grep"?
Day 7: Create a Program, Dice Rolling
Today I learned how to create a program using the example dice rolling where there are three goals:
I am going through the example step by step and will provide screen shots of Sublime and terminal as well as explanations of what was done.
I am showing that the method 'rand' is used to randomly roll the die.
![screen shot 2016-03-01 at 12 05 38 pm](https://cloud.githubusercontent.com/assets/12053149/13438360/fd27a442-dfa5-11e5-9744-08e3a5e6e457.png)
Step 1: Because the 'rand' methods begins with zero and a die begins with 1, we must write a function that will allow us to roll a die beginning with 1 and not zero. The screen shot below shows the code in Sublime and the random output of the rolling of the dice.
Step 2: Now we need to roll a dice that has any number of sides, so we change the argument so that we have sides.
See the screen shot below:
Step 3: Now we need to roll any number of dice. There is a lot that happen in step 3. I will walk through it underneath the screenshot.
![screen shot 2016-03-01 at 12 12 09 pm](https://cloud.githubusercontent.com/assets/12053149/13438591/db15f628-dfa6-11e5-86c5-fc9a72a14b90.png)
Details for Step 3:
The screen shot of Sublime shows that we created the argument 'number' and set of default value of 1 so that if nothing passes, it will return a value of 1.
Next, an empty array called roll_array was created to hold the dice that the user is about to roll.
Because we created an empty array, we need a method that will allow us to iterate through each dice roll. This method is the times method.
Because we used the do method (like the each method), we need to loop through each roll. this means we need to create a loop so that when the user rolls the die it creates a result that can be inserted in the array.
To hold the the value of the assigned rolls, we assign 0 to the variable totals.
Now loop through the loop_array and add it to the totals variable. It is important that we add the totals at the end so the program knows what to return.
Step 4: Although we have created a program, it is not very readable and contains some extra wording / coding that we could do without.
Step 4 is about refining our code to make it more simple, readable and thus understandable. I have created other programs before in Pragmatic Studios and this example is very complex and little confusing with the sides. I would like to work on another example of how to create a class. So, we will edit the code so that we create a instance method with sides. This allows us to pass the number of sides as an argument and then roll die as a method.
Step 5: We still need to make one change. The 'rand(sides) + 1' value doesn't make ANY sense to me and so I need to create a new method that specifies that we are generating a die roll. This makes the code easier to understand and more readable.
Step 6: Now we need to define some ready to use die that users can use immediately and not have to put user input to.
In this very last step, I instantiated some of the die and created a Constant so that the variables do not change. Class names are constants too, so our class Die is an unchanging variable. We will assign some dice to constants. They are below:
SIX_SIDED_DIE = Die.new(6)
EIGHT_SIDED_DIE = Die.new(8)
TEN_SIDED_DIE = Die.new(10)
TWENTY_SIDED_DIE = Die.new(20)
Lastly, I now require the file in IRB so that I can create a conditional.
![screen shot 2016-03-01 at 12 39 41 pm](https://cloud.githubusercontent.com/assets/12053149/13439419/c4633aea-dfaa-11e5-8cde-725b12eb2db5.png)