Skip to content

Instantly share code, notes, and snippets.

@mariastenquist
Last active November 27, 2016 03:54
Show Gist options
  • Save mariastenquist/c79159fb0c50a630e237c76094ff9a49 to your computer and use it in GitHub Desktop.
Save mariastenquist/c79159fb0c50a630e237c76094ff9a49 to your computer and use it in GitHub Desktop.
Turing BE pre-work MS

Turing School Prework - MS

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: done!

Task D- Set up your Environment:

  • Did you run into any issues? No issues really, I ran into a couple things that were out of date, ran brew update, and then checked the versions for ruby, git, rvm, node, Xcode. I enjoy using Sublime Text, although I did install VS Code.
  • How do you open VS Code from your Terminal? ‘code’. Used Command Palette, shell command.
  • What is the file extension for a Ruby file? .rb
  • What is the VS Code shortcut for hiding/ showing your file tree view? ⌘B
  • What is the VS Code shortcut for quickly finding a file (fuzzy finder)? ⌘P

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? print working directory. To see where you are in your filesystem of folders and files.
  • What does hostname tell you, and what shows up in YOUR terminal when you type hostname? the name/label for a device; local

Task F- Learn Ruby:

Option 1 Questions:

IRB

  • How do you start and stop irb? command line start: 'irb'. stop: 'exit'
  • What might you use irb for? interactive ruby interpreter runs Ruby code in the console. good for short snippets of code. To lear/experiment with certain Ruby features.

Variables

  • How do you create a variable? assign a name (left) = value/evaluation (right).
  • What did you learn about the rules for naming variables? Cannot assign a value to a constant. Not a good idea to name a variable as a constant, or reserved terms that have dual meaning in console; ruby. Lowercase start, an upper-case variable is read as a constant.
  • How do you change the value of a variable? assign a new value (right-side of = ) to the same variable name.

Datatypes

  • How can you find out the class of a variable? Ruby has built-in methods. .class is a method that you can call on a variable. object.class
  • What are two string methods? :chomp, :upcase!
  • How can you change an integer to a string? taking an integer and running the method .to_s | e.g. 8.to_s

Strings

  • Why might you use double quotes instead of single quotes in Ruby? Use double quotes for string interpolation, or having a string within a string. Use single quotes to denote string, inside "".
  • 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? 'puts' prints info. 'print' is similar, but doesn't create a new line after printing.
  • What does 'gets' do in Ruby? 'gets' pauses, waits for user input, retrieves value, continues execution.
  • 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? integer: +/- whole numbers. floats: real numbers with decimals--integer.fractionals
  • 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?
    • == conditional equal (to check if equal, result true/false)
    • = greater than or equal

    • <= less than or equal
    • != not equal to
    • && and, to check more than one condition
    • || or, to check one condition or another
  • What are two Ruby methods that return booleans? .include?, .empty? A question mark at the end of method returns boolean value

Conditionals

  • What is flow control? Wanting programs to make decisions for us in OOP
  • 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? A loop that continues and continues because it hasn't met a condition to make it false, and terminate the loop. cntl + c to exit
  • 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? Symbols have performance benefits where variables point to the same object in more than one place, rather than taking up extra memory by making a new copy of code snippet. Symbols are basic objects that can't be modified. Symbols have both a string and integer representation. We assign labels to symbols to use them as shortcuts to track objects in Ruby.
  • Does naming symbols use the same rules for naming variables? Symbols are constants/immutable. You can name a symbol starting with an Uppercase label, however you cannot name them integers, start with integers, special characters, just like variable naming.
  • 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 (zero)
  • What do 'push' and 'pop' do? add/remove items from an array

Hashes

  • Describe some differences between arrays and hashes. Arrays are a collection of elements where each element is assigned an index (position), which makes locating an element/order of an array easy. Arrays are good for an ordered list of elements. Hashes are good for naming properties (keys) that hold a value. Key:value pairs.
  • What is a case when you might prefer an array? What is a case when you might prefer a hash? You might prefer an array if you have an ordered list where the index/position is important. Hashes are good to act as objects that store properties/attributes and have assigned key/value pairs. Hashes are good for large pieces of data that are relatable.
    • 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?
  • 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? Coding!
  • What questions do you have for your student mentor or for your instructors?

Notes-

  • make sure to save comment as jpg or png file.
@mariastenquist
Copy link
Author

Task E, day two: cd
screen shot 2016-11-22 at 10 31 53 pm

@mariastenquist
Copy link
Author

task E, day two: ls
screen shot 2016-11-22 at 10 36 53 pm

@mariastenquist
Copy link
Author

Task F, I/O
i o

@mariastenquist
Copy link
Author

Task F: Numbers!
screen shot 2016-11-25 at 1 16 38 pm

@mariastenquist
Copy link
Author

Task F: Conditionals
screen shot 2016-11-25 at 1 29 01 pm

@mariastenquist
Copy link
Author

Task F: nil
What is going on here? Variable name is set equal to nil, previously in the exercise: a conditional was set word == nil. So word = nil, and name = nil. Below, name equals nil, and an if/else statement is run to output "name hasn't been set yet" if name = nil. If any other other variable label is set = nil, else executes and output is "Your name is #{insert variable name}"

name = nil
if name.nil?
puts "The name hasn't been set yet."
else
puts "Your name is #{name}"
end
screen shot 2016-11-26 at 7 12 16 pm

@mariastenquist
Copy link
Author

Task F: Symbols
screen shot 2016-11-26 at 8 18 14 pm

@mariastenquist
Copy link
Author

Task F: arrays
screen shot 2016-11-26 at 8 36 01 pm

@mariastenquist
Copy link
Author

Task F: hashes
screen shot 2016-11-26 at 8 47 18 pm

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