Skip to content

Instantly share code, notes, and snippets.

@corneliusellen
Last active November 28, 2017 14:02
Show Gist options
  • Save corneliusellen/f5c2c59b2ddb684722c104dcae3c108c to your computer and use it in GitHub Desktop.
Save corneliusellen/f5c2c59b2ddb684722c104dcae3c108c to your computer and use it in GitHub Desktop.
Turing School Prework, Cohort 1711, Ellen Cornelius

Ellen's Prework, Cohort 1711

Daily Warm-Ups

Typing:

Day 1:

Day 1 Result

Day 2:

Day 2 Result

Day 3:

Day 3 Result

Day 4:

Day 4 Result

Day 5:

Day 5 Result

Day 6:

Day 6 Result

Day 7:

Day 7 Result

Day 8:

Day 8 Result

Day 9:

Day 9 Result

Algorithmic Thinking & Logic:

alt text

Day 1 Questions

  1. Did you run into any issues? Yes, I ran into a few installation issues right at the start. I could not install XCode becasue I had not updated my Mac (this took almost 3 hours to update!). Then, I could not install Git, rbenv, and Ruby in my terminal. The error message kept popping up saying "Error: Could not create /usr/local/Cellar Check you have permission to write to /usr/local". I then inserted "sudo" in front of my installation commands, which my termial then prompted me for my Mac password. After that it read "Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system." After much time of trying different fixes, I uninstalled Homebrew and then re-installed it, as well as entered "echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile (new line) source ~/.bash_profile". Then it worked.
  2. How do you open Atom from your Terminal? Type in "atom"
  3. What is the file extension for a Ruby file? .rb
  4. What is the Atom shortcut for hiding/ showing your file tree view? ?
  5. What is the Atom shortcut for quickly finding a file (fuzzy finder)? Shift + Command + f
  6. What does pwd stand for, and how is this command helpful? It stands for "print working directory" and it indicates (or prints) where you are in your current directory
  7. What does ls do? What about cd and mkdir? ls lists the files/directories in the current directory and mkdir creates a new directory (aka folder)
  8. What does hostname tell you, and what shows up in YOUR terminal when you type hostname? host name tells you the name of the machine you're working on. My is "Ellens-MacBook-Air.local"
  9. Type the following commands into your Terminal to ensure you have Ruby, rbenv and Git installed. Take a screenshot that shows the versions of each of these, and post it as a comment in your Gist: Screenshot

Day 2 Questions

  1. What command is entered into the command line to enter an 'irb' session? enter "irb" and "exit" to exit
  2. What is the expression used to express a number squared? enter "Math.sqrt(number)"

  1. What is the ruby command used to output something to the terminal? I'm not sure on this one, I know "cat" outputs the contents of a file to the terminal, but is that a Ruby command? I know "puts" is a Ruby command and also outputs something to the terminal
  2. How is a ruby file run from the command line? enter into the command line "ruby" followed by the file name (you must be in the working directory to do so), such as "ruby ex1.rb"
  3. If a # is at the beginning of a ruby line in Atom, what does that indicate? This indicates a comment. It is ignored by ruby when outputting
  4. What will "turing".length return? 6

Day 3 Questions

  • What is a Pomodoro Break? The Pomodoro technique is an efficient and smart productivity method to get shit done. When using the Pomodoro technique, work in intense, focused blocks of about 25 minutes, and then take about a 5 minute break. After about 4 Pomodoros, take a longer break, about 15 minutes or more. The technique helps increase productivity while maintaining your creativity and motivation. It aslo has also been shown to increase attention span and concentration.

Variables

  1. How do you create a variable? A variable is created by assigning a word using an = sign a value
  2. What did you learn about the rules for naming variables? Variables start with a number or contain dashes (-). They are usually words. Variables also cannot be constants, such as true, false, nil, strings, or numbers.
  3. How do you change the value of a variable? Just assign the variable a new value. IRB will remember variables until you stop running it.

Datatypes

  1. How can you find out the class of a variable? .class
  2. What are two string methods? .to_i (changes to an integer) and .upcase (capitalizes all letters in the string)
  3. How can you change an integer to a string? .to_s

Strings

  1. Why might you use double quotes instead of single quotes in Ruby? You must use double quotes when you use interpolation (i.e. #{} within a string in double quotes)
  2. What is this used for in Ruby: #{}? Interpolation - embedding a Ruby statement into a string
  3. How would you remove all the vowels from a string? .delete('aeiou')

Input & Output

  1. What do 'print' and 'puts' do in Ruby? Both methods print information to the user of your screen. ‘puts’ adds a line break after the object.
  2. What does 'gets' do in Ruby? The “gets” string pauses your program and waits for the user to type in something and hit enter. It then returns the value back to your program and continues execution of the program.

Day 4 Questions

Numerics and Arithmetic

  1. What is the difference between integers and floats? Integers are whole number and floats have a number after a decimal point.
  2. What is the ruby command to find 2 to the 2nd power? 2**2

Booleans

  1. What do each of the following symbols mean?

== Equal, as opposed to just assigning a variable to something

">=" Greater than OR equal to

<= Less than OR equal to

!= The opposite

&& And

|| Or

  1. What are two Ruby methods that return booleans? In general methods that give booleans end with a question mark, i.e. .end_with?(‘x’) or .even?

Conditionals

  1. What is flow control? It is basically how data flows through a program. It uses the if…else…end construct
  2. What will the following code return? Not many apples...

apple_count = 4

if apple_count > 5

puts "Lots of apples!"

else

puts 'Not many apples...'

end

  1. What is an infinite loop, and how can you get out of one? Ctrl + c

Nil

  1. What is nil? Nil means 'nothing'. It's used to show that a variable hasn't been assigned anything yet, or that a function didn't return a value.

Symbols

  1. How can symbols be beneficial in Ruby? Symbols save memory because they let Ruby variables point to the same object in several places instead of allocating a new copy.
  2. Does naming symbols use the same rules for naming variables? For naming symbols, use a “:” at the beginning of the word. They are unlike variable because they are constants and therefore cannot be assigned a value with “=“

Arrays

  1. What method can you call to find out how many elements are in an array? .length
  2. What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]? 0
  3. What do 'push' and 'pop' do? push adds an element to the end of array and pop removes and returns the last element of the array

Hashes

  1. Describe some differences between arrays and hashes. With arrays you use brackets, and you retrieve their values by using their index, or order (a number starting from 0). With hashes you use curly brackets and hashrockets, and you retrieve their values using their keys, or words associated with them.
  2. What is a case when you might prefer an array? What is a case when you might prefer a hash? You might want an array when you are creating a list and the order matters. You might want a hash when you are storing large amounts of data and you need the data sorted by different propoerties, or keys.

Day 6: Making a Game

puts "I have generated a random number for you to guess, what is your guess?"

#A random number is generated, but how do I do this?

#set random number to variable random = x

x = Random.new.rand(0..10)

guesses = 0

user_guess = gets.to_i

#if the user enters the right number, puts "You guessed the right number!"

while user_guess != x

guesses + 1

if

  user_guess < x
  
  puts "Guess higher!"
  
  else
  
    puts "Guess lower!"
    
  end

user_guess = gets.to_i

end

puts "You guessed the right number in #{guesses} guesses!"

#if gets is < than random, say "Guess higher!"

#if gets is > than random, say "Guess lower!"

#if gets = "cheat" then puts random.to_s

#After 4 guesses, prompt the user with a hint, like even? or odd?

##Need guesses variable for this, so set guesses = 0

##Have guesses + 1 everytime the user guesses

##When the guesses = 4, then puts the hint

##How to make a hint when the number is different everytime?

Day 7 Questions

  1. Were you able to get through the work? Did you rush to finish, or take your time? I took my time at the begining so I could understand things and process them on my own terms. I rushed a bit to finish at the end, and I plan on finishing the ongoing Gear-up prework.
  2. What do you feel most confident about? I was able to figure out how to post pictures to my gist markdown on GitHub on my own, which felt like a huge win because it took a couple of hours of Googling. I am confident about my ability to persist at problems and not give up until I find the answer because the reward is huge!
  3. What do you feel least confident about? I feel least confident about being able to problem solve via Google, but I would like to become better at this because it's crucial to figuring out problems. I am also not very confident about managing other aspects of my life around Turing, like relationships and living on a very strict budget. But I am communicating with my support system to try and make them understand how intense the program will be and how much of my time will be tied up.
  4. What are you most looking forward to learning more about? Networking, the career search and how to market myself.
  5. What topics would you most like to see reinforced by instructors? Testing and how to make your code as simple as possible. How to be an "unstoppable" developer.
  6. What is most confusing to you about what you've learned? The difference between else and elseif. Also, there seem to be SO many different tools to use to help you code (nano, Vim, using the terminal, different text editors) and it would be nice to have a list of theses resources, what they help you do and what would be best to prioritize learning.
  7. What questions do you have for your student mentor or for your instructors? What is something I should prioritize focusing on in Mod 1? What is something you wished you prepared more for before coming to Turing? How can I find a good mentor?
  8. What do you feel was most successful in your game? The control flow and simpleness. It clicked for me tinking about how everything besides the variables need to stay inside the loop because the computer needs to keep circling it around. And using "gets" clicked more in that whenever it comes up the computer pauses and waits for the user to input something.
  9. What was the most challenging part about creating the game? Figuring out how to move to Level 3. I couldn't get past how to tell the computer if the user inputted a string (the word "cheats") or a number, but I know you have to keep it all in the loop.
  10. When you reached a challenging part of the game, how did you move forward? I wrote out comments about the steps I needed to take, and then I tried Googling for answers and advice. I plan to ask the prework guides for help now that I have been stuck for a while and it's not worth my time trying to figure it out only on my own.

Priority 1

Functions: How do you call a function and store the result in a variable? Simply type the name of the function, and then you can set it equal to a variable.

Describe the purpose of the following in Ruby classes:

**Initialize method - Don’t fully understand this one, but I know it’s usually the first function of a class because it sets up the class and saves the initial data your object is created with.

New method - ( Class.new( ) ) This method creates a new instance of your object and passes the arguments into the class.

Instance variables - (start with an @) These behave like normal variables except only accessible inside the specific instance of your object. Data is stored inside your object using instance variables.

How to write a program reflection:

The most challenging was trying to see why the initial program should be broken down in to smaller, more readable and maintainable chunks. I understand why the new functions are more readable, but I don’t know how to break them up further. I also still don’t understand fully the purpose of the initialize method. Also, how do you tell the difference between a constant and a variable?

The most enjoyable part was seeing understanding how various parts of the code worked and seeing being able to translate it into words. It also clicked for me why arrays were useful and how they could be used (eg to store different die rolls to later add them up).

Priority 2

Priority 3

Try Git complete

Priority 4

Shortcuts to know:

Mac:

  1. Command + tab = navigate to different applications

Command Line:

  1. Up and down arrows for previous commands
  2. Use tab to auto complete thigs after commands
  3. Input is usually: program, command, specific
  4. atom . = opens recently created file in atom?

Atom:

  1. Need to learn more - Learn Fuzzy Finder?
  2. Watch YouTube videos - https://www.youtube.com/watch?v=UYPgPyxwF28

Git:

  1. Need to learn more - Learn Try Git
  2. order is: add, commit, push
  3. git init = create repository?
  4. git checkout master = switch to branch 'master'
  5. git status
  6. git remote add origin https://github.com/corneliusellen/practice.git / git push -u origin master
  7. git branch -v = view branch ... git remote -v = view files remotely (on Github)

Priority 5

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