Skip to content

Instantly share code, notes, and snippets.

@limsammy
Forked from mbburch/prework.md
Last active March 10, 2017 22:44
Show Gist options
  • Save limsammy/96d5f0d8683c95ae350c70e2dcb4ae37 to your computer and use it in GitHub Desktop.
Save limsammy/96d5f0d8683c95ae350c70e2dcb4ae37 to your computer and use it in GitHub Desktop.
My pre-work gist, forked from existing template.

Turing School Prework - Sam Lim

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?

I did not.

  • How do you open Atom from your Terminal?

By using the command "atom" followed by a file or folder name.

  • What is the file extension for a Ruby file?

.rb

  • What is the Atom shortcut for hiding/ showing your file tree view?

cmd-k

  • What is the Atom shortcut for quickly finding a file (fuzzy finder)?

cmd-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" and prints the path of what directory you are currently in to the terminal

  • What does hostname tell you, and what shows up in YOUR terminal when you type hostname?

The hostname is the label of your machine. My hostname is "Sams-MacBook-Pro.local"

Task F- Learn Ruby:

Option 1 Questions:

IRB

  • How do you start and stop irb?

start irb by executing the command "irb," exit irb by executing the command "exit"

  • What might you use irb for?

experimenting with short pieces of code

Variables

  • How do you create a variable?

You can assign a value to a variable with the assignment operator "="

  • What did you learn about the rules for naming variables?

Names must start with an underscore or lower case letter followed by name characters

  • How do you change the value of a variable?

By reassigning the variable to a different value (see: assignment operator) or by using a function like "upcase"

Datatypes

  • How can you find out the class of a variable?

By appending input with the function ".class". this will output the class of the variable.

  • What are two string methods?

:inspect, :length

  • How can you change an integer to a string?

Append the integer with a "to_s" conversion method. For example, 5.to_s => '5'

Strings

  • Why might you use double quotes instead of single quotes in Ruby?

Use double quotes for string interpolation.

  • What is this used for in Ruby: #{}?

String interpolation, it allows you to embed ruby statements in other strings.

  • How would you remove all the vowels from a string?

By using the "delete" string method with "aeiou" (vowels) as the parameter.

Input & Output

  • What do 'print' and 'puts' do in Ruby?

'print' prints information to the terminal WITHOUT making a new line. 'puts' does the same but creates a new line.

  • What does 'gets' do in Ruby?

'gets' receives user input.

  • Add a screenshot in the comments of the program you created that uses 'puts' and 'gets', and give it the title, "I/O".

See comment

Numbers & Arithmetic

  • What is the difference between integers and floats?

An integer does not have a decimal point. A float has a decimal point and is much more precise.

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

See comment

Booleans

  • What do each of the following symbols mean?

    • ==

    Is equal to

    • =

    Greater than or equal to

    • <=

    Less than or equal to

    • !=

    Not equal to

    • &&

    And

    • ||

    Or

  • What are two Ruby methods that return booleans?

'empty?' and 'include?()'

Conditionals

  • What is flow control?

Flow control is the concept of our program making decisions for us based on predetermined logic.

  • What will the following code return?
apple_count = 4

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

This code will return the string 'Not many apples...'

  • What is an infinite loop, and how can you get out of one?

An infinite loop is a loop that runs forever. To get out of one, the while condition must change to false.

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

See comment

nil

  • What is nil?

nil is Ruby's object for 'empty' or 'null'

  • Take a screenshot of your terminal after working through Step 4, and post it in the comments with the title, "nil".

see comment

Symbols

  • How can symbols be beneficial in Ruby?

They are useful labels for different types of data.

  • Does naming symbols use the same rules for naming variables?

Naming symbols requires a colon in front of the symbol.

  • Take a screenshot of your terminal after working through Step 4, and post it in the comments with the title, "Symbols".

see comment

Arrays

  • What method can you call to find out how many elements are in an array?

the 'length' method

  • 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 removes the last element of an array and returns it.

Hashes

  • Describe some differences between arrays and hashes.

Arrays are lists holding elements which are accessed by the index of the element. Hashes hold keys that point towards elements.

  • What is a case when you might prefer an array? What is a case when you might prefer a hash?

Arrays can be used for sets of data (i.e. a list) that are accessed by INDEX. With hashes you can label the indices, very useful for large sets of RELATED data.

    • Take a screenshot of your terminal after working through Step 2, and post it in the comments with the title, "Hashes".

see comment

Task G- Prework Reflection:

  • Were you able to get through the work? Did you rush to finish, or take your time?

Yes, I was able to get through the work. I did not rush to finish, but I do have prior programming experience.

  • What are you most looking forward to learning more about?

Some of the Brilliant.org quizzes I was faced with had to do with logic schematics. I would like to learn more about this, for example the various forms logic gates can take (visual, algebraic/boolean, truth tables).

  • What topics would you most like to see reinforced by instructors?

Implementing hashes alongside arrays and other more complicated programs.

  • What is most confusing to you about what you've learned?

Logic gates. I do not have any prior experience with visualizing logic that way.

  • What questions do you have for your student mentor or for your instructors?

None.

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.

see comments

  • What challenges did you try for "Summary: Basics"? Post a screenshot of one of your programs.

see comments (all challenges completed)

  • Functions: How do you call a function and store the result in a variable?

You can call a function by saying the name you gave the function followed by the paramaters needed. To store it in a variable simply set the variable to your function.

  • Describe the purpose of the following in Ruby classes: initialize method, new method, instance variables.

The initialize method sets up your object with any prerequired data. The new method creates a new instance of your predefined object passing any data through the init method. Instance variables are variables only accessible within your 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 find most challenging about these concepts is breaking up our logic into smaller pieces (multiple functions), and then using these functions as paramaters for others (see: generate_die_roll method in roll function). What I found most enjoyable are the OOP concepts we learned, creating objects with ".new" from an outlined sample defined in our class and init method

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?

by adding the -n option. this tells echo not to print the trailing newline.

  • 1.4: What do Ctrl-A, Ctrl-E, and Ctrl-U do?

Ctrl-A: goes to beginning of cmd prompt. Ctrl-E: moves to end of line. Ctrl-U clears the line, starts over.

  • 1.5: What are the shortcuts for clearing your screen, and exiting your terminal?

"clear" will clear your screen and exit will terminate the terminal.

  • 2.1: What is the "cat" command used for? What is the "diff" command used for?

cat outputs the contents of a file to the terminal. the diff command will compare two files

  • 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 txt files, use "ls *txt". to show all hidden files, use the All flag: "ls -a"

  • 3.1: How can you download a file from the internet, using the command line?

curl with given paramaters and internet link

  • 3.3: Describe two commands you can use in conjunction with "less".

with the less function, one command you can use is "G" to move to the end, and ^F to move forward a page.

  • 3.4: What are two things you can do with "grep"?

Grep searches through a file. You can look for a specific substring and by using -i you can search for case-insensitive strings.

@limsammy
Copy link
Author

limsammy commented Feb 7, 2017

Task D - Versions

screen shot 2017-02-07 at 10 32 45 am

@limsammy
Copy link
Author

limsammy commented Feb 7, 2017

Task A - Typing practice

screen shot 2017-02-07 at 10 58 15 am

Task B - Algorithmic thinking & logic

screen shot 2017-02-07 at 11 06 02 am

@limsammy
Copy link
Author

limsammy commented Feb 8, 2017

Day Two Task E:

screen shot 2017-02-08 at 1 39 31 pm

screen shot 2017-02-08 at 1 42 56 pm

screen shot 2017-02-08 at 1 43 34 pm

@limsammy
Copy link
Author

limsammy commented Feb 8, 2017

Day Two - Task F

Sections completed: What is Ruby, Command Line, irb, Running programs from a file, Variables, Datatypes, Strings, Input And Output

@limsammy
Copy link
Author

limsammy commented Feb 9, 2017

Day Two - Daily Tasks

A - Typing practice

screen shot 2017-02-09 at 12 05 23 am

B - Algorithmic thinking and logic

screen shot 2017-02-09 at 12 57 21 am

@limsammy
Copy link
Author

limsammy commented Feb 9, 2017

Day Three - Daily Tasks

A - Typing practice:

screen shot 2017-02-09 at 5 16 45 am

B - Brilliant.org Quiz:

screen shot 2017-02-09 at 5 29 35 am

@limsammy
Copy link
Author

limsammy commented Feb 9, 2017

Day Three Task F

Ruby Sections Completed: Numbers And Arithmetic, Booleans, Conditionals, nil, Symbols, Arrays

@limsammy
Copy link
Author

limsammy commented Feb 9, 2017

Numbers Program

screen shot 2017-02-09 at 6 00 38 am

@limsammy
Copy link
Author

limsammy commented Feb 9, 2017

Conditionals Program

screen shot 2017-02-09 at 6 34 25 am

@limsammy
Copy link
Author

limsammy commented Feb 9, 2017

nil

screen shot 2017-02-09 at 6 39 21 am

@limsammy
Copy link
Author

limsammy commented Feb 9, 2017

Symbols

screen shot 2017-02-09 at 9 19 11 am

@limsammy
Copy link
Author

limsammy commented Feb 9, 2017

Hashes

screen shot 2017-02-09 at 9 33 59 am

@limsammy
Copy link
Author

limsammy commented Feb 13, 2017

Loops Challenge Program #1

screen shot 2017-02-13 at 1 06 30 am

Loops Challenge #2

screen shot 2017-02-13 at 1 11 55 am

@limsammy
Copy link
Author

Summary: Basics Programs

screen shot 2017-02-13 at 1 27 04 am

screen shot 2017-02-13 at 1 27 10 am

screen shot 2017-02-13 at 1 27 13 am

screen shot 2017-02-13 at 1 27 15 am

screen shot 2017-02-13 at 1 27 18 am

@limsammy
Copy link
Author

TODO: Screenhero w mentor RE roller.rb

@limsammy
Copy link
Author

Preparations Exercise

screen shot 2017-02-13 at 2 14 24 am

@limsammy
Copy link
Author

limsammy commented Feb 13, 2017

The Basics Exercises

screen shot 2017-02-13 at 5 33 08 am

screen shot 2017-02-13 at 5 36 41 am

screen shot 2017-02-13 at 5 45 15 am

screen shot 2017-02-13 at 5 48 17 am

screen shot 2017-02-13 at 5 50 41 am

screen shot 2017-02-13 at 5 55 33 am

  1. This error tells me that on line 2 there is a syntax error, a closing parenthesis was used when a curly brace was expected.

@limsammy
Copy link
Author

Variables Exercises

screen shot 2017-02-13 at 6 04 24 am

screen shot 2017-02-13 at 6 07 08 am

screen shot 2017-02-13 at 6 08 51 am

screen shot 2017-02-13 at 6 14 36 am

  1. In the first code example, x prints 3 to the terminal. However in the second example the variable x is only defined in the inner scope of the do statement so when the code tries to print x to the terminal in the outer scope it gives us an undefined variable error.

  2. Line 3 of the program tries to access a variable called "shoes." This is either a local variable or has not even been defined.

@limsammy
Copy link
Author

Methods Exercises

screen shot 2017-02-13 at 6 35 02 am

screen shot 2017-02-13 at 6 37 47 am

screen shot 2017-02-13 at 6 39 10 am

  1. Nothing is printed to the terminal.

screen shot 2017-02-13 at 6 41 32 am

  1. For the codeblock defined by the method "calculate_product" the wrong number of arguments are passed.

@limsammy
Copy link
Author

limsammy commented Feb 13, 2017

Flow Control Exercises

screen shot 2017-02-13 at 6 47 06 am

screen shot 2017-02-13 at 6 52 42 am

screen shot 2017-02-13 at 7 00 25 am

screen shot 2017-02-13 at 7 04 15 am

screen shot 2017-02-13 at 7 38 36 am

  1. By adding an "end" statement to the end of the conditional code block.

@limsammy
Copy link
Author

limsammy commented Feb 14, 2017

Loops in Ruby

screen shot 2017-02-13 at 11 49 53 pm

screen shot 2017-02-21 at 8 20 10 pm

screen shot 2017-02-21 at 8 25 10 pm

screen shot 2017-02-21 at 8 28 20 pm

@limsammy
Copy link
Author

Encryptor github exercise: https://github.com/limsammy/encryptor.rb

@limsammy
Copy link
Author

screen shot 2017-02-21 at 8 15 04 pm

@limsammy
Copy link
Author

limsammy commented Feb 22, 2017

Arrays in ruby:

screen shot 2017-02-21 at 10 01 55 pm

  1. returns 1
    arr = [["b"], ["b", 2], ["b", 3], ["a", 1], ["a", 2], ["a", 3]]
  2. returns [1, 2, 3]
    arr = [["b"], ["a", [1, 2, 3]]]

arr.last.first

screen shot 2017-02-21 at 11 39 09 pm

screen shot 2017-02-21 at 11 40 50 pm

  1. Arrays are indexed by integer, not strings.

screen shot 2017-02-21 at 11 43 18 pm

screen shot 2017-02-21 at 11 48 25 pm

@limsammy
Copy link
Author

limsammy commented Feb 22, 2017

Hashes in ruby:

screen shot 2017-02-22 at 12 03 38 am

screen shot 2017-02-22 at 12 08 18 am

screen shot 2017-02-25 at 5 50 57 am

  1. By using the looking up the :name symbol with brackets.

  2. has_value? returns true or false if the value is present.

@limsammy
Copy link
Author

Final Prework Guessing Game Application: https://github.com/limsammy/guessing_game

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