Skip to content

Instantly share code, notes, and snippets.

@JonathanSR
Forked from mbburch/prework.md
Last active November 26, 2016 23:04
Show Gist options
  • Save JonathanSR/5ec9711f4e2e83c3025a43bd22af46f5 to your computer and use it in GitHub Desktop.
Save JonathanSR/5ec9711f4e2e83c3025a43bd22af46f5 to your computer and use it in GitHub Desktop.
An example template for your Turing pre-work Gist

Turing School Prework - Jonathan Serrano

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? No issues at all.
  • How do you open Atom from your Terminal? I installed VS code and I can open it from the termianl by tyiping "code" in it.
  • What is the file extension for a Ruby file? The file extension for a Ruby file is .rb
  • What is the Atom shortcut for hiding/ showing your file tree view? The shortcut is, command B.
  • What is the Atom shortcut for quickly finding a file (fuzzy finder)? The shortcut is, command 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? pwd stands for "print working directory." It's helpful by showing you where in the filesystem you are.
  • What does hostname tell you, and what shows up in YOUR terminal when you type hostname? The hostname tells me the current host and domain of my computer. "local" shows up in my terminal.

Task F- Learn Ruby:

Option 1 Questions:

IRB

  • How do you start and stop irb? To start irb in the command line you type "irb." To stop irb you type "exit."
  • What might you use irb for? Irb might be use to experiment with the program, to figure out how certain language features work.

Variables

  • How do you create a variable? To create a variable you must assign it a value.
  • What did you learn about the rules for naming variables? You cannot start a variable with a number or have a dash in it.
  • How do you change the value of a variable? Assign a new value.

Datatypes

  • How can you find out the class of a variable? By typing .class after the variable.
  • What are two string methods? Two string methods are string unpack and encode.
  • How can you change an integer to a string? To change an integer into a string type the string followed by .to_s.

Strings

  • Why might you use double quotes instead of single quotes in Ruby? I would use double quotes when working with string interpolation as it wont work with single quotes.
  • What is this used for in Ruby: #{}? #{} in Ruby is used to embed a statement into another string.
  • How would you remove all the vowels from a string? I would use .delete('aeiou') following the string to delete all the vowels.

Input & Output

  • What do 'print' and 'puts' do in Ruby? 'Print' prints out information to the user. 'Puts' prints out information to the user but prints out 'nil' as well.
  • What does 'gets' do in Ruby? 'Gets' pauses the program, waits for user input, returns the value to the program and 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? Integers are whole numbers while floats are decimals.
  • 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?
    • == means equal to
    • = means greater than or equal to

    • <= means less than or equal to
    • != means not true
    • && means and
    • || means or
  • What are two Ruby methods that return booleans? Two Ruby methods that return booleans are .end_with and .include.

Conditionals

  • What is flow control? Flow control is a way of selectively executing code with values that exist in the program.
  • What will the following code return?
apple_count = 4

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

The above code will return the string, "Not many apples..."

  • What is an infinite loop, and how can you get out of one? An infinite loop runs forever and to get out of it you press 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 a special Ruby datatype that means nothing.
  • 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 are beneficial as they allow Ruby variables to point to the same object in several places as opposed to creating a new copy. Therefore using up less memory and allowing the program to run more efficiently.
  • Does naming symbols use the same rules for naming variables? It seems like naming symbols has the same rules as naming variables which is that the symbol cannot start with a number and it cannot contain a dash.
  • 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? To find out how many elements are in an array we use the "length" method.
  • What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]? The index of "pizza in this array is [0].
  • What do 'push' and 'pop' do? Push adds an element to the end of that array while pop removes and returns the final element of that array.

Hashes

  • Describe some differences between arrays and hashes. Elements in arrays are accessed by an index, in hashes they are accessed by a key. Arrays are useful for storing ordered lists, hashes are useful for storing properties of objects. Arrays are created with [], hashes are created with {}.

  • What is a case when you might prefer an array? What is a case when you might prefer a hash? If i was making a shopping list I would use an array. If I was creating a list of what car to buy with make, model, year wtc I would use a hash.

    • 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?
  • What questions do you have for your student mentor or for your instructors?

Pre-work Tasks- One Month Schedule

(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.)

Railsbridge Curriculum, cont.

  • 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. I tried all five challenges from "Summary:Basics" and the screenshots are posted in the comment section.
  • Functions: How do you call a function and store the result in a variable? To call a function we type the name of the function then send in the values that we want for it. To store it in a variable we name a variable and set it equal to the function that is to be called.
  • Describe the purpose of the following in Ruby classes: initialize method, new method, instance variables. Initialize method: Saves the initial data the object is created with and performs any other required setup. New method: Is an instance that is created of the object, where arguments are passed to the Initialize Method. Instance Variables: Store data from the object, that start with an @ sign.
  • 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.

Launch School Ruby Book

  • screenshots will be posted in comments
  • What are your three biggest takeaways from working through this book?

CodeSchool

  • 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?

Workflow Video

  • 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?

Michael Hartl's Command Line Book

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"?
@JonathanSR
Copy link
Author

Task F
"Symbols" screenshots
screen shot 2016-10-23 at 5 44 19 pm

screen shot 2016-10-23 at 5 44 25 pm

@JonathanSR
Copy link
Author

Task F
Hashes screenshot

screen shot 2016-10-23 at 6 34 50 pm

@JonathanSR
Copy link
Author

Task A
Typing Practice Screenshots

screen shot 2016-10-23 at 2 37 51 pm

screen shot 2016-10-23 at 2 42 00 pm

@JonathanSR
Copy link
Author

Priority Task 1
Loops Challenge Screenshots

screen shot 2016-10-30 at 12 58 27 pm

screen shot 2016-10-30 at 1 31 07 pm

@JonathanSR
Copy link
Author

Priority 1
Summary Basics Challenge Screenshots

screen shot 2016-10-30 at 1 49 37 pm

screen shot 2016-10-30 at 7 57 15 pm

screen shot 2016-11-01 at 7 01 13 pm

screen shot 2016-11-01 at 7 13 53 pm

screen shot 2016-11-01 at 7 24 20 pm

@JonathanSR
Copy link
Author

Priority 2
The Basics exercises screenshots

screen shot 2016-11-12 at 9 28 06 pm

screen shot 2016-11-12 at 9 28 16 pm

@JonathanSR
Copy link
Author

Priority 2
What is a Variable exercises screenshots and questions at the end.

Exercise 1
screen shot 2016-11-13 at 4 26 56 pm

Exercise 2
screen shot 2016-11-13 at 4 27 30 pm

Exercise 3
screen shot 2016-11-13 at 4 29 24 pm

Exercise 4
screen shot 2016-11-13 at 4 40 23 pm

Exercise/Question 5
The first program will print having x = 3.
The second program will print out and error since x was defined in a n inner scope first then it was tried to be accessed outside of that scope.

Exercise/Question 6
The error message is telling us that it's looking for a variable 'shoes' that has not been defined.

@JonathanSR
Copy link
Author

Priority 2
Methods

Exercise 1
screen shot 2016-11-20 at 1 31 32 pm

Exercise 2
x = 2 evaluates to 2.
puts x = 2 evaluates to nil.
p name = 'Joe' evaluates to Joe.
four = "four" evaluates to four.
print something = "nothing" evaluates to nil.

Exercise 3
screen shot 2016-11-20 at 1 39 29 pm

Exercise 4
The code given will not return anything.

Exercise 5
After modifying the code, it returns, Yippeee!!!!.

Exercise 6
The error message means that the method being called requires two inputs and only 1 was given, therefore missing the 2nd one.

@JonathanSR
Copy link
Author

Priority 2
Flow Control
Exercise 1

  1. (32 * 4) >= 129, returns false
  2. false != !true, returns false
  3. true == 4, returns false
  4. false == (847 == '874'), returns true
  5. (!true || (!(100 / 5) == 20) || ((328 / 4) == 82)) || false, returns true

Exercise 2
screen shot 2016-11-20 at 8 04 34 pm

Exercise 3
screen shot 2016-11-21 at 6 56 22 am

Exercise 4

  1. '4' == 4 ? puts("TRUE") : puts("FALSE")
    This will print out FALSE.

  2. x = 2
    if ((x * 3) / 2) == (4 + 4 - x - 3)
    puts "Did you get it right?"
    else
    puts "Did you?"
    end
    This will print out "Did you get it right?"

3.y = 9
x = 10
if (x + 1) <= (y)
puts "Alright."
elsif (x + 1) >= (y)
puts "Alright now!"
elsif (y + 1) == x
puts "ALRIGHT NOW!"
else
puts "Alrighty!"
end
This will print out "Alright now!"

Exercise 5
screen shot 2016-11-21 at 7 47 34 am

Exercise 6
The error message is letting us know that we are missing an "end" to close of the method.

@JonathanSR
Copy link
Author

Priority 2
Loops & Iterators

Exercise 1
x = [1, 2, 3, 4, 5]
x.each do |a|
a + 1
end

  • This will print out [1, 2, 3, 4, 5]

Exercise 2
screen shot 2016-11-22 at 1 38 25 pm

Exercise 3
screen shot 2016-11-22 at 1 47 53 pm

Exercise 4
screen shot 2016-11-22 at 1 54 51 pm

@JonathanSR
Copy link
Author

JonathanSR commented Nov 23, 2016

Priority 2
Arrays

Exercise 1
screen shot 2016-11-22 at 3 37 42 pm

Exercise 2

  1. arr = ["b", "a"]
    arr = arr.product(Array(1..3))
    arr.first.delete(arr.first.last)
    This will return "1" and the new value of the arr is "[["b"], ["b", 2], ["b", 3], ["a", 1], ["a", 2], ["a", 3]]."

  2. arr = ["b", "a"]
    arr = arr.product([Array(1..3)])
    arr.first.delete(arr.first.last)
    This will return "[1, 2, 3,] and the new value of the ar is "[["b"], ["a", [1, 2, 3]]].

Exercise 3
arr = [["test", "hello", "world"],["example", "mem"]]
To print out "example" from the above array we would call it with, "arr.last[0]"

Exercise 4
arr = [15, 7, 18, 5, 12, 8, 5, 1]

  1. arr.index(5) returns 3.
  2. arr.index[5] returns error Enumerator.
  3. arr[5] returns 8

Exercise 5
string = "Welcome to America!"
The value of a =string[6] = "e".
The value of b=string[11] = "A'
The value of c=string[19] = "nil'

Exercise 6
The error message is letting us know that we are trying to replace an item in array with a string. To correct way to modify it is "names[3] = 'jody'."

Exercise 7
screen shot 2016-11-23 at 12 33 18 pm

@JonathanSR
Copy link
Author

Priority 2
Hashes

Exercise 1
screen shot 2016-11-25 at 2 33 44 pm

Exercise 2
The difference between "merge" and "merge!" is that "merge" creates a new hash entirely and does not modify the hashes being used. In contrast "merge1" modifies the first hash being used with the "merge!" function.

screen shot 2016-11-25 at 2 52 41 pm

Exercise 3
screen shot 2016-11-25 at 3 00 22 pm

Exercise 4
person = {name: 'Bob', occupation: 'web developer', hobbies: 'painting'}
Using the above hash, to access the name of the person I would use, "person.fetch(:name)."

Exercise 5
To find out if a hash has a specific value I would use the "has_value?" method.
screen shot 2016-11-25 at 3 18 22 pm

Exercise 6
screen shot 2016-11-26 at 2 20 15 pm

Exercise 7
x = "hi there"
my_hash = {x: "some value"}
my_hash2 = {x => "some value"}
The first hash has x assigned as its value, while the second hash has the string assigned to x as its value.

Exercise 8
NoMethodError: undefined method `keys' for Array
The above error is letting us know that we don't have a method called 'keys' for arrays.

@JonathanSR
Copy link
Author

Priority 3
Learn How to Use Git & Github
screen shot 2016-11-26 at 4 03 49 pm

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