diff --git a/README.md b/README.md index 33eef4a63..c902f72d0 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,31 @@ This repository will walk you through the Mod 1 Pre-work for the Backend program at Turing. -Each day has a folder containing a `README.md` file with instructions for the day, exercises, and questions. Please complete all the exercises and questions, as well as lessons listed in the day's readme. +Each day has a folder containing a `README.md` file with instructions for the section, exercises, and questions. Please complete all the exercises and questions, as well as lessons listed in the section's README. ### Pre-work Index -* [Day 0 - More Terminal Practice](day_0) -* [Day 1 - Strings and Numbers](day_1) -* [Day 2 - Arrays and Iteration](day_2) -* [Day 3 - If Statements and Loops](day_3) -* [Day 4 - Methods and Return Values](day_4) -* [Day 5 - Hashes](day_5) -* [Day 6 - Classes](day_6) -* [Day 7 - Build A Thing](day_7) +* [Section 1 - SUPER LEARNERS, Terminal and Ruby Foundations](section1) +* [Section 2 - ASKING QUESTIONS, Conditionals and Methods](section2) +* [Section 3 - GROWTH MINDSET, Hashes](section3) +* [Section 4 - HOW YOU USE YOUR TIME, Objects and Classes](section4) +* [Final Prep - Final Deliverables and Submission](final_prep) + +## What to Expect + +Through completing this pre-work, you can expect to get practice re-inforcing what you learned/are learning in Mod 0, learn more technical content, and deeply reflect on your mindsets and habits and start thinking about which of those mindsets and habits will help you learn to code, and which of those you may need to change. + +We will remind you of the best practices that follow from time-to-time, but to ground yourself in the work ahead, read them carefully. + +## Best Practices: Learning to Write Code + +**If you are stuck for longer than 30 minutes, know that it is always ok to ask for help!** The process of becoming a software developer is difficult, and learning to code is hard. At some point, everyone struggles. Struggle is a normal, healthy part of the learning process - don't give up if you hit a hard spot. If you consistently practice every day and don't take shortcuts, you will be on the path to learning how to code. When you reach out for help, challenge yourself to ask clear questions and use technical vocabulary. Speaking accurately about code is a great way to help lock in technical understanding. Use [this guide](https://gist.github.com/ericweissman/fb0241e226227867b6bc70a4d49227f5) to learn the optimial way to ask for help when you get stuck! + +**Process over Product.** When asking for help, do your best to seek understanding rather than `the answer` or `the solution`. Even if your helper gets you a solution that works, make sure to spend time on *why* it works, rather than just accepting the solution and moving on. + +**Type every line of code.** One of the best things you can do to set yourself for success is to make sure you type out all the code examples you see in the readings and exercises in this pre-work, *do not* copy and paste. The more hands-on-keyboard practice you can give yourself, the better. Copying and pasting won't help you solidify these concepts, manually typing all the code in will. This also applies to auto complete features in popular text editors. They are helpful, no doubt, but doing things the hard way at the beginning is a great way to hone your workflow later on. + +**Details matter.** Pay close attention to small details in syntax, spacing, and language. The most detailed oriented you are as you're working, the more reliable and well-crafted your code will be. In programming, being detail oriented helps cut down on buggy code and difficult to use systems. It can also help you notice differences in your code, enabling you to identify typos and mistakes more quickly. # Environment @@ -23,18 +36,19 @@ Follow this guide step-by-step to make sure you have everything you need, then y ***Before proceeding***, if you have not already, complete the [mod-0 environment setup instructions](http://mod0.turing.io/setup-instructions) to install Atom, xcode-select, Homebrew, git, and Chrome. -We will now cover these three topics: +We will cover the following: * [Installing Rbenv - a Ruby Version Manager](#set-up-ruby-environment-manager-rbenv) * [Installing Ruby Versions using Rbenv](#use-rbenv-to-install-a-certain-version-of-ruby) +* [Terminal](#terminal) * [Forking and Cloning the Prework Repository](#forking-the-module-1-prework-repository) -First, let's get a Ruby version management tool on our machines. +First, let's get a Ruby version management tool on our machines. --> -## Set up Ruby Environment Manager: [rbenv](https://github.com/rbenv/rbenv#homebrew-on-mac-os-x) + ## Set up Ruby Environment Manager: [rbenv](https://github.com/rbenv/rbenv#homebrew-on-mac-os-x) -Over the years, Ruby has evolved through various version releases over time that contain new features and upgrades. Version 0.95, the very first, was released in 1995, and at the beginning of year 2020, we're at version 2.7. +Over the years, Ruby has evolved through various version releases over time that contain new features and upgrades. Version 0.95, the very first, was released in 1995, and at the beginning of year 2021, we're at version 2.7. Generally, programs written in one version of Ruby will run just fine on another version, but sometimes incompatibilities can be encountered, meaning that particular program needs to be run with a specific version of Ruby. @@ -42,11 +56,13 @@ Additionally, very useful tools called "gems" are out there that were created sp To solve potential compatability issues, we'd like to be able to install and manage multiple versions of Ruby on our system. We would also like to be able to use gems across different versions of Ruby. These are the kinds of things `rbenv` handles. -#### Installation +### Installation + +#### NOTE: If you have any issues with the `rbenv` setup, please message Eric Weissman on slack (@ericweissman) and we will address your issues at a later date! You're system version of ruby will work fine for your Prework exercises! Here is a video walk-through that may be helpful for the following steps. Check it out! -Keep in mind that the steps in the video are correct, but we want you to install **ruby version 2.5.3**, per the written instructions below. +Keep in mind that the steps in the video are correct, but we want you to install **ruby version 2.7.2**, per the written instructions below. [![Walkthrough RBENV and Ruby](images/rbenv-ruby-thumbnail.jpg)](https://youtu.be/3DtqMlK8In0 "Video Walkthrough for RBENV and Ruby Installation") @@ -105,14 +121,14 @@ More information about rbenv can be found [here](https://github.com/rbenv/rbenv# ### Use rbenv to install a certain version of Ruby -Now that we have rbenv installed, we're going to use it to install a specific version of Ruby: Ruby 2.5.3. This is the version we will use in the Backend Program. +Now that we have rbenv installed, we're going to use it to install a specific version of Ruby: Ruby 2.7.2. This is the version we will use in the Backend Program. -If you need another version it'll be the same procedure, just replace `2.5.3` in the instructions with whichever version you want. +If you need another version it'll be the same procedure, just replace `2.7.2` in the instructions with whichever version you want. Install it with: ``` -$ rbenv install 2.5.3 +$ rbenv install 2.7.2 ``` It will take a while to finish installing, and print a _lot_ of text to your terminal. @@ -123,14 +139,14 @@ When it's all finished, type: $ rbenv versions ``` -and you should now see `2.5.3` listed. +and you should now see `2.7.2` listed. Be careful, there are two different rbenv commands, `version` and `versions`. The first shows you _your current ruby version_. The second shows _all installed versions_. Switch to your newly installed version with ``` -$ rbenv local 2.5.3 +$ rbenv local 2.7.2 ``` Now enter: @@ -142,17 +158,17 @@ $ ruby -v This shows us what version of Ruby we are running. You should see something like: ``` -ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin17] +ruby 2.7.2p105 (2018-10-18 revision 65156) [x86_64-darwin17] ``` -You can ignore everything after the `p` in `2.5.3p105`- the first bit shows us we are running Ruby 2.5.3, which is what we want to verify. If you got something different than `2.5.3`, such as `2.4.1`, go back through the Rbenv installation, make sure you have you successfully edited your `bash_profile`, restart your terminal, and try again. +You can ignore everything after the `p` in `2.7.2p105`- the first bit shows us we are running Ruby 2.7.2, which is what we want to verify. If you got something different than `2.7.2`, such as `2.4.1`, go back through the Rbenv installation, make sure you have you successfully edited your `bash_profile`, restart your terminal, and try again. #### Setting the Default Version You can tell rbenv which Ruby version you want to use by default. Let's do that with terminal command: ``` -$ rbenv global 2.5.3 +$ rbenv global 2.7.2 ``` Now, let's make your terminal aware of this update with command: @@ -163,9 +179,9 @@ $ rbenv rehash ## Terminal -We will be referencing many terminal commands throughout the prework. It is recommended that you practice using terminal commands before getting started with day_1. +We will be referencing many terminal commands throughout the prework. It is recommended that you practice using terminal commands before getting started with section1. -[Check out day_0 to practice!](day_0) +[Check out section 1 to practice!](section1) ### Forking the Module 1 Prework Repository @@ -177,7 +193,7 @@ In order to fork the repository, follow these steps: #### 1. Make sure you are logged in to GitHub (if you are not logged in, log in and come back to this page) -#### 2. You'll want to find this repository's Fork button. Scroll to the top of *this* webpage... yes, [this one](https://github.com/turingschool-examples/backend_mod_1_prework) that you're reading right now! +#### 2. You'll want to find this repository's Fork button. Scroll to the top of *this* webpage... yes, [this one](https://github.com/turingschool/backend_mod_1_prework) that you're reading right now! #### 3. Click on `Fork` in the upper right corner of the screen, just under the top banner. @@ -220,19 +236,19 @@ Resolving deltas: 100% (332/332), done. $ cd backend_mod_1_prework $ git status . // If everything worked correctly, you should see: -On branch master +On branch main nothing to commit, working tree clean ``` From here on out, all the work you do will be in your personal copy of this repository. Throughout Mod 0, we may call this your "prework repository" or "backend prework"... this refers to your forked copy of this `backend_mod_1_prework` repository that you have just now cloned to your device. -Here's _another_ video walk-through you may find helpful: +Here's _another_ video walk-through you may find helpful. **NOTE - The video may reference a "master" branch - we have renamed this branch to "main"** -[![Walkthrough Day 1 and Git stuff](/images/backend-prework-day-one-thumb.jpg)](https://youtu.be/HYAzk6L63ek "Video Walkthrough for Day 1 & Git Stuff") +[![Walkthrough Git stuff](/images/backend-prework-day-one-thumb.jpg)](https://youtu.be/HYAzk6L63ek "Video Walkthrough for Git Stuff") Each day's `README` will walk you through the necessary steps to save your work. -To begin, open your terminal and `cd` into the `day_0` directory. Follow the instructions contained in the `README.md` file, and have fun experimenting! +To begin, open your terminal and `cd` into the `section1` directory. Follow the instructions contained in the `README.md` file, and have fun experimenting! ---------------------------------- diff --git a/day_0/README.md b/day_0/README.md deleted file mode 100644 index ea3042ee8..000000000 --- a/day_0/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# Dive Right In! - -You will likely spend the majority of your time in Module 1 in either the Terminal or your text editor. When you're new to programming, the terminal can seem like a scary place, but it has some advantages over other means of interacting with your computer. Perhaps the greatest advantage is that it allows programmers to build tools that they can share with each other without going through the process of creating a graphical user interface. This makes it easy to share code quickly so that it can be used in multiple projects. - -You already have had some exposure to the terminal in the [mod0 session 2: Terminal and Command Line](http://mod0.turing.io/session2/#terminal-and-command-line). Let's practice a little more! - -### Here's a video walk-through of how to navigate your mod 1 prework: - -[![Walkthrough Day 1 and Git stuff](/images/backend-prework-day-one-thumb.jpg)](https://youtu.be/HYAzk6L63ek "Video Walkthrough for Day 1 & Git Stuff") - -### Practice - -Use the terminal commands described in the video above to move around your computer. - -* Dig deep into one of your existing directories by using `cd` to move and `ls` to see what directories are available. -* Navigate out using `cd ../` to get back to your home directory. Use `pwd` to make sure you don't overshoot it! -* Dig deep into another directory, using `ls` as you go. -* Use `cd ~/` to navigate to your home directory. -* Navigate into your Downloads directory using `cd Downloads`. -* Navigate to your Desktop using `cd ~/Desktop`. -* Use `pwd` and `ls` to confirm your current location. - -Continue practicing these commands until you feel comfortable moving around without having to look at this lesson. - -## Making Things - -### Practice - -Lets get a little practice with `touch`, `mkdir`, `ls`, and `cd`: - -Use `mkdir` and `touch` to create the directories/files in the structure described below. - -```sh -|-- _secret_library - | - |--README.md - |--Gemfile - |--Rakefile - | - |--_lib - | | - | |--secret_library.rb - | |--secret_book.rb - | |--secret_librarian.rb - | |--patron.rb - | |--library_system.rb - | - |--_test - | - |--secret_library_test.rb - |--secret_book_test.rb - |--secret_librarian_test.rb - |--patron_test.rb - |--library_system_test.rb -``` - -Don't worry about putting any text into these files. For now, just create this structure and empty files. - -## Deleting Things - -### The rm Command - -Be careful when deleting something though the terminal! While we want to be comfortable using the very helpful `rm` command, once executed, the command cannot be undone. Lets learn more about `rm` before we practice: - -* `rm`: This will remove a file from your system. Be very careful with this and always double check the file you target! The terminal assumes you're a little more of an expert than the system does. `rm` doesn't move the file to the Trash, it removes it completely from your system. It basically moves the file to the trash, then deletes it immediately. No chance to stop it or change your mind. - -* `rm -rf`: Adding the `-r` and `-f` flags to the `rm` command will allow you to delete directories even if they have other files and/or directories inside of them. For more information on each of these flags enter `man rm` into your terminal. It will print out the manual for this command. - -### Practice - -Use `rm` and `rm -rf` to delete each of the files and directories you created in the Making Things section above. Note, that it would be possible to delete the entire directory that you created with just `rm -rf secret_library`. *Don't do this!* At this point, delete each of the files and directories individually to practice these commands. This will help you remember them better in the long run, which is the goal! More practice now will allow you to be more efficient in the future. diff --git a/day_1/README.md b/day_1/README.md deleted file mode 100644 index 034ae11da..000000000 --- a/day_1/README.md +++ /dev/null @@ -1,194 +0,0 @@ -# Day 1 - Strings and Numbers - -Today, you will begin to learn the basics of Ruby. You will work through several tutorials which will help build your comfort running files and seeing output. You will also learn about two ways to represent data in Ruby: *Strings* and *Numbers*. - -In addition to learning Ruby basics, this day will also walk you through entering commands in the terminal to create files. By the end of the day, you should be very comfortable with the commands `cd` and `ls`, both very useful in navigating your machine, and the commands `mkdir` and `touch`, used to create directories and files on the machine. - -After completing the days work, you will use several git commands to save your work to your local git repository. You will then push your updates to your remote Github repository. Doing this each day will help you build muscle memory with git commands and get used to seeing the output they produce. We will dive deeper into the inner workings of git later. For now, most important is to follow along and know that we are using git to save our work, and Github to put it on the internet. - -### This lesson will have you using Git, Github, etc. Here's a video walkthrough - -[![Walkthrough Day 1 and Git stuff](/images/backend-prework-day-one-thumb.jpg)](https://youtu.be/HYAzk6L63ek "Video Walkthrough for Day 1 & Git Stuff") - -## Open your local copy of backend_mod_1_prework in Atom - -Using your terminal, open the local copy of this repo. To do this, enter these commands into your terminal: - -``` -cd ~ -ls -cd turing -ls -cd 0module -ls -cd backend_mod_1_prework -ls -cd day_1 -ls -atom . -``` - -This will open the day_1 directory in Atom. You should be able to see the directory and its contents in the file explorer on the left side of your Atom window. - -## An Introduction to Ruby - -[Read This Introduction](https://learnrubythehardway.org/book/intro.html) to the Learn Ruby The Hard Way Tutorial. To reiterate this introduction, ***DO NOT*** copy and paste code examples when working through lessons in your prework. Actually type each of them out. - -### Ruby Basics Lessons - -1. Next, you will complete several lessons from the Learn Ruby the Hard Way Tutorial. *For ***each*** lesson* ***follow these directions closely***: - - 1. Create a file within your `day_1` directory that will contain this lesson's work. Verify that you are within the directory by using terminal command `pwd`. If you are not, `cd` into your `day_1` directory. Once you are there, use the `touch` command in your terminal to create a file. For the first lesson, name this file `ex1.rb`. For each subsequent lesson, use `ex2.rb`, `ex3.rb`, so on, so forth. Refer to back to [day_0](../day_0) if you need a refresher on terminal commands. - - 1. Work through the lesson, **typing** the code into your file, and running it in the terminal with `ruby ex1.rb`, replacing `ex1` with the actual file name of what you'd like to run. Make sure the output you get is similar to what the lesson shows. If you get an error saying "No such file or directory", be sure to verify the directory you are located in via the terminal- running command `ls` should show the file you are trying to run. - - 1. Complete the Study Drills listed at the end of the lesson. - - 1. Read the Common Student Questions section. - -1. Check off the items below as you complete the steps you just read for each lesson. ***Remember to create a file containing your work for each lesson!*** - - - [ ] [A Good First Program](https://learnrubythehardway.org/book/ex1.html) - - - [ ] [Comments in Code](https://learnrubythehardway.org/book/ex2.html) - - - [ ] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html) - - - [ ] [Variables and Names](https://learnrubythehardway.org/book/ex4.html) - - - [ ] [Strings](https://learnrubythehardway.org/book/ex5.html) - - - [ ] [More Strings](https://learnrubythehardway.org/book/ex6.html) - - - [ ] [Asking for Input](https://learnrubythehardway.org/book/ex11.html) - - - [ ] Have you created 7 `ex.rb` files with your code in them? - -1. Work through the [Strings](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#3.-strings) and [Numbers](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#5.-numbers) sections from Ruby in 100 Minutes. For each of these sections, open an `irb` session by typing `irb` into your terminal and type in the code snippets provided. - -## Exercises -- Each day contains an exercises directory containing files where you will practice writing code. - -Work through the files in the day_1/exercises directory. Complete them in this order: - -1. strings -1. numbers -1. variables -1. interpolation -1. loops - -## Questions -- Each day contains a questions.md file where you will answer questions about what you have learned. - -Answer the day 1 questions within the questions.md file. The `.md` file extension refers to markdown formatting. Markdown is a simple markup language to help format your text. [This article](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) shows everything you need for basic markdown formatting. - -## Save your work in Git - -When you are finished with all of the day_1 activities, follow these steps in order to save your work to your local git repository. - -1. Make sure you are in your `day_1` directory. Enter `ls` in your terminal- You should see the exercises directory, README.md, and questions.md all listed. - -1. In your terminal, enter `git status`. You should see output like this: - - ``` - On branch master - Changes not staged for commit: - (use "git add ..." to update what will be committed) - (use "git checkout -- ..." to discard changes in working directory) - - modified: exercises/interpolation.rb - modified: exercises/loops.rb - modified: exercises/numbers.rb - modified: exercises/strings.rb - modified: exercises/variables.rb - modified: questions.md - - Untracked files: - (use "git add ..." to include in what will be committed) - - ex1.rb - ex2.rb - ex3.rb - ex4.rb - ex5.rb - ex6.rb - ex7.rb - - no changes added to commit (use "git add" and/or "git commit -a") - ``` - - The command `git status` shows us information about files we changed. Don't worry too much about understanding what this all means just yet. What's important is that you get comfortable typing `git status` often. - -1. Enter `git add ex1.rb`. -1. Enter `git status`. Your status should now look a little different: - - ```On branch master - Changes to be committed: - (use "git reset HEAD ..." to unstage) - - new file: ex1.rb - - Changes not staged for commit: - (use "git add ..." to update what will be committed) - (use "git checkout -- ..." to discard changes in working directory) - - modified: exercises/interpolation.rb - modified: exercises/loops.rb - modified: exercises/numbers.rb - modified: exercises/strings.rb - modified: exercises/variables.rb - modified: questions.md - - Untracked files: - (use "git add ..." to include in what will be committed) - - ex2.rb - ex3.rb - ex4.rb - ex5.rb - ex6.rb - ex7.rb - ``` - - Under "Changes to be committed", "ex1.rb" is now listed. This means that git is now prepared to save this file. We want to do this for each file that has been modified. - -1. Enter `git add ex2.rb` -1. Enter `git status`. "ex2.rb" should now be listed under "Changes to be committed". -1. Do this for each of the "ex#.rb" files you created and for the "questions.md" file. -1. Enter `git status`. Under "Changes not staged for commit", you should see all the files in the exercises directory. -1. Enter `git add exercises`. -1. Enter `git status`. You should now see all those exercises files listed under "Changes to be committed". We just used `git add ` to add all the files located in a directory. -1. Enter `git status`. You should now see all your files listed under "Changes to be committed". If there are any files listed under "Untracked files" or "Changes not staged for commit", add them using `git add `. -1. Enter `git commit -m "Add day 1"`. Don't forget to close the quotes of your message! -1. Run `git status`. You should see this output: - -``` -On branch master -nothing to commit, working tree clean -``` - -Congratulations! You just saved your work to Git! If `git status` is showing any files, add them with `git add ` and commit them with `git commit -m "Add day 1"`. - - -## Push to Github - -You've saved your work to git on your **local** machine, but it is not yet accessible through your **remote** Github repository. Updating our **remote** Github repository with our **local** changes is called **pushing**. Push your code with the following command: - -``` -git push origin master -``` - -You should see output similar to this: - -``` -Counting objects: 9, done. -Delta compression using up to 4 threads. -Compressing objects: 100% (8/8), done. -Writing objects: 100% (9/9), 1.03 KiB | 1.03 MiB/s, done. -Total 9 (delta 2), reused 0 (delta 0) -remote: Resolving deltas: 100% (2/2), completed with 1 local object. -To github.com:JohnDoe/backend_mod_1_prework.git - e8ebd7a..32c0ed3 master -> master -``` - -You should now be able to log in to GitHub, navigate to your remote prework repository and see all the work you did today! diff --git a/day_1/exercises/variables.rb b/day_1/exercises/variables.rb deleted file mode 100644 index a1e45bb26..000000000 --- a/day_1/exercises/variables.rb +++ /dev/null @@ -1,29 +0,0 @@ -# In the below exercises, write code that achieves -# the desired result. To check your work, run this -# file by entering the following command in your terminal: -# `ruby day_1/exercises/variables.rb` - -# Example: Write code that saves your name to a variable and -# prints what that variable holds to the terminal: -name = "Harry Potter" -p name - -# Write code that saves the string 'Dobby' to a variable and -# prints what that variable holds to the terminal: -house_elf = "Dobby" -# YOUR CODE HERE - -# Write code that saves the string 'Harry Potter must not return to Hogwarts!' -# and prints what that variable holds to the terminal: -# YOUR CODE HERE - -# Write code that adds 2 to the `students` variable and -# prints the result: -students = 22 -# YOUR CODE HERE -p students - -# Write code that subracts 2 from the `students` variable and -# prints the result: -# YOUR CODE HERE -p students diff --git a/day_1/questions.md b/day_1/questions.md deleted file mode 100644 index 73700e323..000000000 --- a/day_1/questions.md +++ /dev/null @@ -1,17 +0,0 @@ -## Day 1 Questions - -1. How would you print the string `"Hello World!"` to the terminal? - -1. What character is used to indicate comments in a ruby file? - -1. Explain the difference between an integer and a float? - -1. In the space below, create a variable `animal` that holds the string `"zebra"` - -1. How would you print the string `"zebra"` using the variable that you created above? - -1. What is interpolation? Use interpolation to print a sentence using the variable `animal`. - -1. What method is used to get input from a user? - -1. Name and describe two common string methods: diff --git a/day_2/README.md b/day_2/README.md deleted file mode 100644 index 0c8c1571c..000000000 --- a/day_2/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# Day 2 - Arrays and Iteration - -Computers may not be smart, but they are good at processing things *very* quickly, like working through tons of data. To take full advantage, we need some way of storing lots of data. Today, you will learn about a Ruby data structure, the *Array*, that allows us to store collections of data. You will also learn about *iteration*: when you go through every element of an array. - -When you are all done with the lessons, exercises, and questions for today, you will once again use git to save your work locally, and then send your work to Github. - -## Open your local copy of backend_mod_1_prework - -Using your terminal, open your local copy of the forked repository you created during setup. To do this, you will need to use the terminal command `cd` to enter the directory that holds the repository. Once you are in the correct directory, use the terminal command `atom .` to open the prework repository. Revisit [day_1](../day_1) for more detail if needed. - -## Array and Iteration Lessons - -1. Work through the [Arrays](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#7.-arrays) section of Ruby in 100 Minutes. As you work through this section, research each of the methods mentioned by looking through the [Ruby docs for Arrays](https://ruby-doc.org/core-2.4.1/Array.html). Documentation like this might look intimidating, but diving in and practicing now will build your comfort level. Create a file in your day_2 directory called `array_methods.md` and describe what each method does in your own words. -1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory. - - - [ ] Turing's [Iteration and Each](http://backend.turing.io/module1/lessons/iteration_and_each) lesson. - - - [ ] [Booleans](https://learnrubythehardway.org/book/ex27.html) from Learn Ruby the Hard Way. - - - [ ] [Boolean Practice](https://learnrubythehardway.org/book/ex28.html) from Learn Ruby the Hard Way. - -1. Work through the exercise files in the day_2/exercises directory. Complete them in this order: - 1. arrays - 1. iteration - -1. Answer the questions in the questions.md file in the day_2 directory. - -## Save your work in Git - -When you finish all of the day_2 activities, enter the following commands in your terminal in order to save your work to your local git repository: - -1. `$ git add day_2/exercises` -1. `$ git add day_2/questions.md` -1. Use `git add day_2/` to add all additional files that you created today -1. `$ git status` - you should see only green filenames - if you see any that are red, continue to `git add` those files until `git status` shows all green files. -1. `$ git commit -m "Add Day 2 Work"` - -## Push to Github - -Remember- You've saved your work to git on your **local** machine, but it is not yet accessible through your **remote** Github repository. Push your code up to Github with the following command: - -``` -git push origin master -``` - -You should now be able to log in to GitHub, navigate to your remote prework repository and see all the work you did today! diff --git a/day_2/exercises/arrays.rb b/day_2/exercises/arrays.rb deleted file mode 100644 index f572a5ae6..000000000 --- a/day_2/exercises/arrays.rb +++ /dev/null @@ -1,40 +0,0 @@ -# In the below exercises, write code that achieves -# the desired result. To check your work, run this -# file by entering the following command in your terminal: -# `ruby day_2/exercises/arrays.rb` - -# Example: Write code that stores an array in a variable, -# then prints that array: -animals = ["Zebra", "Giraffe", "Elephant"] -p animals - -# Write code that stores an array of states in a variable, -# then prints that array: -states = #YOUR CODE HERE -p states - -# Write code that stores an array of foods in a variable, -# then prints that array: -# YOUR CODE HERE - -# Example: Write code that prints the number of elements -# in your above array of animals: -p animals.count - -# Write code that prints the number of elements -# in your above array of foods: -# YOUR CODE HERE - -# Write code that prints "Zebra" from your animals array: -# YOUR CODE HERE - -# Write code that prints the last item of your foods array: -# YOUR CODE HERE - -# Write code that adds "lion" to your animals array -# and prints the result (Hint- use a method): -# YOUR CODE HERE - -# Write code that removes the last element from your foods array -# and prints the result (Hint- use a method): -# YOUR CODE HERE diff --git a/day_2/exercises/iteration.rb b/day_2/exercises/iteration.rb deleted file mode 100644 index a801cb4fc..000000000 --- a/day_2/exercises/iteration.rb +++ /dev/null @@ -1,28 +0,0 @@ -# In the below exercises, write code that achieves -# the desired result. To check your work, run this -# file by entering the following command in your terminal: -# `ruby day_2/exercises/iteration.rb` - -# Example: Write code that iterates through a list of animals -# and print each animal: -animals = ["Zebra", "Giraffe", "Elephant"] - -animals.each do |animal| - p animal -end - -# Write code that iterates through a list of animals and prints -# "The is awesome!" for each animal: - -animals.each do |animal| - # YOUR CODE HERE -end - -# Write code that stores an array of foods in a variable, -# then iterates over that array to print -# "Add to shopping list" for each food item: -# YOUR CODE HERE - -# Write code that stores an array of numbers in a variable, -# then iterates over that array to print doubles of each number: -# YOUR CODE HERE diff --git a/day_2/questions.md b/day_2/questions.md deleted file mode 100644 index a179f0b04..000000000 --- a/day_2/questions.md +++ /dev/null @@ -1,17 +0,0 @@ -## Day 2 Questions - -1. Create an array containing the following strings: `"zebra", "giraffe", "elephant"`. - -1. Save the array you created above to a variable `animals`. - -1. Using the array `animals`, how would you access `"giraffe"`? - -1. How would you add `"lion"` to the `animals` array? - -1. Name and describe two additional array methods: - -1. What are the boolean values in Ruby? - -1. In Ruby, how would you evaluate if `2` is equal to `25`? What is the result of this evaluation? - -1. In Ruby, how would you evaluate if `25` is greater than `2`? What is the result of this evaluation? diff --git a/day_3/README.md b/day_3/README.md deleted file mode 100644 index d4534e0e1..000000000 --- a/day_3/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# Day 3 - If Statements and Conditionals - -One of the most important concepts in computer programming is knowing when and how to tell the computer to do either _one_ thing or _another_ thing based on a set of simple criteria. We accomplish this with ***If-Statements*** and ***Conditionals***, which you will learn about today. - -When you are all done with the lessons, exercises, and questions for today, you will once again use git to save your work locally, and then send your work to Github. - -## Open your local copy of backend_mod_1_prework - -Using your terminal, open your local copy of the forked repository you created during setup. To do this, you will need to use the terminal command `cd` to enter the directory that holds the repository. Once you are in the correct directory, use the terminal command `atom .` to open the prework repository. Revisit [day_1](../day_1) for more detail if needed. - -## If statement and Conditional Lessons - -1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory. - - - [ ] [What If?](https://learnrubythehardway.org/book/ex29.html) from Learn Ruby the Hard Way. - - - [ ] [Else and If](https://learnrubythehardway.org/book/ex30.html) from Learn Ruby the Hard Way. - - - [ ] [Making Decisions](https://learnrubythehardway.org/book/ex31.html) from Learn Ruby the Hard Way. - - - [ ] [Conditionals](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#9.-conditionals) from Ruby in 100 Minutes. - -1. Work through the exercise files in the day_3/exercises directory. - -1. Answer the questions in the questions.md file in the day_3 directory. - -## Save your work in Git - -When you are finished with all of the day_3 activities, enter the following commands in your terminal in order to save your work to your local git repository: - -1. `$ git add day_3/exercises` -1. `$ git add day_3/questions.md` -1. Use `git add day_3/` to add all additional files that you created today -1. `$ git status` - you should see only green filenames - if you see any that are red, continue to `git add` those files until `git status` shows all green files. -1. `$ git commit -m "Add Day 3 Work"` - -## Push to Github - -Remember- You've saved your work to git on your **local** machine, but it is not yet accessible through your **remote** Github repository. Push your code up to Github with the following command: - -``` -git push origin master -``` - -You should now be able to log in to GitHub, navigate to your remote prework repository and see all the work you did today! diff --git a/day_3/questions.md b/day_3/questions.md deleted file mode 100644 index db6170fa7..000000000 --- a/day_3/questions.md +++ /dev/null @@ -1,13 +0,0 @@ -## Day 3 Questions - -1. What is a conditional statement? Give three examples. - -1. Why might you want to use an if-statement? - -1. What is the Ruby syntax for an if statement? - -1. How do you add multiple conditions to an if statement? - -1. Provide an example of the Ruby syntax for an if/elsif/else statement: - -1. Other than an if-statement, can you think of any other ways we might want to use a conditional statement? diff --git a/day_4/README.md b/day_4/README.md deleted file mode 100644 index 5fb1100bc..000000000 --- a/day_4/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# Day 4 - Methods and Return Values - -On day 1 of the prework, you learned how to store information in Variables. Today, you will learn about another way to store information; more specifically, how to use Methods to create Return Values. In programming, we _often_ use methods, so this is an important concept to get familiar with! - -When you are all done with the lessons, exercises, and questions for today, you will once again use git to save your work locally, and then send your work to Github. - -## Open your local copy of backend_mod_1_prework - -Using your terminal, open your local copy of the forked repository you created during setup. To do this, you will need to use the terminal command `cd` to enter the directory that holds the repository. Once you are in the correct directory, use the terminal command `atom .` to open the prework repository. Revisit [day_1](../day_1) for more detail if needed. - -## Method Lessons - -1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory. - - _*Note*: In some of these lessons, the author refers to methods as functions. They are interchangable here, but at Turing, we will be use the word `method`._ - - - [ ] [Methods](https://launchschool.com/books/ruby/read/methods) from LaunchSchool. Work up to the `obj.method or method(obj)` header. - - - [ ] [Intro to Methods](https://learnrubythehardway.org/book/ex18.html) from Learn Ruby the Hard Way. - - - [ ] [Methods and Variables](https://learnrubythehardway.org/book/ex19.html) from Learn Ruby the Hard Way. - - - [ ] [Methods and Return Values](https://learnrubythehardway.org/book/ex21.html) from Learn Ruby the Hard Way. - -1. Work through the methods.rb file in the day_4/exercises directory. - -1. Answer the questions in the questions.md file in the day_4 directory. - -## Save your work in Git - -When you are finished with all of the day_4 activities, enter the following commands in your terminal in order to save your work to your local git repository: - -1. `$ git add day_4/exercises` -1. `$ git add day_4/questions.md` -1. Use `git add day_4/` to add all additional files that you created today -1. `$ git status` - you should see only green filenames - if you see any that are red, continue to `git add` those files until `git status` shows all green files. -1. `$ git commit -m "Add Day 4 Work"` - -## Push to Github - -Remember- You've saved your work to git on your **local** machine, but it is not yet accessible through your **remote** Github repository. Push your code up to Github with the following command: - -``` -git push origin master -``` - -You should now be able to log in to GitHub, navigate to your remote prework repository and see all the work you did today! diff --git a/day_4/exercises/methods.rb b/day_4/exercises/methods.rb deleted file mode 100644 index 6ed338e5d..000000000 --- a/day_4/exercises/methods.rb +++ /dev/null @@ -1,27 +0,0 @@ -# In the below exercises, write code that achieves -# the desired result. To check your work, run this -# file by entering the following command in your terminal: -# `ruby day_4/exercises/methods.rb` - -# Example: Write a method that when called will print your name: -def print_name - p "Severus Snape" -end - -print_name - -# Write a method that takes a name as an argument and prints it: -def print_name(name) - # YOUR CODE HERE -end - -print_name("Albus Dumbledore") - -# Write a method that takes in 2 numbers as arguments and prints -# their sum. Then call your method: -# YOUR CODE HERE - -# Write a method that takes in two strings as arguments and prints -# a concatenation of those two strings. Example: The arguments could be -# (man, woman) and the end result might output: "When Harry Met Sally". -# Then call your method: diff --git a/day_4/questions.md b/day_4/questions.md deleted file mode 100644 index af17ab4da..000000000 --- a/day_4/questions.md +++ /dev/null @@ -1,11 +0,0 @@ -## Day 4 Questions - -1. In your own words, what is the purpose of a method? - -1. Create a method named `hello` that will print `"Sam I am"`. - -1. Create a method named `hello_someone` that takes an argument of `name` and prints `"#{name} I am"`. - -1. How would you call or execute the method that you created above? - -1. What questions do you have about methods in Ruby? diff --git a/day_5/README.md b/day_5/README.md deleted file mode 100644 index 28be6b8fb..000000000 --- a/day_5/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Day 5 - Hashes - -Earlier in the week, you learned about one type of collection storage - Arrays. Today, you will learn about another collection storage device called a Hash. As professional developers, you will use hashes on a near daily basis- a solid understanding of how to build hashes and how to retrieve information from them will make life much easier. - -When you are all done with the lessons, exercises, and questions for today, you will once again use git to save your work locally, and then send your work to Github. - -## Open your local copy of backend_mod_1_prework - -Using your terminal, open your local copy of the forked repository you created during setup. Hopefully you are getting the hang of this, but revisit [day_1](../day_1) for more detail if needed. - -## Hash Lessons - -1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory. - - - [ ] [Hashes](https://learnrubythehardway.org/book/ex39.html) from Learn Ruby the Hard Way. - - - [ ] [Hashes](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#8.-hashes) from Ruby in 100 minutes. - -1. Work through the hashes.rb file in the day_5/exercises directory. - -1. Answer the questions in the questions.md file in the day_5 directory. - -## Save your work in Git - -When you are finished with all of the day_5 activities, enter the following commands in your terminal in order to save your work to your local git repository: - -1. `$ git add day_5/exercises` -1. `$ git add day_5/questions.md` -1. Use `git add day_5/` to add all additional files that you created today -1. `$ git status` - you should see only green filenames - if you see any that are red, continue to `git add` those files until `git status` shows all green files. -1. `$ git commit -m "Add Day 5 Work"` - -## Push to Github - -Remember- You've saved your work to git on your **local** machine, but it is not yet accessible through your **remote** Github repository. Push your code up to Github with the following command: - -``` -git push origin master -``` - -You should now be able to log in to GitHub, navigate to your remote prework repository and see all the work you did today! diff --git a/day_5/exercises/hashes.rb b/day_5/exercises/hashes.rb deleted file mode 100644 index 99fcebb77..000000000 --- a/day_5/exercises/hashes.rb +++ /dev/null @@ -1,28 +0,0 @@ -# In the below exercises, write code that achieves -# the desired result. To check your work, run this -# file by entering the following command in your terminal: -# `ruby day_5/exercises/hashes.rb` - -# Example: Write code that prints a hash holding grocery store inventory: -foods = {apples: 23, grapes: 507, eggs: 48} -p foods - -# Write code that prints a hash holding zoo animal inventory: -zoo = #YOUR CODE HERE -p zoo - -# Write code that prints all of the 'keys' of the zoo variable -# you created above: -# YOUR CODE HERE - -# Write code that prints all of the 'values' of the zoo variable -# you created above: -# YOUR CODE HERE - -# Write code that prints the value of the first animal of the zoo variable -# you created above: -# YOUR CODE HERE - -# Write code that adds an animal to the zoo hash. -# Then, print the updated hash: -# YOUR CODE HERE diff --git a/day_5/questions.md b/day_5/questions.md deleted file mode 100644 index d059e12c6..000000000 --- a/day_5/questions.md +++ /dev/null @@ -1,13 +0,0 @@ -## Day 5 Questions - -1. What is a Hash, and how is it different from an Array? - -1. In the space below, create a Hash stored to a variable named `pet_store`. This hash should hold an inventory of items and the number of that item that you might find at a pet store. - -1. Given the following `states = {"CO" => "Colorado", "IA" => "Iowa", "OK" => "Oklahoma"}`, how would you access the value `"Iowa"`? - -1. With the same hash above, how would we get all the keys? How about all the values? - -1. What is another example of when we might use a hash? In your example, why is a hash better than an array? - -1. What questions do you still have about hashes? diff --git a/day_6/README.md b/day_6/README.md deleted file mode 100644 index 829fe4809..000000000 --- a/day_6/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Day 6 - Classes - -Today, you are going to be learning about Objects and Classes. In ruby, Classes are one of the tools we use to group together specific Methods that are meant to work together, or on the same type of Object. Arriving at Turing with a strong understanding of how to build a class, and how to call Methods on that class will make your first couple of weeks go smoothly! - -When you are all done with the lessons, exercises, and questions for today, you will once again use git to save your work locally, and then send your work to Github. - -## Open your local copy of backend_mod_1_prework -Using your terminal, open your local copy of the forked repository you created during setup. Hopefully you are getting the hang of this, but revisit [day_1](../day_1) for more detail if needed. - -## Class lessons - -1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory. - - - [ ] [What Are Objects](https://launchschool.com/books/oo_ruby/read/the_object_model#whatareobjects) section from LaunchSchool. - - - [ ] [Classes Define Objects](https://launchschool.com/books/oo_ruby/read/the_object_model#classesdefineobjects) section from LaunchSchool. - - - [ ] [Classes and Objects Part 1](https://launchschool.com/books/oo_ruby/read/classes_and_objects_part1) from LaunchSchool. - - - [ ] [Objects, Attributes and Methods](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#11.-objects,-attributes,-and-methods) from Ruby in 100 Minutes. - -1. Work through the files in the day_6/exercises directory. - -1. Answer the questions in the questions.md file in the day_6 directory. - -## Save your work in Git - -When you are finished with all of the day_6 activities, enter the following commands in your terminal in order to save your work to your local git repository: - -1. `$ git add day_6/exercises` -1. `$ git add day_6/questions.md` -1. Use `git add day_6/` to add all additional files that you created today -1. `$ git status` - you should see only green filenames - if you see any that are red, continue to `git add` those files until `git status` shows all green files. -1. `$ git commit -m "Add Day 6 Work"` - -## Push to Github - -Remember- You've saved your work to git on your **local** machine, but it is not yet accessible through your **remote** Github repository. Push your code up to Github with the following command: - -``` -git push origin master -``` - -You should now be able to log in to GitHub, navigate to your remote prework repository and see all the work you did today! diff --git a/day_6/exercises/burrito.rb b/day_6/exercises/burrito.rb deleted file mode 100644 index 967f68b6c..000000000 --- a/day_6/exercises/burrito.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Add the following methods to this burrito class and -# call the methods below the class: -# 1. add_topping -# 2. remove_topping -# 3. change_protein - -class Burrito - attr_reader :protein, :base, :toppings - def initialize(protein, base, toppings) - @protein = protein - @base = base - @toppings = toppings - end -end - -dinner = Burrito.new("Beans", "Rice", ["cheese", "salsa", "guacamole"]) -p dinner.protein -p dinner.base -p dinner.toppings diff --git a/day_6/exercises/person.rb b/day_6/exercises/person.rb deleted file mode 100644 index 2c26e9570..000000000 --- a/day_6/exercises/person.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Create a person class with at least 2 attributes and 2 behaviors. -# Call all person methods below the class and print results -# to the terminal that show the methods in action. - -# YOUR CODE HERE diff --git a/day_6/questions.md b/day_6/questions.md deleted file mode 100644 index f58ca5f71..000000000 --- a/day_6/questions.md +++ /dev/null @@ -1,13 +0,0 @@ -## Day 6 Questions - -1. In your own words, what is a Class? - -1. What is an attribute of a Class? - -1. What is behavior of a Class? - -1. In the space below, create a Dog class with at least 2 attributes and 2 behaviors: - -1. How do you create an instance of a class? - -1. What questions do you still have about classes in Ruby? diff --git a/day_7/10_speckled_frogs.md b/day_7/10_speckled_frogs.md deleted file mode 100644 index 67789f479..000000000 --- a/day_7/10_speckled_frogs.md +++ /dev/null @@ -1,27 +0,0 @@ -## 10 Speckled Frogs - -Create a file named `10_speckled_frogs.rb` and within that file, write several a program that will print the following nursery rhyme: - -> 3 speckled frogs sat on a log -> eating some most delicious bugs. -> One jumped in the pool where its nice and cool, -> then there were 2 speckled frogs. -> -> 2 speckled frogs sat on a log -> eating some most delicious bugs. -> One jumped in the pool where its nice and cool, -> then there was 1 speckled frogs. -> -> 1 speckled frog sat on a log -> eating some most delicious bugs. -> One jumped in the pool where its nice and cool, -> then there were no more speckled frogs! - -### Required -Make your program print the rhyme above for *10* frogs, with attention to where language changes. - -### Extension 1 -Print word versions of each number in the first and fourth lines, for example, the first verse in the above example would print 'Three speckled frogs...' and 'were two speckled frogs'. - -### Extension 2 -Make your program work for any number of frogs. diff --git a/day_7/README.md b/day_7/README.md deleted file mode 100644 index c9a053cd5..000000000 --- a/day_7/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Day 7 - Build a Thing! - -Congrats on making it through the first 6 days of Prework! Today, you will put together everything you have learned to actually build a program! Hopefully, this will show you how much you have already accomplished in your first week as a programmer! - -When you have completed the activities for day 7, you will follow instructions to submit your work through a GitHub Pull Request. - -## Open your local copy of backend_mod_1_prework -Using your terminal, open your local copy of the forked repository you created during setup. Hopefully you are getting the hang of this, but revisit [day_1](../day_1) for more detail if needed. - -## Make a Program - -1. Using what you have learned in the last week, complete both of the projects below. Put any files related to the projects you choose in a day_7 directory. - - 1. [FizzBuzz](./fizzbuzz.md) - 1. [10 Speckled Frogs](./10_speckled_frogs.md) - -1. When you are finished with your projects, you should add, commit, and push your changes to GitHub. - -1. Add a `high_level.md` file to your day_7 directory. In that file, write up high level notes about how you would solve one of the following problems. When you're finished writing your detailed notes, you can also choose to code a solution to the problem(s). - - 1. [Ceasar Cipher](./ceasar_cipher.md) - 1. [Checker Board](./checker_board.md) - -1. When you are finished with your high level explanation, you should add, commit, and push your changes to GitHub. - -1. Log in to GitHub, navigate to your remote prework repository and make sure all work from all the days is there! - -## Submission - -When you have completed *all* the activities described above, follow the steps below to submit your technical prework. - -1. Go to *your* prework repository on GitHub - -1. click on `New Pull Request` per the image below: - - ![New PR](https://i.imgur.com/lGKNxwC.png) - -1. On the Pull Request page, make sure you see something similar to below (but with your username): - - ![New PR](https://i.imgur.com/CwJH8os.png) - -1. Click on `Create New Pull Request` (circled in the image above). - -1. Enter `YOUR NAME` as the title of the pull request, and click `Create pull request` as shown below: - - ![Create PR](https://i.imgur.com/CQQzfNc.png) - -1. ***[Please complete this form to submit your prework.](https://forms.gle/wxoVuhHKjrRyvGW2A)*** Be sure to include links to your Gear Up pre-work gist and your technical pre-work GitHub repository. The link to your technical pre-work GitHub repository will look something like: `https://github.com/YOUR_GITHUB_USERNAME/backend_mod_1_prework`. (using your own GitHub username, of course!) - -And with that form submission, ***you're done!!!*** Any feedback after this has been reviewed will be Slacked to you. Can't wait to see you on the first day of class!! - ----------------------------------- - -# Extension (optional, after pre-work completed) - -You've finished your Mod 1 pre-work assignment! - -But there's always more to learn! - -If you're interested in challenging yourself _even more_ and getting a step ahead in your coding abilities before your first day, we recommend working on either: - -- [Turing's ruby exercises repo](https://github.com/turingschool/ruby-exercises) -- [A back-end grad's advice and useful study resources](https://josh.works/turing-backend-prep-01-intro) -- [Credit Check](https://github.com/turingschool-examples/credit_check). - -If you do Credit Check, follow the same steps as you did with your pre-work to fork and clone the repo on to your local computer. diff --git a/day_7/ceasar_cipher.md b/day_7/ceasar_cipher.md deleted file mode 100644 index 7390a70bc..000000000 --- a/day_7/ceasar_cipher.md +++ /dev/null @@ -1,16 +0,0 @@ -## Ceasar Cipher - -Also known as a shift cipher, the Ceasar Cipher is one of the oldest and simplest encoding techniques. A Ceasar Cipher works by shifting the alphabet by a defined number of letters down the alphabet. For example, with a left shift of 3, 'D' would be replaced by 'A', 'E' would be replaced by 'B', and so on. See below for a full alphabet example with a left shift of 3: - -``` -plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ -cipher: XYZABCDEFGHIJKLMNOPQRSTUVW -``` - -Create a file named caesar_cipher.rb and within that file, write a program that will take any string, and encode it based on a shift value provided by the user. The interaction pattern for this program might look something like this: - -``` -cipher = CeasarCipher.new -cipher.encode("Hello World", 5) -=> "CZGGJ RJMGY" -``` diff --git a/day_7/checker_board.md b/day_7/checker_board.md deleted file mode 100644 index e8220394a..000000000 --- a/day_7/checker_board.md +++ /dev/null @@ -1,13 +0,0 @@ -## Checker Board - -Create a file called checker_board.rb and within that file, write a program that will print a checkerboard based on the size *indicated by the user*. On this board, the black spaces will be represented with 'X' and the white spaces will be represented with ' '. An example of the output for a size 6 board would look like this: - -``` -X X X - X X X -X X X - X X X -X X X - X X X - ``` - \ No newline at end of file diff --git a/day_7/fizzbuzz.md b/day_7/fizzbuzz.md deleted file mode 100644 index b2a5a8e4b..000000000 --- a/day_7/fizzbuzz.md +++ /dev/null @@ -1,16 +0,0 @@ -## FizzBuzz - -Create a file named fizzbuzz.rb and within that file, write a program that prints something for each number from 1 to 100 with the following rules: - -* For any number that is a multiple of 3, print 'Fizz' -* For any number that is a multiple of 5, print 'Buzz' -* For any number that is a multiple of both 3 and 5, print 'FizzBuzz' -* For all other numbers, print the number. - -The output of your program will look something like this: -``` -=> 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, ..., 98, Fizz, Buzz -``` - -### Bonus -Can you write the program so that it will run for any range of numbers? diff --git a/final_prep/README.md b/final_prep/README.md new file mode 100644 index 000000000..3b44a4d30 --- /dev/null +++ b/final_prep/README.md @@ -0,0 +1,67 @@ +# Mod 0 Final Prep +Congrats on making it to the Mod 0 Final Prep! Complete the final exercises below and be sure to carefully follow the Pull Request steps to submit your work! + +### Final Technical Prep + +You've learned a ton about some of the core foundations of Javascript! Show us how far you've come by completing the following exercises! You will be using your work from these exercises in your first day of Mod 1! + +- [X] Complete the [Mod Zero Hero Challenge](./mod_zero_hero.rb) +- [X] Complete the [Annotation Challenge](./annotations.rb) + +### Mentorship Prep +Mentorship is an integral part of the Turing experience and will help jumpstart your technical career. In order to get your mentor relationship started on the right foot, please complete the following deliverables: +- [X] Complete the [Mentorship DTR Prep](https://gist.github.com/ericweissman/51965bdcbf42970d43d817818bfaef3c) + - [X] Add link to your gist here: https://gist.github.com/branfull/6147cc3ab0df0b6c8860b0d4c5a3a429 + +### Lesson Prep +You've learned a lot about how to take strong notes during Mod 0. Show us your skills while you learn how to pre-teach content for your first lesson in Mod 1! +- [X] Complete the [Pre Teaching Practice exercise](https://gist.github.com/ericweissman/0036e8fe272c02bd6d4bb14f42fd2f79) gist + - [X] Add a link to your gist here: https://gist.github.com/branfull/4e405b3aaeeb18ec2d98a54e21b92051 + +### Group Work Prep +As part of Turing's project-based learning approach, you will often be working in pairs or larger groups. In order to set yourself (and your team) up for success, it is important to ensure you are prepared to be an equitable contributor and teammate. +- [X] Complete the [DTR Guiding Questions](https://gist.github.com/ericweissman/c56f3a98cdce761808c21d498a52f5c6) + - [X] Add a link to your gist here: https://gist.github.com/branfull/7ed44abb2bd3c8d1f9e0f3b42d22c1c9 + +## All Done? How to Submit your M1 Prework +When you have completed *all* the activities described above, follow the steps below to submit your technical prework. + +1. Go to *your* prework repository on GitHub +1. Click on `New Pull Request` per the image below: + +![New PR](https://i.imgur.com/lGKNxwC.png) + +
+2. On the Pull Request page, make sure you see something similar to below (but with your username): + +![New PR](https://i.imgur.com/CwJH8os.png) + +
+3. Click on `Create New Pull Request` (circled in the image above). +4. Enter `YOUR NAME` as the title of the pull request, and click `Create pull request` as shown below: + +![Create PR](https://i.imgur.com/CQQzfNc.png) + +5. Please complete the form to submit your prework available [here](https://forms.gle/wxoVuhHKjrRyvGW2A). Be sure to include links for your Gear Up pre-work gist and your technical pre-work GitHub repository. The link to your technical pre-work GitHub repository will be in the format https://github.com/YOUR_GITHUB_USERNAME/frontend-mod-1-prework. (using _your_ own GitHub username) + +## Next Steps + +Depending on if you are in Section A or B, you have anywhere between 1.5-3.5 weeks before you start Mod 1. This is an important time to take care of life things such as doctor appointments, dog park trips, quality time with friends and family, etc. It is also important that you maintain the knowledge and skills you acquired during Mod 0 and this pre-work. You can absolutely do both, but to do so successfully, **you need a plan**. We recommend spending, on average, 1-2 hours a day coding (totally 20-40 hours of time). + +What is your plan and how are you going to hold yourself to it? Specifically... +- What are you going to work on? [Resources here](https://github.com/turingschool-examples/fe-m1-practice) +- What days are you going to work? +- What times on those days are you going to work? +- Where you going to be sitting/standing as you do this? +- Where are you documenting this plan? Google Calendar, calendar on your wall, your journal? +- Do any stakeholders in your life know about this plan? (The answer needs to be yes by the time you answer this...) +- What personal items/events are important to you during this time? How are you going to make sure those are not neglected? (Hint, block time on the calendar for them!) + +## Extensions +If you're interested in challenging yourself _even more_ and getting a step ahead in your coding abilities before your first day, we recommend working on either: + +- [Turing's ruby exercises repo](https://github.com/turingschool/ruby-exercises) +- [A back-end grad's advice and useful study resources](https://josh.works/turing-backend-prep-01-intro) +- [Credit Check](https://github.com/turingschool-examples/credit_check). + +If you do Credit Check, follow the [same steps](#forking-the-module-1-prework-repository) as you did previously to fork and clone this repo on to your local computer. diff --git a/final_prep/annotations.rb b/final_prep/annotations.rb new file mode 100644 index 000000000..bd56f5866 --- /dev/null +++ b/final_prep/annotations.rb @@ -0,0 +1,76 @@ +# Add your annotations, line by line, to the code below using code comments. +# Try to focus on using correct technical vocabulary. +# Use the # to create a new comment + +# Build a Bear + +# Defines a method called build_a_bear with name, age, fur, clothes, and special_power as its parameters +def build_a_bear(name, age, fur, clothes, special_power) + # Declares a local greeting variable with a string data type. The string uses interpolation to output name + greeting = "Hey partner! My name is #{name} - will you be my friend?!" + # Declares a local demographics variable with an array data type containing name and age elememnts + demographics = [name, age] + # Declares a local power_saying variable with a string data type. The string uses interpolation to output special_power + power_saying = "Did you know that I can #{special_power}?" + # Declares a local built_bear variable with a hash data type. + built_bear = { + # The string 'basic_info' is the key and the deographics parameter is the value + 'basic_info' => demographics, + # The string 'clothes' is the key and the clothes parameter is the value + 'clothes' => clothes, + # The string 'exterior' is the key and the fur parameter is the value + 'exterior' => fur, + # The string 'cost' is the key and 49.99 is the value + 'cost' => 49.99, + # The string 'sayings' is the key and the array containing the local variable greeting, the local variable power_saying and + # the string "Goodnight my friend!" is the value + 'sayings' => [greeting, power_saying, "Goodnight my friend!"], + # The string 'is_cuddly' is the key and the boolean value true is the value + 'is_cuddly' => true, + } + # Returns the built_bear hash + return built_bear +# Ends the method definition +end + +# Calls the build_a_bear method by passing the appropriate arguments +build_a_bear('Fluffy', 4, 'brown', ['pants', 'jorts', 'tanktop'], 'give you nightmares') +# Calls the build_a_bear method by passing the appropriate arguments +build_a_bear('Sleepy', 2, 'purple', ['pajamas', 'sleeping cap'], 'sleeping in') + + +# FizzBuzz + +# Defines a method called fizzbuzz that has 3 parameters +def fizzbuzz(num_1, num_2, range) + # Iterates i from 1 to the range specified by the range parameter which means it performs the loop range times + (1..range).each do |i| + # if the current (or i'th) number is divisible by num_1 and num_2 + if i % num_1 === 0 && i % num_2 === 0 + # Prints this statement if the conditions in the if statement are met + puts 'fizzbuzz' + # If the previous if-statement conditions are not met, this then checks to see if the + # current (or i'th) number is only divisible by num_1 + elsif i % num_1 === 0 + # Prints this statement if the conditions in the elsif statement are met + puts 'fizz' + # If the previous elsif-statement conditions are not met, this then checks to see if the + # current (or i'th) number is divisible by num_2 + elsif i % num_2 === 0 + # Prints this statement if the conditions in the elsif statement are met + puts 'buzz' + # If none of the previous conditions are met + else + # Prints the current (or i'th) charachter is none of the previous conditions were met + puts i + # Ends the if/elsif/else statments + end + # Ends the loop + end +# Ends the method definition +end + +# Executes the fizzbuzz method by passing in 3 arguments +fizzbuzz(3, 5, 100) +# Executes the fizzbuzz method by passing in 3 arguments +fizzbuzz(5, 8, 400) diff --git a/final_prep/mod_zero_hero.rb b/final_prep/mod_zero_hero.rb new file mode 100644 index 000000000..8bdb38f7a --- /dev/null +++ b/final_prep/mod_zero_hero.rb @@ -0,0 +1,164 @@ +# Challenge - See if you can follow the instructions and complete the exercise in under 30 minutes! + +# Declare two variables - hero_name AND special_ability - set to strings +hero_name = "Superman" +special_ability = "Fly" + +# Declare two variables - greeting AND catchphrase +# greeting should be assigned to a string that uses interpolation to include the hero_name +# catchphrase should be assigned to a string that uses interpolation to include the special_ability +greeting = "Hello #{hero_name}!" +catchphrase = "Let's #{special_ability} outta here" + +# Declare two variables - power AND energy - set to integers +power = 6 +energy = 8 + +# Declare two variables - full_power AND full_energy +# full_power should multiply your current power by 500 +# full_energy should add 150 to your current energy +full_power = power * 500 +full_energy = energy + 150 + + +# Declare two variables - is_human and identity_concealed - assigned to booleans +is_human = false +identity_concealed = true + +# Declare two variables - arch_enemies AND sidekicks +# arch_enemies should be an array of at least 3 different enemy strings +# sidekicks should be an array of at least 3 different sidekick strings +arch_enemies = ["Lex Luthor", "Kryptonite", "Bizarro"] +sidekicks = ["Supergirl", "Superboy", "Earth's yellow sun"] + + +# Print the first sidekick to your terminal +puts sidekicks[0] + +# Print the last arch_enemy to the terminal +puts arch_enemies[-1] + +# Write some code to add a new arch_enemy to the arch_enemies array +arch_enemies[3] = "Batman" + +# Print the arch_enemies array to terminal to ensure you added a new arch_enemey +print arch_enemies +puts "" + +# Remove the first sidekick from the sidekicks array +sidekicks.shift() + +# Print the sidekicks array to terminal to ensure you added a new sidekick +print sidekicks +puts "" + +# Create a function called assess_situation that takes three arguments - danger_level, save_the_day, bad_excuse +# - danger_level should be an integer +# - save_the_day should be a string a hero would say once they save the day +# - bad_excuse should be a string a hero would say if they are too afraid of the danger_level + +# Your function should include an if/else statement that meets the following criteria +# - Danger levels that are above 50 are too scary for your hero. Any danger level that is above 50 should result in printing the bad_excuse to the terminal +# - Anything danger_level that is between 10 and 50 should result in printing the save_the_day string to the terminal +# - If the danger_level is below 10, it means it is not worth your time and should result in printing the string "Meh. Hard pass." to the terminal. +def assess_situation(danger_level, save_the_day, bad_excuse) + if danger_level > 50 + puts "#{bad_excuse}" + elsif danger_level <= 50 && danger_level >= 10 + puts "#{save_the_day}" + else + puts "Meh. Hard pass." + end +end + + + +#Test Cases +announcement = 'Never fear, the Courageous Curly Bracket is here!' +excuse = 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.' +# assess_situation(99, announcement, excuse) > Should print - 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.' +assess_situation(99, announcement, excuse) +#assess_situation(21, announcement, excuse) > should print - 'Never fear, the Courageous Curly Bracket is here!' +assess_situation(21, announcement, excuse) +#assess_situation(3, announcement, excuse) > should print - "Meh. Hard pass." +assess_situation(3, announcement, excuse) + +# Declare a new variable - scary_monster - assigned to an hash with the following key/values +# - name (string) +# - smell (string) +# - weight (integer) +# - citiesDestroyed (array) +# - luckyNumbers (array) +# - address (hash with following key/values: number , street , state, zip) +scary_monster = { + name: "Razor Burn", + smell: "Metallic", + weight: 2, + cities_destroyed: ["London", "Paris", "New York", "Tokyo"], + lucky_numbers: [10, 2, 24, 98], + address: { + number: 123, + street: "Main", + state: "Kansas", + zip: 67226 + } +} + + +# Create a new class called SuperHero +# - Your class should have the following DYNAMIC values +# - name +# - super_power +# - age +# - Your class should have the following STATIC values +# - arch_nemesis, assigned to "The Syntax Error" +# - power_level = 100 +# - energy_level = 50 + +class SuperHero + attr_accessor :name, :energy_level, :power_level + def initialize(name, super_power, age) + @name = name + @super_power = super_power + @age = age + @arch_nemesis = "The Syntax Error" + @power_level = 100 + @energy_level = 50 + end + + # - Create the following class methods + # - say_name, should print the hero's name to the terminal + # - maximize_energy, should update the energy_level to 1000 + # - gain_power, should take an argument of a number and INCREASE the power_level by that number + def say_name + puts "#{name}" + end + + def maximize_energy + self.energy_level = 1000 + end + + def gain_power(number_to_increase) + self.power_level += number_to_increase + end +end + + + + + +# - Create 2 instances of your SuperHero class +the_typist = SuperHero.new("The Typist", "Typing 180 WPM", 84) +matrix = SuperHero.new("Matrix", "Ability to slow things down", 25) + + +# Reflection +# What parts were most difficult about this exerise? +# It was difficult to remember the syntax and layout of functions and classes. + +# What parts felt most comfortable to you? +# I felt very comfortable declaring variables. + +# What skills do you need to continue to practice before starting Mod 1? +# I need to continue to dive into classes and to determine with to use the "@" +# symbol. I also need to make prototypes for classes and functions. diff --git a/section1/README.md b/section1/README.md new file mode 100644 index 000000000..9ee9ce59d --- /dev/null +++ b/section1/README.md @@ -0,0 +1,272 @@ +# Section 1: Super Learners + +Section 1 is estimated to take a total of 6-10 hours to complete. Part C is the longest and most time intensive. This section of pre-work involves reading (both from this document as well as the 📒John Duckett book), 👩‍💻exercises, and 📝reflection questions. Make sure to manage your time well so that should you get stuck and need help, you have plenty of time to do so and meet the deadline. + +- [Vocabulary](#Vocabulary) +- [Part A: Super Learner Habits](#Part-A-Super-Learner-Habits) +- [Part B: Terminal](#Part-B-Terminal) +- [Part C: Ruby Foundations](#Part-C-Ruby-Foundations) + +## Vocabulary + +If you've talked to any alum or near-alum of Turing, one thing they likely shared is "Turing teaches you how to learn". For creators of tech, the learning never ends. Not after graduating a program, not after 20 years of experience. We will provide more support as you are starting out, then release some of that support so you are equipped to learn on your own once you graduate. While we provide more support at the beginning, we also intentionally support you in building skills and habits that will help you do that successfully. + +One of those pieces is in how developers approach vocabulary. Knowing technical vocabulary will allow you to get more out of reading doucmentation and tutorials, and will allow you to communicate well with teams and ask good questions when you need help. Each section of your pre-work (and each lesson once you start Mod 1) will start with a vocabulary section. We don't always give you the definitions - this is intentional. You will create your own definition after having several opportunities to read definitions and see examples. + +Here's what we ask you do: +- Find a special spot in your notebook for vocabulary and JavaScript reserved keywords. Mark it with a post-it or bookmark, so it's easy to find and come back to +- When you start a new section of pre-work, write down each term. Leave plenty of space for (future) notes +- As you read and work through the material you will come across definitions and build an understanding of these terms. Write in definitions, draw diagrams, write out relevant code snippets, etc. If you complete a section and don't have a grasp on a term, that's when it's time to reach out to your pre-work small group or cohort, and collaborate! + +### Vocabulary Terms + +- command +- directory +- code comments +- String +- Number +- Boolean +- variable +- assignment operator +- re-assignment (of a variable) +- interpolation + + +## Part A Super Learner Habits + +Read [this article](https://pubs.ppai.org/pc-today/six-habits-of-super-learners/) about the habits of Super Learners. Reflect on this - what do you already do? Does this make you want to do anything new or different as you beginthis learning journey? Jot down your notes now, and we will ask you to share some reflections with your small group at the end of this section. + +## Part B Terminal + +You will likely spend the majority of your time in Module 1 in either the Terminal or your text editor (Atom). When you're new to programming, the terminal can seem like a scary place, but it has some advantages over other means of interacting with your computer. Perhaps the greatest advantage is that it allows programmers to build tools that they can share with each other without going through the process of creating a graphical user interface. This makes it easy to share code quickly so that it can be used in multiple projects. + +You already have had some exposure to the terminal in [Mod 0, Session 2: Terminal and Command Line](http://mod0.turing.io/session2/#terminal-and-command-line). Let's get a little more practice! + +### Explore and Practice + +Visit the [Turing Terminal](https://learn-terminal.turing.io/) and read through the Learn section as needed. Explore the Playground as needed. + +👩‍💻 Complete all three Challenges. + +### Making Things, Navigating + +#### Commands + +In the following section, you will get a little practice using `touch` and `mkdir` to create files and directories, and `ls` and `cd` to navigate the directory structure and check-in. + +#### Terminal Practice + +👩‍💻 Use `mkdir` and `touch` to create the directories/files in the structure illustrated below: + +```sh +|--secretLibraryProject + | + |--README.md + |--package.json + | + |--lib + | | + | |--secretLibrary.js + | |--secretBook.js + | |--secretLibrarian.js + | |--patron.js + | |--librarySystem.js + | + |--test + | + |--secretLibrary.js + |--secretBook.js + |--secretLibrarian.js + |--patron.js + |--librarySystem.js +``` + +Don't worry about putting any text or content into these files. For now, create this structure with empty files. + +Your first command should be: + +```bash +mkdir secretLibraryProject +``` + +Note that in the command provided above, the dashes preceding the directory name were not used in the actual directory name. The dashes are just used as a diagram aide, and is a common pattern you will see in other documentation. + +### Deleting Things + +#### Commands + +* `rm`: This will remove a file from your system. Be careful with this! The terminal assumes you're a little more of an expert than the system does. This doesn't move the file to the Trash, it removes it completely from your system. It's a little like moving the file to the trash and then deleting it immediately. + +* `rm -rf`: Adding the `-r` and `-f` flags to the `rm` command will allow you to delete directories even if they have other files and/or directories inside of them. For more information on each of these flags enter `man rm` into your terminal. It will print out the manual for this command. + +#### Terminal Practice + +👩‍💻 Use `rm` and `rm -rf` to delete each of the files and directories you created in the `Making Things` section above. + +Note that it would be possible to delete the entire directory that you created with just `rm -rf secretLibrary`. **Don't do this!** At this point it's better for you to delete each of the files and directories individually so that you get some practice with these commands, which will help you remember them better in the long run. The goal here (for this particular exercise) isn't to be efficient and creating and deleting files and directories, it's to *get practice* creating and deleting files and directories. Ultimately this practice will allow you to be more efficient in the future. + +## Part C Ruby Foundations + +In this section, you will begin to learn the basics of Ruby. You will work through several exercises which will help you get comfortable running files and seeing output. You will learn about ways to represent data in Ruby as Strings, Numbers, and Booleans, as well as begin to explore how to capture and work with that data. + +At the end of the section, you will use several Git commands to save your work to your local Git repository. Then you will push your updates to your remote GitHub repository. For now, we are building muscle memory with git commands and getting used to seeing what output they produce. We will dive deeper into the inner workings of Git later. For now, all you need to do is follow along and know that we are using Git to save our work, and GitHub to put it on the internet. + +### Open your local copy of backend-mod-1-prework in Atom + +Using your terminal, open the local copy of this repository. To do this, enter these commands into your terminal (this may vary slightly depending on the names of your directories): + +``` +cd ~ +ls +cd turing +ls +cd 0module +ls +cd backend-mod-1-prework +ls +cd section1 +ls +atom . +``` + +This will open the `section1` directory in Atom. You should be able to see the directory and its contents in the file explorer on the left side of your Atom window. + +### An Introduction to Ruby + +[Read This Introduction](https://learnrubythehardway.org/book/intro.html) to the Learn Ruby The Hard Way Tutorial. To reiterate this introduction, ***DO NOT*** copy and paste code examples when working through lessons in your prework. Actually type each of them out. + +### Ruby Basics Lessons + +1. Next, you will complete several lessons from the Learn Ruby the Hard Way Tutorial. *For ***each*** lesson* ***follow these directions closely***: + + 1. Create a file within your `section1` directory that will contain this lesson's work. Verify that you are within the directory by using terminal command `pwd`. If you are not, `cd` into your `section1` directory. Once you are there, use the `touch` command in your terminal to create a file. For the first lesson, name this file `ex1.rb`. For each subsequent lesson, use `ex2.rb`, `ex3.rb`, so on, so forth. + + 1. Work through the lesson, **typing** the code into your file, and running it in the terminal with `ruby ex1.rb`, replacing `ex1` with the actual file name of what you'd like to run. Make sure the output you get is similar to what the lesson shows. If you get an error saying "No such file or directory", be sure to verify the directory you are located in via the terminal- running command `ls` should show the file you are trying to run. + + 1. Complete the Study Drills listed at the end of the lesson. + + 1. Read the Common Student Questions section. + +1. Check off the items below as you complete the steps you just read for each lesson. ***Remember to create a file containing your work for each lesson!*** + + - [ ] [A Good First Program](https://learnrubythehardway.org/book/ex1.html) + + - [ ] [Comments in Code](https://learnrubythehardway.org/book/ex2.html) + + - [ ] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html) + + - [ ] [Variables and Names](https://learnrubythehardway.org/book/ex4.html) + + - [ ] [Strings](https://learnrubythehardway.org/book/ex5.html) + + - [ ] [More Strings](https://learnrubythehardway.org/book/ex6.html) + + - [ ] [Asking for Input](https://learnrubythehardway.org/book/ex11.html) + + +1. Work through the [Strings](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#3.-strings) and [Numbers](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#5.-numbers) sections from Ruby in 100 Minutes. For each of these sections, open an `irb` session by typing `irb` into your terminal and type in the code snippets provided. + +## Exercises +- Each section contains an exercises directory containing files where you will practice writing code. + +Work through the files in the section1/exercises directory. Complete them in this order: + +1. strings +1. numbers +1. variables +1. interpolation +1. loops + +## Questions +- Each day contains a questions.md file where you will answer questions about what you have learned. + +Answer the day 1 questions within the questions.md file. The `.md` file extension refers to markdown formatting. Markdown is a simple markup language to help format your text. [This article](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) shows everything you need for basic markdown formatting. + + +## Save your work in Git + +When you are finished with all of the `section1` exercises and reflections, follow these steps in order to save your work to your local git repository. + +1. Make sure you are in your `section1` directory. When you run `ls` in your terminal, you should see the `exercises` directory listed, as well as `README.md`, `reflection.md`, etc. +2. In your terminal, run `git status`. You should see output like this: + +``` +On branch main +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: exercises/interpolation.rb + modified: exercises/numbers.rb + modified: exercises/variables.rb + modified: reflection.md + +no changes added to commit (use "git add" and/or "git commit -a") +``` + +The command `git status` shows us information about files we changed. Don't worry too much about understanding what this all means just yet. What's important is that you get comfortable typing `git status` often. + +3. Run `git add reflection.md`. +4. Run `git status`. Your status should now look a little different: + +```On branch main +Changes to be committed: + (use "git reset HEAD ..." to unstage) + + modified: reflection.md + +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: exercises/interpolation.rb + modified: exercises/numbers.rb + modified: exercises/variables.rb +``` + +Under "Changes to be committed", It now lists "reflection.md". This means that git is getting ready to save this file. We want to do this for each file. + +5. Run `git add exercises`. +6. Run `git status`. You should now see all those exercises files listed under "Changes to be committed". We just used `git add ` to add all the files located in a directory. +7. Run `git status`. You should now see all your files listed under "Changes to be committed". If there are any files listed under "Untracked files" or "Changes not staged for commit", add them using "git add ". +8. Run `git commit -m "Add Section 1"`. +9. Run `git status`. You should see this output: + +``` +On branch main +nothing to commit, working tree clean +``` + +Congratulations! You just saved your work to Git! If `git status` is showing any files, add them with `git add ` and commit them with `git commit -m "Add Section 1"`. + +### Push to GitHub + +You've saved your work to Git on your local machine, but it is not yet accessible through your remote GitHub repository. Updating our remote GitHub repository with our local changes is called pushing. Push your code with the following command: + +``` +git push origin main +``` + +You should see output _similar_ to this: + +``` +Counting objects: 9, done. +Delta compression using up to 4 threads. +Compressing objects: 100% (8/8), done. +Writing objects: 100% (9/9), 1.03 KiB | 1.03 MiB/s, done. +Total 9 (delta 2), reused 0 (delta 0) +remote: Resolving deltas: 100% (2/2), completed with 1 local object. +To github.com:your-username/frontend_mod_1_prework.git + e8ebd7a..32c0ed3 main -> main +``` + +You should now be able to log in to GitHub, navigate to your remote prework repository and see all the work you did in this section! + +## Index Links + +- [Vocabulary](#Vocabulary) +- [Part A: Super Learner Habits](#Part-A-Super-Learner-Habits) +- [Part B: Terminal](#Part-B-Terminal) +- [Part C: Ruby Foundations](#Part-C-Ruby-Foundations) + +🚀 [Go to Section 2](../section2) diff --git a/section1/exercises/booleans.rb b/section1/exercises/booleans.rb new file mode 100644 index 000000000..299da8b63 --- /dev/null +++ b/section1/exercises/booleans.rb @@ -0,0 +1,18 @@ +#------------------- +# BOOLEANS +#------------------- + +# EXAMPLE: log to the console the result of 1 is equal to 2: +puts 1 == 2 + +# EXAMPLE: log to the console the result of 7 is greater than 2: +puts 7 > 2 + +# YOU DO: log to the console the result of "hello" is equal to "Hello": +puts "hello" == "Hello" + +# YOU DO: log to the console the result of 3 is not equal to 4: +puts 3 != 4 + +# YOU DO: log to the console the result of 4 is less than or equal to 5: +puts 4 <= 5 diff --git a/day_1/exercises/interpolation.rb b/section1/exercises/interpolation.rb similarity index 52% rename from day_1/exercises/interpolation.rb rename to section1/exercises/interpolation.rb index c7f4f47df..73d48044e 100644 --- a/day_1/exercises/interpolation.rb +++ b/section1/exercises/interpolation.rb @@ -1,25 +1,36 @@ # In the below exercises, write code that achieves # the desired result. To check your work, run this # file by entering the following command in your terminal: -# `ruby day_1/exercises/interpolation.rb` +# `ruby section1/exercises/interpolation.rb` # Example: Write code that uses the variables below to form a string that reads # "The Chudley Cannons are Ron's favorite Quidditch team": name = "Ron" team = "Chudley Cannons" -p "The #{team} are #{name}'s favorite Quidditch team" +puts "The #{team} are #{name}'s favorite Quidditch team" # Write code that uses the variables below to form a string that reads # "The quick red fox jumped over the lazy brown dog": speedy = "quick red fox" slow_poke = "lazy brown dog" -p # YOUR CODE HERE +puts "The #{speedy} jumped over the #{slow_poke}" # Write code that uses the variables below to form a string that reads # "In a predictable result, the tortoise beat the hare!": slow_poke = "tortoise" speedy = "hare" -# YOUR CODE HERE + +puts "In a predictable result, the #{slow_poke} beat the #{speedy}!" + + +# YOU DO: +# Declare three variables, name/content/data type of your choice. Think carefully about what you name the variables. Remember, the goal is to be concise but descriptive (it's a hard balance!) Then, log out ONE sentence that incorporates all THREE variables. + +bad = "worst" +da_clink = "prison" +soul_suckers = "dementors" + +puts "The #{bad} part about #{da_clink} was the #{soul_suckers}." diff --git a/day_1/exercises/loops.rb b/section1/exercises/loops.rb similarity index 62% rename from day_1/exercises/loops.rb rename to section1/exercises/loops.rb index 90dc15ab1..e16c75c16 100644 --- a/day_1/exercises/loops.rb +++ b/section1/exercises/loops.rb @@ -1,18 +1,26 @@ # In the below exercises, write code that achieves # the desired result. To check your work, run this # file by entering the following command in your terminal: -# `ruby day_1/exercises/loops.rb` +# `ruby section1/exercises/loops.rb` # Example: Write code that prints your name five times: 5.times do - p "Hermione Granger" + puts "Hermione Granger" end # Write code that prints the sum of 2 plus 2 seven times: 7.times do - # YOUR CODE HERE + puts 2 + 2 end # Write code that prints the phrase 'She sells seashells down by the seashore' # ten times: -# YOUR CODE HERE +10.times do + puts "She sells seashells down by the seashore" +end + + +# Write code that prints the result of 5 + 7 a total of 9 timees +9.times do + puts 5 + 7 +end diff --git a/day_1/exercises/numbers.rb b/section1/exercises/numbers.rb similarity index 81% rename from day_1/exercises/numbers.rb rename to section1/exercises/numbers.rb index 9a5468a31..3cc700191 100644 --- a/day_1/exercises/numbers.rb +++ b/section1/exercises/numbers.rb @@ -1,16 +1,16 @@ # In the below exercises, write code that achieves # the desired result. To check your work, run this # file by entering the following command in your terminal: -# `ruby day_1/exercises/numbers.rb` +# `ruby section1/exercises/numbers.rb` # Example: Write code that prints the result of the sum of 2 and 2: -p 2 + 2 +puts 2 + 2 # Write code that prints the result of 7 subtracted from 83: -p #YOUR CODE HERE +puts 83 - 7 # Write code that prints the result of 6 multiplied by 53: -# YOUR CODE HERE +puts 6 * 53 # Write code that prints the result of the modulo of 10 into 54: -# YOUR CODE HERE +puts 54 % 10 diff --git a/day_1/exercises/strings.rb b/section1/exercises/strings.rb similarity index 60% rename from day_1/exercises/strings.rb rename to section1/exercises/strings.rb index f2f903ffc..0b4a162ff 100644 --- a/day_1/exercises/strings.rb +++ b/section1/exercises/strings.rb @@ -1,13 +1,16 @@ # In the below exercises, write code that achieves # the desired result. To check your work, run this # file by entering the following command in your terminal: -# `ruby day_1/exercises/strings.rb` +# `ruby section1/exercises/strings.rb` # Example: Write code that prints your name to the terminal: -p "Alan Turing" +puts "Brant Fuller" # Write code that prints `Welcome to Turing!` to the terminal: -p #YOUR CODE HERE +puts "Welcome to Turing!" # Write code that prints `99 bottles of pop on the wall...` to the terminal: -# YOUR CODE HERE +puts "99 bottles of pop on the wall..." + +# Write out code to log one line from your favorite song or movie. +puts "I'm a peacock. You gotta let me fly." diff --git a/section1/exercises/variables.rb b/section1/exercises/variables.rb new file mode 100644 index 000000000..ab9c2d503 --- /dev/null +++ b/section1/exercises/variables.rb @@ -0,0 +1,75 @@ +# In the below exercises, write code that achieves +# the desired result. To check your work, run this +# file by entering the following command in your terminal: +# `ruby section1/exercises/variables.rb` + +# Example: Write code that saves your name to a variable and +# prints what that variable holds to the terminal: +name = "Brant" +puts name + +# Write code that saves the string 'Dobby' to a variable and +# prints what that variable holds to the terminal: +house_elf = "Dobby" +puts house_elf + +# Write code that saves the string 'Harry Potter must not return to Hogwarts!' +# and prints what that variable holds to the terminal: +warning = 'Harry Potter must not return to Hogwarts!' +puts warning + +# Write code that adds 2 to the `students` variable and +# prints the result: +students = 22 +students += 2 +puts students + +# Write code that subracts 2 from the `students` variable and +# prints the result: +students -= 2 +puts students + + +# YOU DO: +# Declare three variables, named `first_name`, `is_hungry` and `number_of_pets`. +# Store the appropriate data types in each. +first_name = "Brant" +is_hungry = true +number_of_pets = 0 + +# IN WORDS: +# How did you decide to use the data type you did for each of the three variables above? + +# If I were to add a question mark to the end of each variable, I could see the +# appropriate data type. When prompting for a first name, a string is the appropriate response. +# When asking if you are hungry, you might respond with yes or no. That is a true/false answer +# which is perfect for a boolean. Also, many boolean variables start with is_ or has_. +# number_of_pets has 'number' right there in the name. + + +# YOU DO: +# Re-assign the values to the three variables from the previous challenge to different values (but same data type). +# print all three variables to the terminal. +first_name = "Clark" +is_hungry = false +number_of_pets = 1 + +puts first_name +puts is_hungry +puts number_of_pets + + +# YOU DO: +# Using the variables below, print the total number of snacks to the terminal: +healthy_snacks = 6; +junk_food_snacks = 8; + +puts healthy_snacks + junk_food_snacks + + +#------------------- +# FINAL CHECK +#------------------- + +# Did you run this file in your terminal to make sure everything printed out to the terminal + # as you would expect? diff --git a/day_0/images/finder.png b/section1/images/finder.png similarity index 100% rename from day_0/images/finder.png rename to section1/images/finder.png diff --git a/day_0/images/spotlight.png b/section1/images/spotlight.png similarity index 100% rename from day_0/images/spotlight.png rename to section1/images/spotlight.png diff --git a/day_0/images/terminal.png b/section1/images/terminal.png similarity index 100% rename from day_0/images/terminal.png rename to section1/images/terminal.png diff --git a/section1/practice_exercises/ex1.rb b/section1/practice_exercises/ex1.rb new file mode 100644 index 000000000..5f2c98470 --- /dev/null +++ b/section1/practice_exercises/ex1.rb @@ -0,0 +1,8 @@ +puts "Hello World!" +puts "Hello Again" +puts "I like typing this." +puts "This is fun." +puts "Yay! Printing." +puts "I'd much rather you 'not'." +puts 'I "said" do not touch this.' +puts "One more line." diff --git a/section1/practice_exercises/ex2.rb b/section1/practice_exercises/ex2.rb new file mode 100644 index 000000000..dffb2b27c --- /dev/null +++ b/section1/practice_exercises/ex2.rb @@ -0,0 +1,9 @@ +# A comment, this is so you can read your program later. +# Anything after the # is ignored by ruby. + +puts "I could have code like this." # and the comment after is ignored + +# You can also use a comment to "disable" or comment out a piece of code: +# puts "This won't run." + +puts "This will run." diff --git a/section1/practice_exercises/ex3.rb b/section1/practice_exercises/ex3.rb new file mode 100644 index 000000000..5c371d1f4 --- /dev/null +++ b/section1/practice_exercises/ex3.rb @@ -0,0 +1,37 @@ +# This line prints the string +puts "I will now count my chickens:" + +# This line counts the hens and interpolates a mathematical expression +puts "Hens #{25.0 + 30.0 / 6.0}" +# This line counts the Roosters and interpolates a mathematical expression +puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}" + +# This line prints the string +puts "Now I will count the eggs:" + +# This line computes and prints a mathematical expression +puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0 + +# This line prints the string +puts "Is it true that 3 + 2 < 5 - 7?" + +# This line computes and prints a comparitive expression +puts 3.0 + 2.0 < 5.0 - 7.0 + +# This line prints a string and interpolates a mathematical expression +puts "What is 3 + 2? #{3.0 + 2.0}" +# This line prints a string and interpolates a mathematical expression +puts "What is 5 - 7 #{5.0 - 7.0}" + +# This line prints a string +puts "Oh, that's why it's false." + +# This line prints a string +puts "How about some more." + +# This line prints a string and interpolates a comparitive expression +puts "Is it greater #{5.0 > -2.0}" +# This line prints a string and interpolates a comparitive expression +puts "Is it greater or equal? #{5.0 >= -2.0}" +# This line prints a string and interpolates a include comparitive expression +puts "Is it less or equal? #{5.0 <= -2.0}" diff --git a/section1/practice_exercises/ex3_math_drill.rb b/section1/practice_exercises/ex3_math_drill.rb new file mode 100644 index 000000000..c09446271 --- /dev/null +++ b/section1/practice_exercises/ex3_math_drill.rb @@ -0,0 +1 @@ +puts 365 / 5.0 diff --git a/section1/practice_exercises/ex4.rb b/section1/practice_exercises/ex4.rb new file mode 100644 index 000000000..e695b3bfa --- /dev/null +++ b/section1/practice_exercises/ex4.rb @@ -0,0 +1,25 @@ +# This assigns the number 100 to the variable cars +cars = 100 +# This assigns the float 4.0 to the variable space_in_a_car +space_in_a_car = 4.0 +# This assigns the integer 30 to the variable drivers +drivers = 30 +# This assigns the integer 90 to the variable passengers +passengers = 90 +# Assigns the difference of cars and drivers to the vairiable cars_not_driven +cars_not_driven = cars - drivers +# Assigns drivers to the variable cars_driven +cars_driven = drivers +# Assigns the product of cars_driven and space_in_a_car to the varialbe +# carpool_capacity +carpool_capacity = cars_driven * space_in_a_car +# Assigns the quotient of passengers / cars_driven to average_passengers_per_car +average_passengers_per_car = passengers / cars_driven + + +puts "There are #{cars} cars available." +puts "There are only #{drivers} drivers available." +puts "There will be #{cars_not_driven} empty cars today." +puts "We can transport #{carpool_capacity} people today." +puts "We have #{passengers} to carpool today." +puts "We need to put about #{average_passengers_per_car} in each car." diff --git a/section1/practice_exercises/ex5.rb b/section1/practice_exercises/ex5.rb new file mode 100644 index 000000000..49e513dd1 --- /dev/null +++ b/section1/practice_exercises/ex5.rb @@ -0,0 +1,17 @@ +name = 'Zed A. Shaw' +age = 35 # not a lie in 2009 +height = 74 * 2.54 # cm +weight = 180 / 2.2 # kg +eyes = 'Blue' +teeth = 'White' +hair = 'Brown' + +puts "Let's talk about #{name}." +puts "He's #{height} cm tall." +puts "He's #{weight} kg heavy." +puts "Actually that's not too heavy." +puts "He's got #{eyes} eyes and #{hair} hair." +puts "His teeth are usually #{teeth} depending on the coffee." + +# this line is tricky, try to get it exactly right +puts "If I add #{age}, #{height}, and #{weight} I get #{age + height + weight}." diff --git a/section1/practice_exercises/ex6.rb b/section1/practice_exercises/ex6.rb new file mode 100644 index 000000000..27a3d0fc3 --- /dev/null +++ b/section1/practice_exercises/ex6.rb @@ -0,0 +1,37 @@ + +# This assigns the number 10 to a variable +types_of_people = 10 +# Asigns a string with an interpolation to a variable +x = "There are #{types_of_people} types of people." +# Assigns a string to a variable +binary = "binary" +# Assigns a string to a variable +do_not = "don't" +# Assigns a string with interpolation to a variable +y = "Those who know #{binary} and those who #{do_not}." + +# Prints a variable with string data type +puts x +# Prints a variable with string data type +puts y + +# Prints string with interpolation +puts "I said: #{x}." +# Prints string with interpolation +puts "I also said: '#{y}'." + +# Assigns boolean data type to variable +hilarious = false +# Assigns string with interpolation to a variable +joke_evaluation = "Isn't that joke so funny?! #{hilarious}" + +# Prints variable with string data type +puts joke_evaluation + +# Assigns string to a variable +w = "This is the left side of..." +# Assigns string to a variable +e = "a string with a right side." + +# prints two variables with string data types to create one long string +puts w + e diff --git a/section1/practice_exercises/ex7.rb b/section1/practice_exercises/ex7.rb new file mode 100644 index 000000000..4bd3b1902 --- /dev/null +++ b/section1/practice_exercises/ex7.rb @@ -0,0 +1,8 @@ +print "How old are you? " +age = gets.chomp +print "How tall are you? " +height = gets.chomp +print "How much do you weigh? " +weight = gets.chomp + +puts "So, you're #{age} old, #{height} tall and #{weight} heavy." diff --git a/section1/reflection.md b/section1/reflection.md new file mode 100644 index 000000000..f96793ee8 --- /dev/null +++ b/section1/reflection.md @@ -0,0 +1,39 @@ +## Section 1 Reflection + +1. How did the SuperLearner Article resonate with you? What from this list do you already do? Want to start doing or do more of? Is there anything not on this list, that you would add to it? + +I was pleasantly surprised to find that I already have several of the SuperLearner attributes. I think that is why my first response was that the article was underwhelming. I already read a good amount everyday but that is usually news and not in the form of fiction or non-fiction novels. I really enjoy teaching others what I know or what I’ve discovered. I have seen it in many forms. I have taught my classmates as we were studying for tests in college. When I find a new concept, I love to share it with my brother or any of my friends I think may enjoy that information as well. I take short breaks early and often which I always thought was a form of laziness. For the most part I enjoy the journey of learning. That is evident by looking at my 3 undergraduate degrees. I typically watch YouTube or read articles in order to learn and stay informed rather than just to seek entertainment. I mostly eat a very healthy diet thanks to my wife, but I think it would be simple to make small tweaks to have my diet geared toward anti-cognitive decline. I love the idea of growth and improvement but maybe I should take steps to gamify my growth. I think the idea of trying to break stuff to learn how it works or the idea of being curious enough to figure out how something works is another thing that SuperLearners do. + +1. How would you print the string `"Hello World!"` to the terminal? + +`puts "Hello World!"`` + +1. What character is used to indicate comments in a ruby file? + +`#` + +1. Explain the difference between an integer and a float? + +An integer is a whole number where a float has a decimal point + +1. In the space below, create a variable `animal` that holds the string `"zebra"` + +`animal = "zebra"` + +1. How would you print the string `"zebra"` using the variable that you created above? + +`puts animal` + +1. What is interpolation? Use interpolation to print a sentence using the variable `animal`. + +Interpolation is a way to insert data into a string by referencing that data through a variable. + +`puts "Every time I travel from Lubbock to Austin, I have to look for the #{animal}s in Zephyr!"` + +1. What method is used to get input from a user? + +`gets.chomp` will get input from a method but will not include `\n` in the input. + +1. Name and describe two common string methods: +`.split()` splits a string into an array. The elements inside the created array are split based on the input in the `.split()` method. +`.length` returns the number of characters in the string. diff --git a/section2/README.md b/section2/README.md new file mode 100644 index 000000000..b81832248 --- /dev/null +++ b/section2/README.md @@ -0,0 +1,117 @@ +# Section 2 - Asking Questions + +Section 2 is estimated to take a total of 8-12 hours to complete. Similar to Section 1, this section of pre-work involves 📒reading, 👨🏽‍💻exercises, and 📝reflection questions. Make sure to manage your time well so that should you get stuck and need help, you have plenty of time to do so and meet the deadline. + +- [Vocabulary](#Vocabulary) +- [Part A: Asking Questions](#Part-A-Asking-Questions) +- [Part B: Conditionals](#Part-B-If-Statements-and-Conditionals) +- [Part C: Methods](#Part-C-Methods) + +## Vocabulary + +This section will introduce a number of new terms, that may feel a bit more complex. Write these terms and reserved keywords in that special spot in your notebook now. Work to hold yourself acocuntable to updating definitions _as you work through this section_. + +### Vocabulary Terms + +- if statements +- method + +## Get Set Up + +Using your terminal, open the local copy of the repository that you created during setup. To do this, you will need to use the terminal command `cd` to change into the directory that holds the repository. Once you are in the correct directory, use the terminal command `atom .` to open the prework repository. If you are having trouble with this, see the `section1` instructions. + +## Part A Asking Questions + +If you've made it into Section 2 of the pre-work, we hope that you've heard us say loud and clear, that asking questions is a good and important thing to do! That doesn't mean it's easy, though. Some of us have educational experiences that tell us otherwise, some of us have had bad experiences when being vulnerable and asking questions, and sometimes it's just hard to determine which words to use to formulate the question itself! + +Read the three blog posts that follow: +* [It's okay to ask questions](https://dev.to/mporam/its-okay-to-ask-questions-43hf) +* [Asking better questions](https://dev.to/josefine/asking-better-questions-2e2k) +* [Your Questions Are Dumb; Ask Them Anyway](https://dev.to/kathryngrayson/your-questions-are-dumb-ask-them-anyway-3cm6) + +Reflect on these posts, and how you feel about asking questions (specifically, technical questions as you enter your technical work at Turing). How might this positively or negatively impact your growth? + +It's going to take some time to find that balance between googling and pushing yourself to solve a problem without hand-holding, and reaching out for help. That's ok! be patient with yourself. The way you will find that balance is by being cognizant and aware of how you currently operate. Keep this on your mind as you work through this section, and... there is no time like the present to start asking questions! + +Now that you understand the importance of asking questions, read the [Turing guide on asking questions](https://gist.github.com/ericweissman/fb0241e226227867b6bc70a4d49227f5) to ensure that you know the best way to ask the questions you may have! + +## Part B If Statements and Conditionals + + +One of the most important concepts in computer programming is knowing when and how to tell the computer to do either _one_ thing or _another_ thing based on a set of simple criteria. We accomplish this with ***If-Statements*** and ***Conditionals***, which you will learn about today. + +When you are all done with the lessons, exercises, and questions for today, you will once again use git to save your work locally, and then send your work to Github. + +### Open your local copy of backend_mod_1_prework + +Using your terminal, open your local copy of the forked repository you created during setup. To do this, you will need to use the terminal command `cd` to enter the directory that holds the repository. Once you are in the correct directory, use the terminal command `atom .` to open the prework repository. + +### If statement and Conditional Lessons + +1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory. + + - [ ] [What If?](https://learnrubythehardway.org/book/ex29.html) from Learn Ruby the Hard Way. + + - [ ] [Else and If](https://learnrubythehardway.org/book/ex30.html) from Learn Ruby the Hard Way. + + - [ ] [Making Decisions](https://learnrubythehardway.org/book/ex31.html) from Learn Ruby the Hard Way. + + - [ ] [Conditionals](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#9.-conditionals) from Ruby in 100 Minutes. + +1. Work through the if_statements.rb file in the section2/exercises directory. + +1. Answer the questions in the reflection.md file in the section2 directory. + +## Part C Methods + +1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory. + + _*Note*: In some of these lessons, the author refers to methods as functions. They are interchangable here, but at Turing, we will be use the word `method`._ + + - [ ] [Methods](https://launchschool.com/books/ruby/read/methods) from LaunchSchool. Work up to the `obj.method or method(obj)` header. + + - [ ] [Intro to Methods](https://learnrubythehardway.org/book/ex18.html) from Learn Ruby the Hard Way. + + - [ ] [Methods and Variables](https://learnrubythehardway.org/book/ex19.html) from Learn Ruby the Hard Way. + + - [ ] [Methods and Return Values](https://learnrubythehardway.org/book/ex21.html) from Learn Ruby the Hard Way. + +1. Work through the methods.rb file in the section2/exercises directory. + +1. Answer the questions in the reflection.md file in the section2 directory. + +## Vocabulary + +Look back at that special spot in your notebook for vocabulary. Hopefully you updated it with definitions, diagrams, and code samples as you went through this section. If not, do so now. This will be part of this sections deliverables. + +## Relections + +📝 Answer the prompts in the `reflection.md` file in the `section2` directory. If you need a reminder on how to format your markdown, [this is the Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)! + +## Save your work in Git + +When you are finished with all of the `section2` activities, use your terminal to run the following commands in order to save your work to your local Git repository. + +1. `$ git add section2/exercises` +2. `$ git add section2/reflection.md` +3. `$ git status` - you should see only green filenames - if you see any that are red, continue to `git add` those files until `git status` shows all green files. +4. `$ git commit -m "Add Section 2 work"` + +## Push to Github + +You've save your work to git on your local machine, but it is not yet accessible through your remote GitHub repository. Updating our remote GitHub repository with our local changes is called **pushing**. Push your code with the following command: + +``` +git push origin main +``` + +You should now be able to log in to GitHub, navigate to your remote prework repository and see all the work you did in this section! + +## Index Links + +- [Vocabulary](#Vocabulary) +- [Part A: Asking Questions](#Part-A-Asking-Questions) +- [Part B: Conditionals](#Part-B-If-Statements-and-Conditionals) +- [Part C: Methods](#Part-C-Methods) + +🚀 [Go to Section 3](../section3) diff --git a/section2/exercises/ex1.rb b/section2/exercises/ex1.rb new file mode 100644 index 000000000..1bcf231f6 --- /dev/null +++ b/section2/exercises/ex1.rb @@ -0,0 +1,36 @@ +people = 20 +cats = 30 +dogs = 15 + + +if people < cats + puts "Too many cats! The world is doomed!" +end + +if people > cats + puts "Not many cats! The world is saved!" +end + +if people < dogs + puts "The world is drooled on!" +end + +if people > dogs + puts "The world is dry!" +end + + +dogs += 5 + +if people >= dogs + puts "People are greater than or equal to dogs." +end + +if people <= dogs + puts "People are less than or equal to dogs." +end + + +if people == dogs + puts "People are dogs." +end diff --git a/section2/exercises/ex2.rb b/section2/exercises/ex2.rb new file mode 100644 index 000000000..b9bb67d21 --- /dev/null +++ b/section2/exercises/ex2.rb @@ -0,0 +1,53 @@ +# Assigns integer to a people variable +people = 30 +# Assigns integer to a cars variable +cars = 31 +# Assigns integer to a trucks variable +trucks = 32 + + + +# Decides if the instance of cars are greater than people and +# cars are greater than trucks +if cars > people && cars > trucks + # Prints this statement if the if condition is satisfied + puts "We should take the cars." + # If the if statement condition is not satisfied, look to this + # condition of whether the cars are less than the number of people +elsif cars < people + # Prints this statement if this second condition is satisfied + puts "We should not take the cars." + # If neither of the if conditions are met, procede with this block +else + # Prints this statement if none of the previous conditions are satisfied + puts "We can't decide." + # End the if/elseif block +end + +# Decides if the instance of trucks are greater than cars +if trucks > cars + # Prints this statement if trucks are greater than cars + puts "That's too many trucks." + # If the trucks are not greater than cars, check to see if + # the trucks are less than cars +elsif trucks < cars + # Prints this statement if trucks are less than cars + puts "Maybe we could take the trucks." + # If the trucks are neither greater than or less than cars + # execute this block +else + # Prints this statement + puts "We still can't decide." + # Ends the if/elseif block +end + +# Checks to see if there are more people than trucks +if people > trucks + # Prints this statement if there are more people than trucks + puts "Alright, lets just take the trucks." + # If people aren't greater than trucks, enter this block +else + # Prints this statemetn if people aren't greater than trucks + puts "Fine, let's stay home then." + # Ends the if/elseif block +end diff --git a/section2/exercises/ex3.rb b/section2/exercises/ex3.rb new file mode 100644 index 000000000..c436b98c9 --- /dev/null +++ b/section2/exercises/ex3.rb @@ -0,0 +1,42 @@ +puts "You enter a dark room with two doors. Do you go through door #1 or door #2?" + +print "> " +door = $stdin.gets.chomp + +if door == "1" + puts "There's a giant bear here eating a cheese cake. What do you do?" + puts "1. Take the cake." + puts "2. Scream at the bear." + puts "3. Take a picture." + + print "> " + bear = $stdin.gets.chomp + + if bear == "1" + puts "The bear eats your face off. Good job!" + elsif bear == "2" + puts "The bear eats your legs off. Good job!" + elsif bear == "3" + puts "No one will believe you if it's not on the gram. Good Job!" + else + puts "Well, doing %s is probably better. Bear runs away." % bear + end + +elsif door == "2" + puts "You stare into the endless abyss at Cthulu's retna." + puts "1. Blueberries." + puts "2. Yellow jacket clothespins." + puts "3. Understanding revolvers yelling melodies." + + print "> " + insanity = $stdin.gets.chomp + + if insanity == "1" || insanity == "2" + puts "Your body survives powered by a mind of jello. Good Job!" + else + puts "The insanity rots your eyes into a pool of muck. Good Job!" + end + +else + puts "You stumble around and fall on a knife and die. Good Job!" +end diff --git a/section2/exercises/ex3_bonus.rb b/section2/exercises/ex3_bonus.rb new file mode 100644 index 000000000..6071e84e3 --- /dev/null +++ b/section2/exercises/ex3_bonus.rb @@ -0,0 +1,47 @@ +puts "You need to pick out your outfit for the day. Do you want to (1) look fancy or (2) dress comfortably?" + +print "> " +choice = $stdin.gets.chomp + +if choice == "1" + puts "1. Black-tie" + puts "2. Business" + puts "3. Business Casual" + puts "4. Smart Casual" + + print "> " + fancy = $stdin.gets.chomp + + if fancy == "1" + puts "Where do you even buy something like this? Good luck!" + elsif fancy == "2" + puts "Are you applying for a loan? Good luck!" + elsif fancy == "3" + puts "Perfect, you can hit the golf course after work. Good luck!" + elsif fancy == "4" + puts "What even is smart casual? You'd better start Googling. Good Luck!" + else + puts "I thought we were getting fancy today?" + end + +elsif choice == "2" + puts "1. Athleasure" + puts "2. Cargo shorts" + puts "3. Sweats" + + print "> " + casual = $stdin.gets.chomp + + if casual == "1" + puts "You never know when you'll need to break into a workout. Smart!" + elsif casual == "2" + puts "You always want a place to keep your bottle openers. Smart!" + elsif casual == "3" + puts "Who are we kidding ourselves? No one will see us on camera. Smart!" + else + puts "Staying in bed means less laundry to do. Smart!" + end + +else + puts "Decisions are hard. Get some coffee." +end diff --git a/section2/exercises/ex4.rb b/section2/exercises/ex4.rb new file mode 100644 index 000000000..c9c80fca6 --- /dev/null +++ b/section2/exercises/ex4.rb @@ -0,0 +1,8 @@ +def say(words='hello') + puts words + '.' +end + +say() +say("hi") +say("how are you") +say("I'm fine") diff --git a/section2/exercises/ex5.rb b/section2/exercises/ex5.rb new file mode 100644 index 000000000..2e27229b1 --- /dev/null +++ b/section2/exercises/ex5.rb @@ -0,0 +1,26 @@ +# this one is like your scripts with ARGV +def print_two(*args) + arg1, arg2 = args + puts "arg1: #{arg1}, arg2: #{arg2}" +end + +# ok, that *args is actually pointless, we can just do this +def print_two_again(arg1, arg2) + puts "arg1: #{arg1}, arg2: #{arg2}" +end + +# this just takes one argument +def print_one(arg1) + puts "arg1: #{arg1}" +end + +# this one takes no arguments +def print_none() + puts "I got nothin'." +end + + +print_two("Zed", "Shaw") +print_two_again("Zed", "Shaw") +print_one("First!") +print_none() diff --git a/section2/exercises/ex6.rb b/section2/exercises/ex6.rb new file mode 100644 index 000000000..7a4335bf1 --- /dev/null +++ b/section2/exercises/ex6.rb @@ -0,0 +1,40 @@ +# define a cheese and crachers method that takes 2 parameters +def cheese_and_crackers(cheese_count, boxes_of_crackers) + # prints an interpolated string + puts "You have #{cheese_count} cheeses!" + # prints an interpolated string + puts "You have #{boxes_of_crackers} boxes of crackers!" + # prints a string + puts "Man that's enough for a party!" + # prints a string + puts "Get a blanket.\n" + # ends the method definition block +end + + +# prints a string +puts "We can just give the fuction numbers directly:" +# calls our function with two integer arguments +cheese_and_crackers(20, 30) + + +# prints a string +puts "OR, we can use variables from our script:" +# creates a variable of integer data type +amount_of_cheese = 10 +# creates a variable of integer data type +amount_of_crackers = 50 + +# calls our function with our two newly created variables as arguments +cheese_and_crackers(amount_of_cheese, amount_of_crackers) + + +# prints a string +puts "We can even do math inside too:" +# calls our function using addition within each argument +cheese_and_crackers(10 + 20, 5 + 6) + +# prints a string +puts "And we can combine the two, variables and math:" +# calls our function using variables and math within each argument +cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000) diff --git a/section2/exercises/ex6_bonus.rb b/section2/exercises/ex6_bonus.rb new file mode 100644 index 000000000..7f41812d6 --- /dev/null +++ b/section2/exercises/ex6_bonus.rb @@ -0,0 +1,52 @@ +# this is to practice using methods + +def sibling(sibling_number) + puts "You have #{sibling_number} sibling(s)." +end + +def reduce_by_one(number_to_be_reduced) + return number_to_be_reduced - 1 +end + +puts "If you had 3 siblings:" +sibling(3) + +puts "How many siblings do you have?" +print "> " +query = gets.chomp.to_i + +sibling(query) +puts "But what if you had 2 more?" +sibling(query + 2) + +twins = 2 + +puts "If you only had one pair of twins for your siblings:" +sibling(twins) +puts "If you had 2 pairs of twins for your siblings:" +sibling(twins + 2) + +puts "How many siblings do you wish you had?" +print "> " +wish = gets.chomp.to_i + +puts "Your wish:" +sibling(wish) + +puts "If you had your ideal siblings less your actual siblings:" +sibling(wish - query) + +difference = wish - query + +puts "Again but different:" +sibling(difference) + +puts "If you had 4 less than that:" +sibling(difference - 4) + +puts "If you had one less than your wish:" +sibling(reduce_by_one(wish)) +puts "If you had one less than 6 more than the difference between your ideal siblings and your actual siblings:" +sibling(reduce_by_one(difference + 6)) +puts "If you had 2 more than one less than 2 more than the difference between your ideal siblings and your actual siblings:" +sibling(2 + reduce_by_one(difference + 2)) diff --git a/section2/exercises/ex7.rb b/section2/exercises/ex7.rb new file mode 100644 index 000000000..92c0e1986 --- /dev/null +++ b/section2/exercises/ex7.rb @@ -0,0 +1,45 @@ +def add(a, b) + puts "ADDING #{a} + #{b}" + return a + b +end + +def subtract(a, b) + puts "SUBTRACTING #{a} - #{b}" + return a - b +end + +def multiply(a, b) + puts "MULTIPLYING #{a} * #{b}" + return a * b +end + +def divide(a, b) + puts "DIVIDING #{a} / #{b}" + return a / b +end + + +puts "Let's do some math with just functions!" + +age = add(30, 5) +height = subtract(78, 4) +weight = multiply(90, 2) +iq = divide(100, 2) + +puts "Age: #{age}, Height: #{height}, Weight: #{weight}, IQ: #{iq}" + + +# A puzzle for the extra credit, type it in anyway. +puts "Here is a puzzle." + +what = add(age, subtract(height, multiply(weight, divide(iq, 2)))) + +puts "That becomes: #{what}. Can you do it by hand?" + +puts "My turn." + +my_turn = divide(100, add(58, subtract(6, multiply(6, 10)))) + +puts "This should equal 25: #{my_turn}" + +puts 24 + 34 / 100 - 1023 diff --git a/day_3/exercises/if_statements.rb b/section2/exercises/if_statements.rb similarity index 76% rename from day_3/exercises/if_statements.rb rename to section2/exercises/if_statements.rb index a80b96840..177cb43f2 100644 --- a/day_3/exercises/if_statements.rb +++ b/section2/exercises/if_statements.rb @@ -1,27 +1,27 @@ # In the below exercises, write code that achieves # the desired result. To check your work, run this # file by entering the following command in your terminal: -# `ruby day_3/exercises/if_statements.rb` +# `ruby section2/exercises/if_statements.rb` -# Example: Using the weather variable below, write code that decides +# Example: Using the weather variable below, write code that decides # what you should take with you based on the following conditions: # if it is sunny, print "sunscreen" # if it is rainy, print "umbrella" # if it is snowy, print "coat" # if it is icy, print "yak traks" - weather = 'snowy' + weather = 'icy' if weather == 'sunny' - p "sunscreen" + puts "sunscreen" elsif weather == 'rainy' - p "umbrella" + puts "umbrella" elsif weather == 'snowy' - p "coat" + puts "coat" elsif weather == 'icy' - p "yak traks" + puts "yak traks" else - p "good to go!" + puts "good to go!" end # Experiment with manipulating the value held in variable 'weather' @@ -35,21 +35,25 @@ # Right now, the program will print # out both "I have enough money for a gumball" and -# "I don't have enough money for a gumball". Write a +# "I don't have enough money for a gumball". Write a # conditional statement that prints only one or the other. # Experiment with manipulating the value held within num_quarters # to make sure both conditions can be achieved. -num_quarters = 0 +num_quarters = 2 + +if num_quarters < 2 + puts "I don't have enough money for a gumball" +else + puts "I have enough money for a gumball" +end -puts "I have enough money for a gumball" -puts "I don't have enough money for a gumball" ##################### # Using the variables defined below, write code that will tell you -# if you have the ingredients to make a pizza. A pizza requires +# if you have the ingredients to make a pizza. A pizza requires # at least two cups of flour and sauce. # You should be able to change the variables to achieve the following outputs: @@ -61,5 +65,11 @@ # Experiment with manipulating the value held within both variables # to make sure all above conditions output what you expect. -cups_of_flour = 1 +cups_of_flour = 2 has_sauce = true + +if cups_of_flour >=2 && has_sauce + puts "I can make pizza" +else + puts "I cannot make pizza" +end diff --git a/section2/exercises/methods.rb b/section2/exercises/methods.rb new file mode 100644 index 000000000..4dc11cf93 --- /dev/null +++ b/section2/exercises/methods.rb @@ -0,0 +1,61 @@ +# In the below exercises, write code that achieves +# the desired result. To check your work, run this +# file by entering the following command in your terminal: +# `ruby section2/exercises/methods.rb` + +# Example: Write a method that when called will print your name: +def print_name + puts "Severus Snape" +end + +print_name + +# Write a method that takes a name as an argument and prints it: +def print_name(name) + puts "#{name}" +end + +print_name("Albus Dumbledore") + +# Write a method that takes in 2 numbers as arguments and prints +# their sum. Then call your method three times with different arguments passed in: +def sum_of_two_numbers(num_1, num_2) + puts num_1 + num_2 +end + +sum_of_two_numbers(1, 3) +sum_of_two_numbers(0, 45) +sum_of_two_numbers(92, -2) + +# Write a method that takes in two strings as arguments and prints +# a concatenation of those two strings. Example: The arguments could be +# (man, woman) and the end result might output: "When Harry Met Sally". +# Then call your method three times with different arguments passed in. + +def get_coffee_with_friends(friend_1, friend_2) + puts "#{friend_1} and #{friend_2} get coffee at Central Perk." +end + +get_coffee_with_friends("Joey Tribbiani", "Chandler Bing") +get_coffee_with_friends("Monica Geller", "Phoebe Buffay") +get_coffee_with_friends("Ross Geller", "Rachel Green") + + +#------------------- +# PART 3: Naming is Hard +#------------------- + + +# Naming is notoriously hard in programming. It is a skill to name a variable or function concisely enough that it is reasonable to type, but descriptive enough that others can infer the meaning. + +# Look at the code you wrote for the previous YOU DO🎈 - what did you name the function, and why? +# What did you name each parameter, and why? + +# EXPLAIN: The method name I chose for adding 2 numbers was "sum_of_two_numbers" because it is short, +# it explains what the method does, and it starts with an action word. I named the parameters "num_1" and "num_2" +# because it is easy to understand that we will be passing in two numbers. + +# For the method taking two strings, I named it get_coffee_with_friends. I knew the outcome would be a string +# stating two friends characters would be getting coffee at Central Perk. The method name is descriptive, +# it isn't too short or too long, and it begins with an action word. I chose "friend_1" and "friend_2" as the +# parameters because it is descriptive of what arguments should be passed. diff --git a/section2/reflection.md b/section2/reflection.md new file mode 100644 index 000000000..a4cadd79a --- /dev/null +++ b/section2/reflection.md @@ -0,0 +1,78 @@ +## Section 2 Reflection + +1. Regarding the blog posts in Part A, how do you feel about asking questions? Do you tend to ask them too soon, or wait too long, or somewhere in between? + +In my previous careers, I have waited too long to ask questions. I have to remind myself that I am paid to do a job and not to remain stuck. + +### If Statements + +1. What is a conditional statement? Give three examples. + +A conditional statement checks to see if a statement is true or false. +`cars >= trucks` +`3 != 4` +`time > 12` + +1. Why might you want to use an if-statement? + +You would want to use an if-statement if you want to only perform a task in a certain situation. + +1. What is the Ruby syntax for an if statement? +``` +if conditional_statement + execute this block +end +``` + +1. How do you add multiple conditions to an if statement? + +You can use nested if statements and you can use else-if statements. + +1. Provide an example of the Ruby syntax for an if/elsif/else statement: +``` +if bananas > apples && bananas > grapes + puts "bananas are the greatest" +elsif apples > bananas && apples > grapes + puts "apples are the greatest" +elsif grapes > bananas && grapes > apples + puts "grapes are the greatest" +else + puts "there is a tie" +end +``` + +1. Other than an if-statement, can you think of any other ways we might want to use a conditional statement? + +I can see how it would be useful in testing but I think you would write the test using if-statements. Maybe it would be good to check if variables are what you expect them to be. + +### Methods + +1. In your own words, what is the purpose of a method? + +Oftentimes a block of code is repeated several times. A method is a good way to make an abstraction that not only reduces the lines of code one has to read +but it can also make the code more clear to understand. + +1. Create a method named `hello` that will print `"Sam I am"`. + +``` +def hello() + puts "Sam I am" +end +``` + +1. Create a method named `hello_someone` that takes an argument of `name` and prints `"#{name} I am"`. + +``` +def hello_someone(name) + puts ""#{name} I am" +end +``` + +1. How would you call or execute the method that you created above? + +`hello_someone("Sam")` + +1. What questions do you have about methods in Ruby? + +- How many parameters should a method reasonably take? +- Could you use a method to generate hashes? diff --git a/section3/README.md b/section3/README.md new file mode 100644 index 000000000..2e7a6c717 --- /dev/null +++ b/section3/README.md @@ -0,0 +1,71 @@ +# Section 3 - GROWTH MINDSET, Arrays and Loops + +Section 3 is estimated to take a total of 6-10 hours to complete. Similar to the previous sections, this section of pre-work involves 📒reading, 👩🏻‍💻exercises, and 📝reflection questions. Make sure to manage your time well so that should you get stuck and need help, you have plenty of time to do so and meet the deadline. + +Since Arrays are a bigger topic, it is the main focus of this section. Some review work from the first two sections has been woven in so you get opportunities to continue seeing and applying those concepts, as well. + +- [Vocabulary](#Vocabulary) +- [Part A: Growth Mindset](#Part-A-Growth-Mindset) +- [Part B: Hashes](#Part-B-Hashes) + +## Vocabulary + +### Vocabulary Terms + +- hash +- key +- value + +## Open your local copy of backend-mod-1-prework + +Using your terminal, open the local copy of the repository that you created during setup. To do this, you will need to use the terminal command `cd` to change into the directory that holds the repository. Once you are in the correct directory, use the terminal command `atom .` to open the prework repository. If you are having trouble with this, see the `section1` README. + +## Part A Growth Mindset + +Read/watch one or both of the following: +- This [2-part blog post series](https://blog.mindsetworks.com/entry/how-having-a-growth-mindset-can-help-you-learn-to-code) discusses how having a growth mindset is helpful when learning to code, and how coding promotes a growth mindset! +- This [video interview](https://dev.to/hackflix_dev/how-to-hack-a-growth-mindset-b1g) where an experienced Front-End engineer discusses learning about the concept of Growth Mindset and how that's changed how she sees her work and career. (The first 7 minutes are intros and a discussion on Developer Relations. After that, the conversation about Growth Midnset begins.) + +Then, consider on the following questions. We will ask you to share some of these responses at the end of this section. +- What are two points from the article or video that either resonated with you, or were brand new to you? +- In which ways do you currently demonstrate a Growth Mindset? In which ways do you _not_? +- What is something you are good at or knowledgeable at now, that you once weren't? How did you get those skills/knowledge? Was it hard at some point? + +## Part B Hashes + +Earlier, you learned about one type of collection storage - Arrays. Today, you will learn about another collection storage device called a Hash. As professional developers, you will use hashes on a near daily basis- a solid understanding of how to build hashes and how to retrieve information from them will make life much easier. + +When you are all done with the lessons, exercises, and questions for today, you will once again use git to save your work locally, and then send your work to Github. + +1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory. + + - [ ] [Hashes](https://learnrubythehardway.org/book/ex39.html) from Learn Ruby the Hard Way. + + - [ ] [Hashes](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#8.-hashes) from Ruby in 100 minutes. + +1. Work through the hashes.rb file in the section4/exercises directory. + +1. Answer the questions in the reflection.md file in the section4 directory. + +## Reflection + +📝 Answer the questions in the `reflection.md` file in the `section3` directory. + +## Save your work in Git + +When you are finished with all of the `section3` activities, use the Git workflow and commands you've learned to add and commit your work. Write a commit message that concisely summarizes what work this commit contains. If you need a refresher on that workflow, look at the Mod 0 lesson where this was covered, of the directions in Sections 1 or 2. + +## Push to GitHub + +You've save your work to Git on your local machine, but it is not yet accessible through your remote Github repository. Push your code to your remote repository. If you don't remember the command, look back at the directions in Sections 1 or 2. + +Visit your GitHub repository to verify the work you did for this section was pushed successfully! + + +## Index Links + +- [Vocabulary](#Vocabulary) +- [Part A: Growth Mindset](#Part-A-Growth-Mindset) +- [Part B: Hashes](#Part-B-Hashes) + +🚀 [Go to Section 4](../section4) diff --git a/section3/exercises/arrays.rb b/section3/exercises/arrays.rb new file mode 100644 index 000000000..d8c2016f2 --- /dev/null +++ b/section3/exercises/arrays.rb @@ -0,0 +1,115 @@ + +# In the exercises below, write your own code where indicated +# to achieve the desired result. + +# Two examples are already completed. Your task is to complete +# any remaining prompt. + + + + +#------------------- +# PART 1: Animals: Array Syntax +#------------------- + +# EXAMPLE: write code below that will print an array of animals. +# Store the array in a variable. +animals = ["Zebra", "Giraffe", "Elephant"]; +print animals +print "\n" + +# EXAMPLE: Write code below that will print "Zebra" from the animals array +# YOUR CODE HERE +puts animals[0] + +# YOU DO: Write code below that will print the number of elements in array of +# animals from above. +puts animals.length + + +# YOU DO: Write code that will reassign the last item in the animals +# array to "Gorilla" +animals[2] = "Gorilla" + + + +# YOU DO: Write code that will add a new animal (type of your choice) to position 3. +animals[3] = "Tiger" + +# YOU DO: Write code that will print the String "Elephant" in the animals array +animals[4] = "Elephant" +puts animals[4] +# "Elephant" was in the last element in the array originally. There were directions to +# reassign the last element to "Gorrila". When this happened, "Elephant" was removed +# from the array so I had to add it to the array in order to print the "Elephant" string. + + +#------------------- +# PART 2: Foods: Array Methods +#------------------- + +# YOU DO: Declare a variable that will store an an array of at least 4 foods (strings) +foods = ["Pizza", "Waffles", "Pasta", "Hamburgers"] + +# YOU DO: Write code below that will print the number of elements in the array of +# foods from above. + +puts foods.length + + +# YOU DO: Write code below that uses a method to add "broccoli" to the foods array and +# print the changed array to verify "broccoli" has been added + +foods[4] = "broccoli" +print foods +puts "" + +# YOU DO: Write code below that removes the last item of food from the foods array and +# print the changed array to verify that item has been removed + +foods.pop() +print foods +puts "" + +# YOU DO: Write code to add 3 new foods to the array. + # There are several ways to do this - choose whichever you'd like! + +extra_foods = ["Rice", "Ham", "Donuts"] +foods += extra_foods + + +# Then, print the changed array to verify the new items have been added +print foods +puts "" + +# YOU DO: Remove the food that is in index position 0. +foods.delete_at(0) +print foods +puts "" + +#------------------- +# PART 3: Where are Arrays used? +#------------------- + + +# Sometimes we need to hold on to multiple pieces of data, but have it grouped together in a list. +# This is why programming languages have arrays! + +# One example of a web/mobile application that uses arrays is Instagram. Each user has a set of posts +# associated with their account. Each post, is one of potentially many, that are grouped together in a list, or, array. + +# The post itself likely has more complex data, but here is one way we can think about it: + + +posts = ["image at beach", "holiday party", "adorable puppy", "video of cute baby"]; + +# YOU DO: Think of a web application you commonly use. Where do you see LISTS utilized, where arrays +# may be storing data? Come up with 3 examples - they could be from different web applications or +# all from the same one. + +# 1: +spotify_playlists = ["Lo-Fi Cafe", "Classical Essentials", "Muted Jazz", "All New Indie"] +# 2: +espn_favorite_teams = ["Texas Tech Men's Basketball", "Texas Tech Football", "Dallas Mavericks", "Texas Rangers", "Dallas Cowboys"] +# 3: +ynab_account_names = ["Checking Account", "Double Cash CC", "Ally Savings", "Yotta Savings", "Charles Schwab"] diff --git a/section3/exercises/ex1.rb b/section3/exercises/ex1.rb new file mode 100644 index 000000000..eba450c48 --- /dev/null +++ b/section3/exercises/ex1.rb @@ -0,0 +1,68 @@ +# create a mapping of state to abbreviation +states = { + 'Oregon' => 'OR', + 'Florida' => 'FL', + 'California' => 'CA', + 'New York' => 'NY', + 'Michigan' => 'MI', + 'New Mexico' => 'NM' +} + +# create a basic set of states and some cities in them +cities = { + 'CA' => 'San Francisco', + 'MI' => 'Detroit', + 'FL' => 'Jacksonville', + 'NM' => 'Santa Fe' +} + +# add some more cities +cities['NY'] = 'New York' +cities['OR'] = 'Portland' + +# puts out some cities +puts '-' * 10 +puts "NY state has: #{cities['NY']}" +puts "OR State has: #{cities['OR']}" + +# puts some states +puts '-' * 10 +puts "Michigan's abbreviation is: #{states['Michigan']}" +puts "Florida's abbreviation is: #{states['Florida']}" + +# do it by using the state then cities dict +puts '-' * 10 +puts "Michigan has: #{cities[states['Michigan']]}" +puts "Florida has: #{cities[states['Florida']]}" + +# puts every state abbreviation +puts '-' * 10 +states.each do |state, abbrev| + puts "#{state} is abbreviated #{abbrev}" +end + +# puts every city in state +puts '-' * 10 +cities.each do |abbrev, city| + puts "#{abbrev} has the city #{city}" +end + +# now do bot at the same time +puts '-' * 10 +states.each do |state, abbrev| + city = cities[abbrev] + puts "#{state} is abbreviated #{abbrev} and has city #{city}" +end + +puts '-' * 10 +# by default ruby says "nil" when something isn't in there +state = states['Texas'] + +if !state + puts "Sorry, no Texas." +end + +# default values using //= with the nil result +city = cities['TX'] +city ||= 'Does Not Exist' +puts "The city for the state 'TX' is: #{city}" diff --git a/section3/exercises/hashes.rb b/section3/exercises/hashes.rb new file mode 100644 index 000000000..ce6a2869d --- /dev/null +++ b/section3/exercises/hashes.rb @@ -0,0 +1,146 @@ +# In the below exercises, write code that achieves +# the desired result. To check your work, run this +# file by entering the following command in your terminal: +# `ruby section3/exercises/hashes.rb` + +# Example: Write code that prints a hash holding grocery store inventory: +foods = { + apples: 23, + grapes: 507, + eggs: 48} +puts foods + +# Write code that prints a hash holding zoo animal inventory: +zoo = { + apes: 6, + elephants: 4, + lions: 7, + pandas: 3, + penguins: 13} +puts zoo + +# Write code that prints all of the 'keys' of the zoo variable +# you created above: +puts zoo.keys + +# Write code that prints all of the 'values' of the zoo variable +# you created above: +puts zoo.values + +# Write code that prints the value of the first animal of the zoo variable +# you created above: +puts zoo[:apes] + +# Write code that adds an animal to the zoo hash. +# Then, print the updated hash: +zoo[:tigers] = 3 +puts zoo + + +#------------------- +# Part 2: Email +#------------------- + + +# Think about all the pieces of information associated with one single email in your inbox. +# It has a sender, a subject, ... + +# Declare a variable that stores hash. Each key should be an attribute of an email and each +# value should be some appropriate value for that key. Work to have at least 5 key-value pairs. + +email_information = { + sender: "George Bluth", + subject: "There's Always Money in the Banana Stand", + date: "11/09/2003", + recipient: "Michael Bluth", + timestamp: "8:00 PM" +} + +# Write code that prints your email hash to the terminal. + +puts email_information + + +# Write code that prints all of the 'keys' of the email hash +# you created above: +puts email_information.keys + +# Write code that prints all of the 'values' of the email hash +# you created above: +puts email_information.values + + +#------------------- +# Part 3: Many Emails - OPTIONAL EXTENSION +#------------------- + +# LONG EXAMPLE: +# Now that we've learned about Objects AND Arrays, we can combine them. + +# Check out the following example of an array of Instagram posts: + + +# posts = ["image at beach", "holiday party", "adorable puppy", "video of cute baby"]; + + +# Frankly, that was a very simplified version of the Array the Instagram developers have +# written and work with. Still probably slightly simplified as we don't know what their code +# actually looks like, but it may look more like this: + + +posts = [ + { + 'image_src' => "./images/beach.png", + 'caption' => "At the beach with my besties", + 'timestamp' => "4:37 PM August 13, 2019", + 'number_likes' => 0, + 'comments' => [] + }, + { + 'image_src' => "./images/holiday-party.png", + 'caption' => "What a great holiday party omg", + 'timestamp' => "11:37 PM December 31, 2019", + 'number_likes' => 13, + 'comments' => [] + } +] + +puts posts +puts posts[0] + + +# The code snippet above shows an Array with 2 elements. Each element in an +# Object Literal. Each of those Object Literals has 4 key-value pairs. This may LOOK +# a bit daunting - it's OK! You don't need to be 100% comfortable with this, but it's +# good to have some exposure before going into Mod 1. + + +# YOU DO: Create an array of at least 3 EMAIL Object Literals, using the same +# key-value pairs you used in your email Object above. +# Then, log the email Array to the console. + +bluth_emails = [ + { + sender: "Gob Bluth", + subject: "I've Made a Huge Mistake", + date: "11/07/2004", + recipient: "Michael Bluth", + timestamp: "8:01 PM" + }, + { + sender: "Carl Weathers", + subject: "Baby You've Got a Stew Going", + date: "02/08/2004", + recipient: "Tobias Funke", + timestamp: "3:15 PM" + }, + { + sender: "Lindsay Bluth", + subject: "Hot Ham Water", + date: "01/02/2006", + recipient: "Buster Bluth", + timestamp: "1:23 PM" + } +] + +puts bluth_emails diff --git a/section3/reflection.md b/section3/reflection.md new file mode 100644 index 000000000..1f77921f6 --- /dev/null +++ b/section3/reflection.md @@ -0,0 +1,61 @@ +## Section 3 Reflection + +1. What are two points from the Growth Mindset article and/or video that either resonated with you, or were brand new to you? + +- Don't compare yourself to the growth of other developers to determine if you are growing or not. This will be difficult for me. I like to compare myself to others because it often motivates me if I feel like I'm falling behind. +- I used to reflect monthly in one of my previous jobs to see what went well and what could be improved. I was able to be intentional in how I was able to improve myself in that position. I need to do more of that moving forward. + +1. In which ways do you currently demonstrate a Growth Mindset? In which ways do you _not_? +- I always want to improve. It is one of the things that I really enjoy seeing in myself and other aspects of life. It's what I like about golf. I love seeing the progress of a house being built over time. I love making processes more efficient. Progress is the best! +- I struggle with the importance and role of making mistakes. I think I've been groomed through public schooling to think that making a mistake means that I'm not good enough. If something we're doing doesn't fail, we rarely take the time to look and see if we were simply lucky or if we actually did the task correctly. If, instead, we fail, we must examine the process and diagnose what went wrong. By way of investigating and thinking, we learn the process more deeply. + +1. What is a Hash, and how is it different from an Array? + +- A hash is a data type that consists of pairs of keys and values. The key/value pairs are not indexed numerically unlike elements within an array. + +1. In the space below, create a Hash stored to a variable named `pet_store`. This hash should hold an inventory of items and the number of that item that you might find at a pet store. + +``` +pet_store = { + 'Dog collars' => 42, + 'Chew toys' => 24, + 'Cans of Catfood' => 326, + 'Fish tanks' => 19 +} +``` + +1. Given the following `states = {"CO" => "Colorado", "IA" => "Iowa", "OK" => "Oklahoma"}`, how would you access the value `"Iowa"`? + +`states['IA']` + +1. With the same hash above, how would we get all the keys? How about all the values? + +**keys:** +``` +states.each do |abbrev, state| + puts "#{abbrev}" +end +``` + +*or* + +`puts states.keys` + +**values:** +``` +states.each do |abbrev, state| + puts "#{state}" +end +``` + +*or* + +`puts states.values` + +1. What is another example of when we might use a hash? In your example, why is a hash better than an array? + +- You might use a hash when you have something like a phone registry where you have the name as a key and the phone number as a value. It is better than an array because you can search for the number without iterating over the array to find the number. You would also likely need to create an array of arrays to keep track of the same data pairs. + +1. What questions do you still have about hashes? + +- I'd be interested to know why some refer to hashes as objects. Is this common among languages that aren't Ruby? Is this a Turing specific decision and other companies could have different standards? diff --git a/section4/README.md b/section4/README.md new file mode 100644 index 000000000..cdc45d668 --- /dev/null +++ b/section4/README.md @@ -0,0 +1,67 @@ +# Section 4 - Objects, Classes and Code Challenges + +Section 4 is estimated to take a total of 10-14 hours to complete. Similar to the previous sections, this section of pre-work involves reading 📒, 👨🏾‍💻exercises, and 📝reflection questions. Make sure to manage your time well so that should you get stuck and need help, you have plenty of time to do so and meet the deadline. + +- [Vocabulary](#Vocabulary) +- [Part A: How You Spend Your Time](#Part-A-How-You-Spend-Your-Time) +- [Part B: Classes](#Part-B-Classes) + +## Vocabulary + +### Vocabulary Terms + +- method +- class +- class instance +- properties + +## Part A How You Spend Your Time + +One challenge developers face, moreso when they are starting out, is estimating how long something will take. Sometimes we don't account for merge conflicts, bugs, annoying Slack messages, and all the other things that interrupt our workflow or slow us down. + +One challenge learners in a new environment/content area face is feeling like they know nothing, and until they know everything, they feel like they are failing. + +So this week, we would like you to start self-monitoring your progress. Before you start on the technical work, reflect back on how the pre-work has gone so far. +- Have the time estimates matched up with your experience? +- When you sit down to start working, do you have a clear goal of what you want to accomplish and in how much time? If so, how aligned is that to what actually happens? +- How do you work best - in 2 hour blocks, 4 hour blocks, etc? Do you take breaks regularly? Do you have a system to hold yourself accountable to taking breaks? + +You've probably heard of the Pomodoro Technique in Mod 0 classes (and elsewhere, maybe!). During this final section of pre-work, we are going to ask that you follow this technique. Please read about it [here](https://www.dovico.com/blog/2020/08/26/the-pomodoro-technique-how-to-manage-your-work-time-and-flow-the-easy-way/). The article doesn't mention writing down Step 1, but we ask that you find a special spot in your notebook where you do this for each work session. In the deliverables, we will ask that you share what you wrote down for Step 1 of the technique each time you started a new task. _Note: if the 25 minutes on/3-5 minutes off isn't best for you, you do **not** have to follow that! The main focus of this is setting an intention and continuing to better understand your working style._ + +## Part B Classes + +Today, you are going to be learning about Objects and Classes. In ruby, Classes are one of the tools we use to group together specific Methods that are meant to work together, or on the same type of Object. Arriving at Turing with a strong understanding of how to build a class, and how to call Methods on that class will make your first couple of weeks go smoothly! + +When you are all done with the lessons, exercises, and questions for today, you will once again use git to save your work locally, and then send your work to Github. + +1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory. + + - [ ] [What Are Objects](https://launchschool.com/books/oo_ruby/read/the_object_model#whatareobjects) section from LaunchSchool. + + - [ ] [Classes Define Objects](https://launchschool.com/books/oo_ruby/read/the_object_model#classesdefineobjects) section from LaunchSchool. + + - [ ] [Classes and Objects Part 1](https://launchschool.com/books/oo_ruby/read/classes_and_objects_part1) from LaunchSchool. + + - [ ] [Objects, Attributes and Methods](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#11.-objects,-attributes,-and-methods) from Ruby in 100 Minutes. + +1. Work through the files in the section4/exercises directory. + +1. Answer the questions in the reflection.md file in the section4 directory. + +## Reflection + +📝 Answer the questions in the `reflection.md` file in the section4 directory. + +## Save your work, push to GitHub + +Commit your Code Challenges and push up to your GitHub repository. + + +## Index Links + +- [Vocabulary](#Vocabulary) +- [Part A: How You Spend Your Time](#Part-A-How-You-Spend-Your-Time) +- [Part B: Classes](#Part-B-Classes) + + +🚀 [Go to the Final Project](../finalProject) diff --git a/section4/exercises/burrito.rb b/section4/exercises/burrito.rb new file mode 100644 index 000000000..17930392e --- /dev/null +++ b/section4/exercises/burrito.rb @@ -0,0 +1,40 @@ +# Add the following methods to this burrito class and +# call the methods below the class: +# 1. add_topping +# 2. remove_topping +# 3. change_protein + +class Burrito + attr_accessor :protein, :base, :toppings + def initialize(protein, base, toppings) + @protein = protein + @base = base + @toppings = toppings + end + + def add_topping(new_topping) + self.toppings.append(new_topping) + end + + def remove_topping(sans_topping) + self.toppings.delete(sans_topping) + end + + def change_protein(protein) + self.protein = protein + end +end + +dinner = Burrito.new("Beans", "Rice", ["cheese", "salsa", "guacamole"]) +puts dinner.protein +puts dinner.base +print dinner.toppings +puts "" +dinner.add_topping("sour cream") +print dinner.toppings +puts "" +dinner.remove_topping("salsa") +print dinner.toppings +puts "" +dinner.change_protein("Chicken") +puts dinner.protein diff --git a/day_6/exercises/dog.rb b/section4/exercises/dog.rb similarity index 65% rename from day_6/exercises/dog.rb rename to section4/exercises/dog.rb index 03221314d..00a838c95 100644 --- a/day_6/exercises/dog.rb +++ b/section4/exercises/dog.rb @@ -1,5 +1,5 @@ # In the dog class below, write a `play` method that makes -# the dog hungry. Call that method below the class, and +# the dog hungry. Call that method below the class, and # print the dog's hunger status. class Dog @@ -12,6 +12,10 @@ def initialize(breed, name, age) @hungry = true end + def play + @hungry = true + end + def bark p "woof!" end @@ -22,9 +26,11 @@ def eat end fido = Dog.new("Bernese", "Fido", 4) -p fido.breed -p fido.name -p fido.age -p fido.hungry +puts fido.breed +puts fido.name +puts fido.age +puts fido.hungry fido.eat -p fido.hungry +puts fido.hungry +fido.play +puts fido.hungry diff --git a/section4/exercises/ex1.rb b/section4/exercises/ex1.rb new file mode 100644 index 000000000..143602810 --- /dev/null +++ b/section4/exercises/ex1.rb @@ -0,0 +1,51 @@ + class MyCar + attr_accessor :color + attr_reader :year + + def initialize(year, model, color) + @year = year + @model = model + @color = color + @current_speed = 0 + end + + def speed_up(number) + @current_speed += number + puts "You push the gas and accelerate #{number} mph." + end + + def brake(number) + @current_speed -= number + puts "You push the brake and decelerate #{number} mph." + end + + def current_speed + puts "You are giong #{@current_speed} mph." + end + + def shut_down + @current_speed = 0 + puts "Let's park this bad boy!" + end + + def spray_paint(color) + self.color = color + puts "Your new #{color} paint job looks great!" + end + end + + lumina = MyCar.new(1997, 'Chevy lumina', 'white') + lumina.speed_up(20) + lumina.current_speed + lumina.speed_up(20) + lumina.current_speed + lumina.brake(20) + lumina.current_speed + lumina.brake(20) + lumina.current_speed + lumina.shut_down + lumina.current_speed + lumina.color = 'black' + puts lumina.color + puts lumina.year + lumina.spray_paint("red") diff --git a/section4/exercises/ex2.rb b/section4/exercises/ex2.rb new file mode 100644 index 000000000..37506d866 --- /dev/null +++ b/section4/exercises/ex2.rb @@ -0,0 +1,16 @@ +class Student + attr_accessor :first_name, :last_name, :primary_phone_number + + def introduction(target) + puts "Hi #{target}, I'm #{first_name}!" + end + + def favorite_number + 7 + end +end + +frank = Student.new +frank.first_name = "Frank" +# frank.introduction('Katrina') +puts "Frank's favorite number is #{frank.favorite_number}." diff --git a/section4/exercises/person.rb b/section4/exercises/person.rb new file mode 100644 index 000000000..099cf3004 --- /dev/null +++ b/section4/exercises/person.rb @@ -0,0 +1,23 @@ +# Create a person class with at least 2 attributes and 2 behaviors. +# Call all person methods below the class and print results +# to the terminal that show the methods in action. + +class Person + attr_accessor :first_name, :weight_in_lbs + def initialize(first_name, weight_in_lbs) + @first_name = first_name + @weight_in_lbs = weight_in_lbs + end + + def greet + puts "Hello, my name is #{first_name}" + end + + def weight_statement + puts "I weigh #{weight_in_lbs} lbs but I'm not to my fighting weight yet." + end +end + +robert = Person.new("Robert", 172) +robert.greet +robert.weight_statement diff --git a/section4/reflection.md b/section4/reflection.md new file mode 100644 index 000000000..18ac61d3f --- /dev/null +++ b/section4/reflection.md @@ -0,0 +1,54 @@ +## Section 4 Reflection + +1. How different did your workflow feel this week, considering we asked you to follow the Pomodoro technique? +- When I went to reach for my phone for a mental break, I would first check my pom timer to see if it was acceptable. I stayed more focused but it was more difficult to commit to starting a pom. + +1. Regarding the work you did around setting intentions in Step 1 of the Pomodoro technique - how did that go? Were you surprised by anything (did you find yourself way more focused than you realized, more distracted that you thought you'd be, estimating times accurately or totally off, etc)? +- Luckily the layout of the section helped me to set my step 1 pom intention. I think I was surprised at how disciplined I was during the pom. + +1. In your own words, what is a Class? +- A Class is a category of a thing. It is also like a factory or a mold that produces instances with common attributes. + +1. What is an attribute of a Class? +- An attribute is a characteristic of a class that *every* instance of that class has. + +1. What is behavior of a Class? +- A behavior of a class is what *every* instance of a class is capable of doing. + +1. In the space below, create a Dog class with at least 2 attributes and 2 behaviors: + +```rb +class Dog + attr_accessor :name, :bone_pile, :posture + + def initialize(name, bone_pile) + @name = name + @bone_pile = bone_pile + @posture = "Standing" + end + + def sit + @posture = "Sitting" + end + + def up + @posture = "Standing" + end + + def dig_for_bones(number_of_bones) + self.bone_pile += number_of_bones + puts "#{name} has #{bone_pile} bones!" + end + + def eat_bone + self.bone_pile -= 1 + puts "#{name} now has #{bone_pile} bones." + end +end +``` + +1. How do you create an instance of a class? +`instance = Class.new()` + +1. What questions do you still have about classes in Ruby? +- I still need to iron out when the '@' symbol is used and when it isn't inside of a definition.