Skip to content

Instantly share code, notes, and snippets.

@katiekeel
Forked from mbburch/prework.md
Last active April 13, 2017 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katiekeel/1cdb7c8ef563430addf53c08adee3d2c to your computer and use it in GitHub Desktop.
Save katiekeel/1cdb7c8ef563430addf53c08adee3d2c to your computer and use it in GitHub Desktop.
Katie Shermer's Turing pre-work Gist

Day 1:

Task A - Typing

Screenshot below

Task D - Environment Setup

Screenshot below of Terminal installs

Did you run into any issues?

Nope! (I have done all of this before while self-teaching)

How do you open Atom from your Terminal?

  1. $atom to be accessed from the Terminal in Atom settings

  2. $atom touch filename to create a new file; $atom filename to open an existing file

What is the file extension for a Ruby file?

.rb

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

Command-B

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

Command-P

Task E - Command Line

What does pwd stand for, and how is this command helpful?

Print working directory - tells you what directory you're in if Terminal is unclear

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

Hostname shows you the name of your computer within your network. Hostname in my terminal shows Katies-MacBook-Pro.local

Day 2

Task A - Typing

Screenshot below

Task E - Command Line

Screenshots posted below - Codecademy course complete; mkdir, cd, ls sections of Learn Code the Hard Way complete

Task F - Ruby

IRB

How do you start and stop irb?

irb; exit

What might you use irb for?

Testing simple ideas - math operators, basic strings and arrays, etc.

Variables

How do you create a variable?

Just type the name you want, an equals sign, and its value

What did you learn about the rules for naming variables?

You can use all letters, underscores, and numbers between letters in names. All numbers, dashes, and numbers at the start/end don't work.

How do you change the value of a variable?

Type its name again, then reassign it to the new value with =

Datatypes

How can you find out the class of a variable?

Type its name and .class

What are two string methods?

.length and .reverse

How can you change an integer to a string?

.to_s

Strings

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

Double quotes allow you to use string interpolation and the escape sequence

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

String interpolation - you can call a variable in the middle of a string

How would you remove all the vowels from a string?

"string".delete('aeiou')

Input & Output

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

Print prints the output to the terminal as-is; puts gives the output its own new line

What does 'gets' do in Ruby?

Retrieves 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".

Screenshot below

Day 3

Task A - Typing

Screenshot below

Task F - Ruby

Numbers & Arithmetic

What is the difference between integers and floats?

Integers are whole numbers; floats are numbers with decimal points.

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

Screenshot below

Booleans

What do each of the following symbols mean?

==

Checks equality on either side of the operator

=

Takes an item to the left of the operator and assigns it the value to the right of the operator

<=

Less than or equals to

!=

Not equal to

&&

"and" operator - if values on both sides of operator are true, expression evaluates true

||

"or" operator - if a value on either side of the operator is true, expression evalues true. If neither are true, evaluates false

What are two Ruby methods that return booleans?

.include? and .empty?

Conditionals

What is flow control?

Selectively executing code based on values that exist in the program.

What will the following code return?

"Not many apples..."

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

It's created when you write a loop that has no exit or break point - it keeps executing forever. Type CTRL + C to break it.

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

Screenshot below

nil

What is nil?

A special Ruby 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".

Screenshot below

Symbols

How can symbols be beneficial in Ruby?

They allow Ruby variables to point to the same object in many different places, using less memory, which is important for complex programs.

Does naming symbols use the same rules for naming variables?

Variables: You can use all letters, underscores, and numbers between letters in names. All numbers, dashes, and numbers at the start/end don't work.

Symbols: You can use all letters, underscores, numbers at the end, and numbers between letters in names. All numbers, dashes, and numbers at the start don't work.

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

Screenshot below

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 removes the last element from the array

Hashes

Describe some differences between arrays and hashes.

An array is an ordered, indexed list of items; a hash is an ordered list of items that are identified by keys or values

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

An array is ideal for when you need an ordered list of items; a hash is for when you need to call items from a list based on their name.

An array could be used to store ages for a group of people: [6, 17, 84, 33, 19]

A hash could be used to store information about a group of people: {Joan => "mom", Bill => "dad", Frank => "brother"}

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

Screenshot below

Day 4

Task A - Typing

Screenshot below

Task F - Learning Ruby

Loops

Screenshot posted below

Summary: Basics

Screenshot below

Functions

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

Name the variable, the assign it to the function with =

Classes

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

Initialize method creates a new method for you to use on your objects. New method creates a new instance of your object (defined in the Class parameter at the top). Instance variables store data that's only usable by that particular object.

How to Write a Program

I am familiar with creating my own classes and methods through my work in Second Shift. This overview will be helpful for completing the assignments I'm still working on, which involve creating my own classes and methods and using MiniTest to test them.

Launch School: Ruby

The Basics

Screenshot below

Variables

Screenshot below

@katiekeel
Copy link
Author

Completion of my installs in Terminal

terminalinstalls

@katiekeel
Copy link
Author

My first completed typing practice session

typingpractice1

@katiekeel
Copy link
Author

Completion of Codecademy command line course

cmdlinecomplete

@katiekeel
Copy link
Author

Completion of command line mkdir exercise

cmd_line_mkdir

@katiekeel
Copy link
Author

Completion of command line cd exercise

cmd_line_cd

@katiekeel
Copy link
Author

Completion of command line ls exercise

cmd_line_ls

@katiekeel
Copy link
Author

My second completed typing practice

typing_practice_2

@katiekeel
Copy link
Author

I/O program

i o

@katiekeel
Copy link
Author

Third typing practice session

typing_practice_3

@katiekeel
Copy link
Author

Numbers
practice_calculator

@katiekeel
Copy link
Author

Conditionals

conditionals

@katiekeel
Copy link
Author

Symbols

symbols

@katiekeel
Copy link
Author

Hashes

hashes

@katiekeel
Copy link
Author

loops

@katiekeel
Copy link
Author

summary_basics

@katiekeel
Copy link
Author

Launch School's Ruby book: strings exercises

ls_strings

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