Skip to content

Instantly share code, notes, and snippets.

@maxglassie
Forked from mbburch/prework.md
Last active November 27, 2016 22:27
Show Gist options
  • Save maxglassie/6440040078d980df719fe5039399ff6d to your computer and use it in GitHub Desktop.
Save maxglassie/6440040078d980df719fe5039399ff6d to your computer and use it in GitHub Desktop.
Pre-Work Gist

Turing School Prework - Max Glassie

Task A- Practice Typing:

  • screenshots of scores will be posted in comments

Task B- Algorithmic Thinking & Logic:

  • screenshots of completed sections will be posted in comments

Task C- Create your Gist:

Task D- Set up your Environment:

  • Did you run into any issues?

Yes, there was a problem updating homebrew. I already had it on my laptop, but it didn't have the latest version. An update to macOSX made it so homebrew didn't have ownership of the root folder for my user. I got the following error: "Warning: /usr/local/include isn't writable." I searched around on stackoverflow and read about varying solutions for this problem. Eventually, after looking up and reading about each command in the following, I settled on "sudo chown -R $(whoami) /usr/local" which fixed the problem. There were a few other weird things that popped in the homebrew doctor (they've updated it to pop with potential issues, which may not cause problems but will help brew support troubleshoot if there is a problem). Figuring out what the key issue was and also deciding what NOT to do was important, since there were some rabbit holes. It took me an hour+ to troubleshoot.

  • How do you open VS Code from your Terminal? The tutorial asks us to use Visual Studio Code as our text editor. I found this resource http://osxdaily.com/2007/02/01/how-to-launch-gui-applications-from-the-terminal/ and learned to open it with this command "open -a Visual\ Studio\ Code"

  • What is the file extension for a Ruby file? .rb

  • What is the VS Code shortcut for hiding/ showing your file tree view? Command + Shift + E

  • What is the VS Code shortcut for quickly finding a file (fuzzy finder)? Shift + Command + F for finding within a file. Control + Shift + Tab for cylcing through the last set of files opened. (https://code.visualstudio.com/docs/editor/codebasics)

Task E- The Command Line:

  • 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" - or "print working directory" - it helps you figure out which directory you're in, which isn't always obvious, since you can't see it in a GUI.

  • What does hostname tell you, and what shows up in YOUR terminal when you type hostname? It's the name of my computer network. Mine is Max-Glassies-MacBook-Pro.local

Task F- Learn Ruby:

Option 1 Questions:

IRB

  • How do you start and stop irb? type irb into terminal. type 'quit' to quit or 'exit'
  • What might you use irb for? testing small pieces of code in the command line, while working on a bigger problem. it's instant feedback!

Variables

  • How do you create a variable? variable_name = variable_value
  • What did you learn about the rules for naming variables? no dashes '-', can't do all numbers, can't start with numbers,
  • How do you change the value of a variable? just type in the same formula again, but with a different value. ex = 10, ex = 11

Datatypes

  • How can you find out the class of a variable? call the method 'class' on the given object
  • What are two string methods? slice, upcase
  • How can you change an integer to a string? to_s

Strings

  • Why might you use double quotes instead of single quotes in Ruby? if you want to use interpolation #{} to add a variable's value to a string. it doesn't work with single quotes - it just prints literally, ex: "Hello #{name}"
  • What is this used for in Ruby: #{}? interpolation
  • How would you remove all the vowels from a string? "What, no vowels?!".delete("aieou")

Input & Output

  • What do 'print' and 'puts' do in Ruby? Very interesting: "The method puts always has the return value of nil, which is what we see after the => in the output. Printing 'Hello World' to the screen is just a side-effect."

puts prints the output to the user. each puts creates its own line. print is like puts but doesn't create a new line for each.

  • What does 'gets' do in Ruby? gets pauses the program and waits for the user to type something and hit the enter button. it will return whatever the user types.

  • 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? integers do not have decimal points and floats do. On a deeper level, the float that is displayed is not equal to the representation in the hardware, so over many iterations the numbers will not align, so it's almost always better to use integers.

  • Complete the challenge, and post a screenshot of your program in the comments with the title, "Numbers". see below.

Booleans

  • What do each of the following symbols mean?
    • == (equals)
    • = (greater than or equal to)

    • <= (less than or equal to)
    • != (not equal to)
    • && (this and that evaluate to true)
    • || (either this OR that evaluate to true)
  • What are two Ruby methods that return booleans? by convention predicate methods end with '?' two examples are end_with? and include?

Conditionals

  • What is flow control? a case that determines how the procedure executes based on a given predicate or list of predicates.

  • What will the following code return?

apple_count = 4

if apple_count > 5
  puts "Lots of apples!"
else
  puts 'Not many apples...'
end

'Not many apples...'

  • What is an infinite loop, and how can you get out of one? if the loop doesn't specify a conditional statement that causes the procedure to stop, then it will continue infinitely. you can quit out of an infinite loop in terminal by hitting ctrl + c

  • Take a screenshot of your program and terminal showing two different outputs, and post it in the comments with the title, "Conditionals". see below

nil

  • What is nil? nil is a special data type that means "nothing"
  • Take a screenshot of your terminal after working through Step 4, and post it in the comments with the title, "nil". see below

Symbols

  • How can symbols be beneficial in Ruby? symbols are immutable vs. string are mutable data types in Ruby. mutability is useful but can also be pretty messy. symbols help prevent that messiness, as well as making sure that those data are constant throughout a program. symbols immutability also means that it is more efficient, given that each symbol has it's own place in the memory.

  • Does naming symbols use the same rules for naming variables? No. Symbols are constants, so they cannot be assigned a value. Assigning a symbol to a variable is the same, however (ex: today = :Friday)

  • 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? .length
  • What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]? 0
  • What do 'push' and 'pop' do? push adds an element to the end of an array. pop "pops" the element off of the end of an array.

Hashes

  • Describe some differences between arrays and hashes. arrays are accessed by an index (a number) whereas hashes are accessed by their key.
  • What is a case when you might prefer an array? What is a case when you might prefer a hash? arrays are better for ordered items, whereas hashes are better for non-ordered items. hashes are often used to store the properties of some object
    • Take a screenshot of your terminal after working through Step 2, and post it in the comments with the title, "Hashes".

Task G- Prework Reflection:

  • Were you able to get through the work? Did you rush to finish, or take your time? I was able to get through the work. I took my time, juggling the move out to Denver and finishing up some client work. There was a bit of a rush to complete everything at the end, before the program start (today is Nov. 27). But I wasn't uncomfortable with the material.

  • What are you most looking forward to learning more about? Object-oriented programming, how to interface with the database, data structures and their corresponding algorithms, and internet protocols. I'm also interested in learning more about key design patterns in Ruby. I'm looking forward to learning more about Git.

  • What topics would you most like to see reinforced by instructors? I'm not sure, really. I'm hoping there's ample discussion of theory.

  • What is most confusing to you about what you've learned? Initially, I was pretty confused by the block structure; I'm getting more comfortable with it now. I'm also confused by attribute accessor and the way that Ruby stores variables in objects... the code syntax doesn't completely make sense to me.

  • What questions do you have for your student mentor or for your instructors? I don't have questions now. I'm just excited to get started and to be immersed in coding.

@maxglassie
Copy link
Author

conditionals script
screen shot 2016-11-21 at 12 52 05
results
screen shot 2016-11-21 at 12 52 37

@maxglassie
Copy link
Author

nil
screen shot 2016-11-21 at 13 02 02

@maxglassie
Copy link
Author

maxglassie commented Nov 21, 2016

symbols object_id
screen shot 2016-11-21 at 13 20 57
screen shot 2016-11-21 at 13 23 56

@maxglassie
Copy link
Author

maxglassie commented Nov 26, 2016

Brilliant
screen shot 2016-11-26 at 15 32 49

screen shot 2016-11-26 at 15 39 18

@maxglassie
Copy link
Author

Hashes
screen shot 2016-11-26 at 16 02 23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment