- screenshots of scores will be posted in comments
- screenshots of completed sections will be posted in comments
- Did you run into any issues?
Not really. I already had xcode installed from previous online coursework so and have been through the command line lessons on code academy so it was all very straightforward.
- How do you open VS Code from your Terminal?
type code. hit enter.
- What is the file extension for a Ruby file?
.rb
- What is the VS Code shortcut for hiding/ showing your file tree view?
Command B
- What is the VS Code shortcut for quickly finding a file (fuzzy finder)?
Command 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?
Present working directory. It lets you know which directory you are currently working in and thus affecting. Since the command line moves one at a time it seems like it can be easy to become disoriented. This ensures you know where you are.
- What does hostname tell you, and what shows up in YOUR terminal when you type hostname?
My computer's network name. Benjamins-MacBook-Pro.local
IRB
- How do you start and stop irb?
Type irb and hit enter to start. Type exit and hit enter to stop. On my machines I can also use CTRL + D.
- What might you use irb for?
irb is a place to experiment with how ruby language and functions work. It is not a good place to write code...
Variables
- How do you create a variable?
creat a variable name such as "my_variable" and set it equal(using the "=") to something(number, string, etc).
- What did you learn about the rules for naming variables?
variables cannot start with a number, cannot have dashes and cannot have space. They should generally start with a lower case letter or an underscore.
- How do you change the value of a variable?
set the variable name equal("=") to the new value.
Datatypes
- How can you find out the class of a variable?
type the variable and call the method ".class"
- What are two string methods?
.upcase, .downcase
- How can you change an integer to a string?
call the method ".to_s" i.e. "5.to_s"
Strings
- Why might you use double quotes instead of single quotes in Ruby?
If I want to use string interpolations(#{example}) I have to use double quotes. Otherwise double or single quotes are valid for strings.
- What is this used for in Ruby: #{}?
That combination of symbols is used for string interpolation. So whatever is inside the curly braces will be embeded into the string when it's outputted. If it is a number or equation it will be converted to part of the string during output. If it's a variable the value of the variable will be called into the string.
- How would you remove all the vowels from a string?
'This sentence is a string containing vowels'.delete('aeiou')
Input & Output
- What do 'print' and 'puts' do in Ruby?
Print outputs some to ruby on a single line. Puts outputs something to ruby with a line after it.
- What does 'gets' do in Ruby?
"Gets" prompts the use for some sort of input.
- 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?
Inegers are whole numbers like 2, -5, and 55. Floats are numbers with decimels like 3.14 or 2.1
- 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?
- ==
equal to
-
=
greater than or equal to
- <=
less than or equal to
- !=
not equal to
- &&
both sides must be true to return true boolean
- ||
one side or the other or both must be true to return true boolean
-
What are two Ruby methods that return booleans?
.nil? .empty?
Conditionals
- What is flow control?
Flow control is the idea that the program makes decisions on which piece of code to run depending on the conditions. Either as a result of input or other circumstances it chooses which code to execute.
- What will the following code return?
apple_count = 4
if apple_count > 5
puts "Lots of apples!"
else
puts 'Not many apples...'
end
The code will return 'Not many apples...' because apple_count is less than 5 so the true condition is not met.
- What is an infinite loop, and how can you get out of one?
An infinite loop is a piece of code using something like a while statement has no provision to make the statement false, thereby it will simply continue to run forever until stopped with a command like ctl + 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 a datatype that means nothing. Not zero but specifically the abscence of data.
- 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 can be beneficial in ruby by creating single consitant objects that can be pointed to throughout a program. This matters more in larger programs where conserving memory helps for efficiency. Unlike strings which require individual object identities, even if the conent is the same, if two symbols are the same content then they are the same object. Hence one id, less memory used.
- Does naming symbols use the same rules for naming variables?
Generally the rules are the same except that a symbol can circumvent all naming conventions by putting the name in quotes. For example :10 Varraible-15 would return ane error but :"10 Varraible-15" is acceptable.
- 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_name.length will tell you how many elements are in an array.
- What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]?
The index of the first item in an array is 0.
- What do 'push' and 'pop' do?
.push() will add whatever is between the brackets to the end of the array it is called on. Conversely .pop will remove the last elements of the array it is called on.
Hashes
- Describe some differences between arrays and hashes.
Arrays store values in a specific order which can be retrieved by the index number of their position. Hashes store pairs of keys and values thus you don't need the exact location within a hash to find a value, only its corresponding key. Arrays use brackets whereas hashes use curly braces and rockets to assign keys to values.
- What is a case when you might prefer an array? What is a case when you might prefer a hash?
You may prefer an array if keep a set of data in a particular order because the index of a given item in the array would be useful. You would prefer a hash if, for example, you are keeping a set of data about an object(i.e. a basketball) where the keys in the hash are characteristics(i.e. color, shape) and the values are the corresponding values of those characteristics for the item(i.e. orange, spherical)
-
- 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 was able to get through all the pre-work. I would not say that I rushed although I did finish this section very quickly. I would say that I dedicated a significant amount of time each day to the tasks and so was able to accomplish faster than if I had had more pressing life commitments or time constraints. With so much time still to come before the start of class I intend to not only move on to the additional prework but to also reviewing and solidifying the concepts in these earlier sections.
- What are you most looking forward to learning more about?
I am most looking forward to learning more about the command line. I'm really enjoying interacting with my computer on that level. I'm fascinated by all the things you can accomplish just from the terminal. Additionally I'm looking forward to learning how to practically apply ruby for designing and making programs. After doing all the brilliant excercises I'm realizing there is just a staggering depth of computer science I am unaware of and I'm hoping to close that gap as much as possible.
- What topics would you most like to see reinforced by instructors?
In terms of the Ruby specific pre-work I would love to see the use and explanation of symbols reinforced. I understand the basic differences between symbols and strings, but in a more utilitarian sense I want to understand why it is better to an immutable vs mutable data type. Again this is just getting into more solid computer science concepts that I imagine will be a future focus of certain classes.
- What is most confusing to you about what you've learned?
In addition to what I was mentioning about symbols in the previous sections I would also like to get more clarification about flow control. That section of the pre-work gave me the most trouble in terms of the additional challenge part of the assignment. I was able to design something that fit the criteria but only by searching ahead to find the functionality I needed. I don't know if the intention of the challenge was to go in search of the answer or if there was a way to write the program using the concept we were supposed to have learned up to that point.
- What questions do you have for your student mentor or for your instructors?
Most pressing would be the question from the previous question regarding the additional challenge program from the flow control section. Beyond that I don't have any specific questions regarding the ruby or command line prework. Having jumped ahead a bit, I'm curious about git and github and how that is used in practicle programming workflow.
(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?
After defining the function you can simply call it by name. To store it as a variable would look something like:
myVar = function_name parameter
- Describe the purpose of the following in Ruby classes: initialize method, new method, instance variables.
The initialize method is the first function of a class and saves the intial date a given object is created with in addition to any further required setup. The new method is how you create an object using a defined class. It is called on the class with the argument of whatever variable the initialize function of that class requires. Instance variables are used within a object to store data and are only used within the object. For instance the variable given as the argument when calling .new on a class to create an object will be stored as an instance variable and used when calling any other functions defined within the class of that 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.
What I found most enjoyable about creating this program was edging toward a practicle use of ruby to do something. It was good to learn about the rand method and how that can be useful. What I found both enjoyable and challenging was starting to understand what makes code clunky vs streamline and useful. It's a difficult thing to wrap my head around without more experience but I'm beginning to get how classes and objects are going to be vital in this respect.
- screenshots will be posted in comments
- What are your three biggest takeaways from working through this book?
My first and biggest take-away was clarifying the difference between a command that mutates the caller and one that doesn't. Similary, learning about how variables are pointers to values and do not neccessarily behave how you would imagine when assigning and reassigning. Another take away regarding variables was scope. The launch school reading made the concept of when and where a variable is accessible depending on where it was initialized. My last big takeaway was about chaining methods together. In the earlier excecises I was writing method after method on new lines, but the launch school book made it clear that you should consider what the output of every method will be and if the next thing you need to do can utilize that return then just chain it to the end. It makes the code a lot more concise and even readable.
- screenshots will be posted in comments
- What are your two biggest takeaways from working through this tutorial?
Big takeaway number one is that it seems vital to have a full understanding of git because version control is vital and integral to any sort of collaborative code development. Big takeaway number two is that git offers a great deal of redundancy and human error protection so learning to utilize it to its full potential will offer the greatest protection again irreparable data loss.
- What is one question you have about Git & GitHub?
I still don't really understand how pull requests work, but in all fairness that is because I have not really sought out the answer yet. My real questions are really more related to how this workflow goes on larger and smaller scales and how project are organized on github. Mainly a general practicle application curiosity.
- 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?
To me effective workflow is going to be based on solid communication, clear goals and technical proficiency. In terms of shortcuts, learning to be a VS Code power user as well as becoming a master of the terminal including it's interaction with git are of paramount importance to optimizing workflow. I would like to learn more about the practicle interaction of these programs and practice utilizing them in a variety of circumstances to feel most comfortable and thereby increase speed and efficiency.
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?
echo -n "hello"
- 1.4: What do Ctrl-A, Ctrl-E, and Ctrl-U do?
Ctrl -A brings the cursor to the front of the comman line. Ctrl-E brings it to the end. Ctrl-U Clears it.
- 1.5: What are the shortcuts for clearing your screen, and exiting your terminal?
To clear the screen Ctrl-L. To exit terminal Ctrol -D
- 2.1: What is the "cat" command used for? What is the "diff" command used for?
Cat is used both to easily display the contents a file in the terminal as well as add lines from the terminal into files. The diff command is used to display the difference between two files in the terminal.
- 2.2: What command would you use to list all txt files? What command would you use to show all hidden files?
To list all text files "ls *.txt". To show all hidden files "ls -la".
- 3.1: How can you download a file from the internet, using the command line?
utilizing the curl or cURL command
- 3.3: Describe two commands you can use in conjunction with "less".
By typing "/" you can search for a specific string, navigating forward and backward through each occurance with "n" and "N" respectively. "G" and "1G" will take you to the end and beginning of the file respectively.
- 3.4: What are two things you can do with "grep"?
Using grep you can search for specific strings within files, logs, proccesses etc. By piping grep into other commands or using regex as search criteria you can find/count/copy/move/delete all sorts of things with efficiency.
Day 11 Typing and Logic Problems