- screenshots of scores will be posted in comments
- screenshots of completed sections will be posted in comments
- Did you run into any issues?
The only issues I encountered arose from typos.
- How do you open Atom from your Terminal?
atom .
- What is the file extension for a Ruby file?
.rb
- What is the Atom shortcut for hiding/ showing your file tree view?
cmd+\
- What is the Atom shortcut for quickly finding a file (fuzzy finder)?
Cmd+t or Cmd+p
- 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?
It stands for "print working directory". It writes the pathname for your current working directory to the standard output.
-
What does hostname tell you, and what shows up in YOUR terminal when you type hostname?
It sets or prints the name of the current host system. When I type 'hostname' into my terminal it returns 'Charlottes-MBP'.
IRB
- How do you start and stop irb?
To start irb simply type 'irb' into the terminal. To exit type 'exit'.
- What might you use irb for?
irb is a good tool to explore how ruby features work.
Variables
- How do you create a variable?
To create a variable you must declare it using an appropriate variable name and an equal sign.
- What did you learn about the rules for naming variables?
Varibles must be declared using letters and numbers. They can be all letters, but they cannot be all numbers. They cannot start with a number. They can include an underscore but not a dash. They can contain a number but it must be either between two letters or at the end of the variable name.
- How do you change the value of a variable?
You can change variables in a number of ways. For interger and float variables you can use mathmatical formulas to alter a variable, such as new_variable = variable1 + variable2. For strings you can use dot notation, such as string = "thisisastring".upcase.
Datatypes
- How can you find out the class of a variable?
To find out what class a variable is use the .class method.
- What are two string methods?
.upcase and .downcase
- How can you change an integer to a string?
Use the method .to_s
Strings
- Why might you use double quotes instead of single quotes in Ruby?
String interpolation only works with strings contained by double quotes
- What is this used for in Ruby: #{}?
String interpolation.
- How would you remove all the vowels from a string?
Use the method .delete(aeiou)
Input & Output
- What do 'print' and 'puts' do in Ruby?
'print' and 'puts' are both methods of displaying outputs in Ruby. 'print' does not create a new line, but 'puts' does.
- What does 'gets' do in Ruby?
'gets' is a method used to aquire a new input from the user running a program.
- 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?
Initgers are numbers without decimal points, floats are number variables with decimal points.
- 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?
- ==
equals
-
=
greater than or equal to
- <=
less than or equal to
- !=
not equal
- &&
and
- ||
or
-
What are two Ruby methods that return booleans?
.end_with? and .include
Conditionals
- What is flow control?
Flow control is the order in which statements in a program are executed. In essence it's the order in which a program makes decisions according to the structure and order of the code.
- What will the following code return?
apple_count = 4
if apple_count > 5
puts "Lots of apples!"
else
puts 'Not many apples...'
end
It will return 'Not many apples...'.
- What is an infinite loop, and how can you get out of one?
An infinate loop is a loop in which the condiditons to terminate the loop cannnot be met. To exit an infinate loop type ctrl+c.
- 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?
Nil is used to determine if a variable is empty.
- 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?
Symbols help ruby to use memory more efficiently by allowing variables point to the same object in many places.
- Does naming symbols use the same rules for naming variables?
Yes and no. Symbols can be named using single or double quotes, whereas variables cannot. However, similar to variables, symbols cannot begin with a number, or contain a hyphen.
- 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?
array.length
- What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]?
The index of pizza is 0.
- What do 'push' and 'pop' do?
Push adds a new element to the end of the array. Pop deletes the last element of an array.
Hashes
- Describe some differences between arrays and hashes.
An array stores its items by index number, hashes store items by 'keys'. Hashes are lists of two items, the first is the key the second is the value.
- What is a case when you might prefer an array? What is a case when you might prefer a hash?
A case in which one would prefer an array would be with a simple list such as [1, 2, 3]. A case where a hash would be preferable is one in which there are many elements associated with one item. For example the date has the day, month, and year. A hash related to the date might look something like this date = {'day' => '1', 'month' => '2', 'year' => '2016'}.
-
- 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?
Yes. I took my time.
- What are you most looking forward to learning more about?
I'm just excited to learn how to work with ruby to build programs and practical applications. It's an interesting language.
- What topics would you most like to see reinforced by instructors?
Well I would like to learn more about objects and how to work with them within ruby.
- What is most confusing to you about what you've learned?
Most of what I have done for the prework has been more reiview than anything else. I have a little bit of experience coding and it was nice to refresh my understanding.
- What questions do you have for your student mentor or for your instructors?
What about ruby and the ruby on rails framework make it so great for developing web applications?
(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?
To call a function type in the name of the function then provide the values the function needs to do its job.
- Describe the purpose of the following in Ruby classes: initialize method, new method, instance variables.
The initialize method performs the required set-up and saves the initial data the object is created with. The new method creates an instance of the object and sends it to the initialize method. An instance variable is where data is stored within an object, they are only visable from within an instance of an object.
- 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"?
symbols