diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..637749b28 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index 33eef4a63..8daf6e95a 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 reinforcing 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,34 +36,37 @@ 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: + * [Forking and Cloning the Prework Repository](#forking-the-module-1-prework-repository) -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) - -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. + + + --> -[![Walkthrough RBENV and Ruby](images/rbenv-ruby-thumbnail.jpg)](https://youtu.be/3DtqMlK8In0 "Video Walkthrough for RBENV and Ruby Installation") + -Similar to Homebrew, rbenv provides a script to get everything installed. Open a terminal with Spotlight search (`Command + Space`) and enter these commands: + -### Use rbenv to install a certain version of Ruby + -#### Setting the Default Version + + ### Forking the Module 1 Prework Repository @@ -177,13 +193,15 @@ 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. +![click fork button](/images/be_step1.png) + #### 4. On the new page, confirm that it is a "forked" copy of the repository, with your username included in the URL and repository name. -![confirm new repository belongs to _your_ github account](/images/fork_02.jpg) +![confirm fork](/images/be_step2.png) Check [github help](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) out for more info about forks. @@ -195,7 +213,7 @@ Cloning is when you copy a remote Github repository to your local computer. #### 1. In YOUR `backend_mod_1_prework` repository that your just forked, click on `Clone or Download` -![clone down your copy](/images/fork_03.jpg) +![clone your copy](/images/be_step3.png) #### 2. If you see `Clone with HTTPS` click on `Use SSH` @@ -220,32 +238,21 @@ 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: +### IMPORTANT NOTE - PLEASE READ CAREFULLY +Do **NOT** work directly in the Github interface or use the `Edit` button to work directly from the Github version of your prework repository! + +Instead, add your work in your text editor (Atom) on your local machine (laptop) - your prework involves using `git` to track changes and push your work up to Github. We will cover how to do this in Mod 0 AND we give explicit instructions on how to do this in each section of the 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") +## Get Started 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! ---------------------------------- - -# Extensions (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](#forking-the-module-1-prework-repository) as you did previously to fork and clone this repo on to your local computer. 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/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..0db990e6b --- /dev/null +++ b/final_prep/README.md @@ -0,0 +1,92 @@ +# 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! + +- [ ] Complete the [Mod Zero Hero Challenge](./mod_zero_hero.rb) +- [ ] Complete the [Annotation Challenge](./annotations.rb) + +### Refactor Previous Work +You've learned A LOT over the last few weeks as it relates to technical content - chances are, you probably have some code from your previous exercises that is either sloppy, incorrect, poorly named, etc. Before starting Mod 1, we want you to `refactor` your code - which is the process of adjusting or improving your code for readability and accuracy. + +Some things to consider as you refactor include... +- Are my variable names easy to understand/convey the data type they are assigned to? +- Do I have proper indentation on my functions, if/else statements, etc. ? +- Do I follow proper conventions for capitalization, punctuation, casing, etc. as it relates to my code? +- Are there functions that I wrote that I can make more concise while maintaining same functionality? + +Take your time as you go back and refactor your exercises from each section. We've included a handy checklist for you to go through below. + +- [X] I have refactored my `section1` exercises to the best of my ability +- [X] I have refactored my `section2` exercises to the best of my ability +- [X] I have refactored my `section3` exercises to the best of my ability +- [X] I have refactored my `section4` exercises to the best of my ability + +### Time Management Prep +In Mod 0 you've learned about different techniques for managing your time at Turing. Please create a calendar for your **first 3 weeks of Mod 1**. Feel free to make your calendar fit your style, but we suggest that your calendar should include the following: +- [X] Standard M1 class schedule (see M1 calendar [here](https://backend.turing.io/module1/) +- [X] Study/Project work time +- [X] Health + Wellness + +When you are finished, add screenshots of your calendar so we can provide feedback if needed! + +- `Add Week 1 Screenshot Here` +![Mod_1_Week_1](https://user-images.githubusercontent.com/87393003/128575348-58035345-4ffa-4151-8d87-6f0fecd7c224.png) +- `Add Week 2 Screenshot Here` +![Mod_1_Week_2](https://user-images.githubusercontent.com/87393003/128575355-a998f3f3-03d2-43f4-ab62-68a58c728c82.png) +- `Add Week 3 Screenshot Here` +![Mod_1_Week_3](https://user-images.githubusercontent.com/87393003/128575361-c3bb9d7a-89a6-46f3-9d0d-98a318875ad4.png) + +### 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/michab17/6f48dcfa16e6cd5499ac9ea214c27db3 + +### 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! +- [ ] Complete the [Pre Teaching Practice exercise](https://gist.github.com/ericweissman/0036e8fe272c02bd6d4bb14f42fd2f79) gist + - [ ] Add a link to your gist here: https://gist.github.com/michab17/4fb2682fc691bfa093b14d375c9c45b9 + +### 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. +- [ ] Complete the [DTR Guiding Questions](https://gist.github.com/ericweissman/c56f3a98cdce761808c21d498a52f5c6) + - [ ] Add a link to your gist here: https://gist.github.com/michab17/1717cf91f2dd0d41c82c11e437890168 + +## 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 +Check out our thoughts on [extension activities](https://mod0.turing.io/prework/extensions) if you find yourself with some extra time before starting Mod 1! diff --git a/final_prep/annotations.rb b/final_prep/annotations.rb new file mode 100644 index 000000000..5688408e1 --- /dev/null +++ b/final_prep/annotations.rb @@ -0,0 +1,60 @@ +# 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 + +# This creates a method called build_a_bear, which takes in the arguments of name, age, fur, clothes and special_power +def build_a_bear(name, age, fur, clothes, special_power) + #This prints out a string with the name argument interpolated into it + greeting = "Hey partner! My name is #{name} - will you be my friend?!" + #This creates a variable that is set equal to an array holding name and age + demographics = [name, age] + #This sets a variable equal to a string that has the special_power interpolated into it + power_saying = "Did you know that I can #{special_power}?" + #This sets a variable equal to a hash which holds basic_info, clothes, exterior, cost, sayings and is_cuddly as keys + built_bear = { + 'basic_info' => demographics, + 'clothes' => clothes, + 'exterior' => fur, + 'cost' => 49.99, + 'sayings' => [greeting, power_saying, "Goodnight my friend!"], + 'is_cuddly' => true, + } + #This returns the hash that was created in the method + return built_bear +end + +#These next two lines call the method with all the arguments given +build_a_bear('Fluffy', 4, 'brown', ['pants', 'jorts', 'tanktop'], 'give you nightmares') +build_a_bear('Sleepy', 2, 'purple', ['pajamas', 'sleeping cap'], 'sleeping in') + + +# FizzBuzz +# This defines a method called fizzbuzz with num_1, num_2 and range as arguments +def fizzbuzz(num_1, num_2, range) + #This is a for loop that loops from 1 to the given range argument. + (1..range).each do |i| + #This is an if statement which sees if both the remainder of i / num_1 is equal to 0 and if the remainder of 1 / num_2 is equal to 0 + if i % num_1 === 0 && i % num_2 === 0 + #If the above if statement is true then it will print 'fizzbuzz' + puts 'fizzbuzz' + #This is a continuation of the if statement where if only the remainder of i / num_1 is equal to 0 it will run + elsif i % num_1 === 0 + #If the above if elsif statement is true then it will print 'fizz' + puts 'fizz' + #This is another continuation of the if statement in which if only the remainder of i / num_2 is equal to 0 it will run + elsif i % num_2 === 0 + #If the above elsif statement is true it will print 'buzz' + puts 'buzz' + #If none of the above statements are true this will run + else + #If the else is fulfilled this will print i + puts i + end + end +end + +#These last two lines run the method with the given integers as the arguments +fizzbuzz(3, 5, 100) +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..98861aa6e --- /dev/null +++ b/final_prep/mod_zero_hero.rb @@ -0,0 +1,147 @@ +# 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 = "Jen" +special_ability = "telekenisis" +# 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, my name is #{hero_name}." +catchphrase = "#{special_ability} is the name of the game." +# Declare two variables - power AND energy - set to integers +power = 9001 +energy = 100 +# 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 = true +identity_concealed = false + +# 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 = ["Tom", "Jerry", "Paul"] +sidekicks = ["Micha", "Alex", "Sam"] +# Print the first sidekick to your terminal + +puts sidekick[0] + +# Print the last arch_enemy to the terminal + +puts arch_enemies[2] + +# Write some code to add a new arch_enemy to the arch_enemies array + +arch_enemies.push("Terry") + +# Print the arch_enemies array to terminal to ensure you added a new arch_enemey +puts arch_enemies +# Remove the first sidekick from the sidekicks array +sidekicks.shift +# Print the sidekicks array to terminal to ensure you added a new sidekick +puts sidekick +# 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 +def assess_situation(danger_level, save_the_day, bad_excuse) + if danger_level > 50 + puts bad_excuse + elsif danger_level >= 10 && danger_level <=50 + puts save_the_day + else + puts "Meh. Hard pass." + end + + +# 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. + +#Test Cases +announcement = 'Never fear, the Jen is here!' +excuse = 'I just remembered I left my stove on.' +assess_situation(99, announcement, excuse) #> Should print - 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.' +assess_situation(21, announcement, excuse) #> should print - 'Never fear, the Courageous Curly Bracket is here!' +assess_situation(3, announcement, excuse) #> should print - "Meh. Hard pass." + +# 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" => "Baddy McBadguy", + "smell" => "spoiled milk", + "weight" => 4527, + "cities_destroyed" => ["Chicago", "San Diego", "Pittsburgh"], + "lucky_numbers" => [7, 17, 37], + "address" => { + "number" => 123, + "street" => "Circle drive", + "state" => "Montana", + "zip" => 12345 + } +} + +# 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 + +# - 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 +class SuperHero + attr_accessor :name, :super_power, :age, :arch_nemesis, :power_level, :energy_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 + + def say_name + puts self.name + end + + def maximize_energy + self.energy_level = 1000 + end + + def gain_power(number) + self.power_level += number + end +end + +# - Create 2 instances of your SuperHero class +jen = SuperHero.new("Jen", "telekenisis", "24") +micha = SuperHero.new("Micha", "shapeshifting", "26") + +# Reflection +# What parts were most difficult about this exerise? + +#Specifically figuring out what was meant with the static and dynamic values what the most difficult for me. + +# What parts felt most comfortable to you? + +#Everything but creating classes felt the most comfortable to me. + +# What skills do you need to continue to practice before starting Mod 1? + +#I just need a little more practice when it comes to classes. I also need to better understand when to use self.variable and when not to. diff --git a/images/be_step1.png b/images/be_step1.png new file mode 100644 index 000000000..f3d427deb Binary files /dev/null and b/images/be_step1.png differ diff --git a/images/be_step2.png b/images/be_step2.png new file mode 100644 index 000000000..86dc090b5 Binary files /dev/null and b/images/be_step2.png differ diff --git a/images/be_step3.png b/images/be_step3.png new file mode 100644 index 000000000..ee53fba1f Binary files /dev/null and b/images/be_step3.png differ diff --git a/section1/README.md b/section1/README.md new file mode 100644 index 000000000..c6d234289 --- /dev/null +++ b/section1/README.md @@ -0,0 +1,273 @@ +# 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 documentation 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 begin this 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!*** + + - [X] [A Good First Program](https://learnrubythehardway.org/book/ex1.html) + + - [X] [Comments in Code](https://learnrubythehardway.org/book/ex2.html) + + - [X] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html) + + - [X] [Variables and Names](https://learnrubythehardway.org/book/ex4.html) + + - [X] [Strings](https://learnrubythehardway.org/book/ex5.html) + + - [X] [More Strings](https://learnrubythehardway.org/book/ex6.html) + + - [X] [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. booleans +1. variables +1. interpolation +1. loops + +## Questions +- Each day contains a reflections.md file where you will answer questions about what you have learned. + +Answer the day 1 questions within the reflections.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..d4c1ebd40 --- /dev/null +++ b/section1/exercises/booleans.rb @@ -0,0 +1,16 @@ +#------------------- +# BOOLEANS +#------------------- + +# EXAMPLE: log to the console the result of 1 is equal to 2: +p 1 === 2 + +# EXAMPLE: log to the console the result of 7 is greater than 2: +p 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/section1/exercises/ex1.rb b/section1/exercises/ex1.rb new file mode 100644 index 000000000..007330e23 --- /dev/null +++ b/section1/exercises/ex1.rb @@ -0,0 +1,9 @@ +#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 "This is another line." diff --git a/section1/exercises/ex11.rb b/section1/exercises/ex11.rb new file mode 100644 index 000000000..4bd3b1902 --- /dev/null +++ b/section1/exercises/ex11.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/exercises/ex2.rb b/section1/exercises/ex2.rb new file mode 100644 index 000000000..0cb6c6428 --- /dev/null +++ b/section1/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/exercises/ex3.rb b/section1/exercises/ex3.rb new file mode 100644 index 000000000..7b57bbca1 --- /dev/null +++ b/section1/exercises/ex3.rb @@ -0,0 +1,47 @@ +# + plus +# - minus +# / slash +# * asterisk +# % percent +# < less-than +# > greater-than +# <= less-than-or-equal +# >= greater-than-or-equal + +# This line prints the message in quotations +puts "I will now count my chickens" + +# This line prints Hens and then the calculation +puts "Hens #{25.0 + 30.0 / 6.0}" +# This line prints Roosters and then the calculation +puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}" + +# This line prints the message in quotations +puts "Now I will count the eggs:" + +# This line prints the result of the calculation +puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0 + +# This line prints the message in quotations +puts "Is it true that 3.0 + 2.0 < 5.0 - 7.0?" + +# This line prints the result of the calculation +puts 3.0 + 2.0 < 5.0 - 7.0 + +# This line prints "What is 3 + 2" and then the result +puts "What is 3 + 2? #{3.0 + 2.0}" +# This line prints "What is 5 - 7" and then the result +puts "What is 5 - 7? #{5.0 - 7.0}" + +# This line prints the message +puts "Oh, that's why it's false." + +# This line prints the message +puts "How about some more." + +# This line prints the message and then the result of the computation +puts "Is it greater? #{5.0 > -2.0}" +# This line prints the message and then the result of the computation +puts "Is it greater or equal? #{5.0 >= -2.0}" +# This line prints the message and then the result of the computation +puts "Is it less or equal? #{5.0 <= -2.0}" diff --git a/section1/exercises/ex4.rb b/section1/exercises/ex4.rb new file mode 100644 index 000000000..41edfa372 --- /dev/null +++ b/section1/exercises/ex4.rb @@ -0,0 +1,31 @@ +# Sets the variable cars to equal 100 +cars = 100 +# Sets the variable space_in_a_car to equal 4.0 +space_in_a_car = 4.0 +# Sets the variable drivers to equal 30 +drivers = 30 +# Sets the variable passengers to equal 90 +passengers = 90 +# Subtracts drivers from cars and sets it to equal cars_not_driven +cars_not_driven = cars - drivers +# Sets cars_driven to equal drivers +cars_driven = drivers +# Sets carpool_capacity to equal cars_driven * space_in_a_car +carpool_capacity = cars_driven * space_in_a_car +# Sets average_passengers_per_car to equal passengers / cars_driven +average_passengers_per_car = passengers / cars_driven + +# prints how many cars are available +puts "There are #{cars} cars available." +# Prints how many drivers are available +puts "There are only #{drivers} drivers available." +# Prints how many empty cars there will be +puts "There will be #{cars_not_driven} empty cars today." +# prints how many people can be transported +puts "We can transport #{carpool_capacity} people today." +# Prints how many passengers there are to carpool +puts "We have #{passengers} to carpool today." +# Prints the average amount of people there need to be in each cars +puts "We need to put about #{average_passengers_per_car} in each car." + +# He got an error on line 14 because he did not define the variable carpool_capacity diff --git a/section1/exercises/ex5.rb b/section1/exercises/ex5.rb new file mode 100644 index 000000000..124f03144 --- /dev/null +++ b/section1/exercises/ex5.rb @@ -0,0 +1,20 @@ +name = 'Micha Bernhard' +age = 26 +height = 70 # inches +weight = 200 # pounds +eyes = 'Brown' +teeth = 'White' +hair = 'Brown' + +height_in_centimeters = height * 2.54 + +weight_in_kilograms = weight / 2.205 + +puts "Let's talk about #{name}." +puts "He's #{height_in_centimeters} centimeters tall." +puts "He's #{weight_in_kilograms} kilograms heavy." +puts "Actually thats not too heavy." +puts "He's got #{eyes} eyes and #{hair} hair." +puts "His teeth are usually #{teeth} depending on the coffee." + +puts "If I add #{age}, #{height_in_centimeters}, and #{weight_in_kilograms} I get #{age + height_in_centimeters + weight_in_kilograms}." diff --git a/section1/exercises/ex6.rb b/section1/exercises/ex6.rb new file mode 100644 index 000000000..66ffc41f7 --- /dev/null +++ b/section1/exercises/ex6.rb @@ -0,0 +1,21 @@ +types_of_people = 10 +x = "There are #{types_of_people} types of people." +binary = "binary" +do_not = "don't" +y = "Those who know #{binary} and those who #{do_not}." + +puts x +puts y + +puts "I said: #{x}." +puts "I also said: '#{y}'." + +hilarious = false +joke_evaluation = "Isn't that joke so funny?! #{hilarious}" + +puts joke_evaluation + +w = 'This is the left side of...' +e = 'a string with a right side.' + +puts w + e diff --git a/day_1/exercises/interpolation.rb b/section1/exercises/interpolation.rb similarity index 58% rename from day_1/exercises/interpolation.rb rename to section1/exercises/interpolation.rb index c7f4f47df..77cf6a145 100644 --- a/day_1/exercises/interpolation.rb +++ b/section1/exercises/interpolation.rb @@ -1,7 +1,7 @@ # 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": @@ -15,11 +15,21 @@ 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. + +program = "Turing" +adj1 = "fun" +adj2 = "hard" + +puts "#{program} is both #{adj1} and #{adj2}!" diff --git a/day_1/exercises/loops.rb b/section1/exercises/loops.rb similarity index 66% rename from day_1/exercises/loops.rb rename to section1/exercises/loops.rb index 90dc15ab1..36c29f52f 100644 --- a/day_1/exercises/loops.rb +++ b/section1/exercises/loops.rb @@ -1,7 +1,7 @@ # 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 @@ -10,9 +10,17 @@ # 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 82% rename from day_1/exercises/numbers.rb rename to section1/exercises/numbers.rb index 9a5468a31..19798c9e2 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 # 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 10 % 54 diff --git a/day_1/exercises/strings.rb b/section1/exercises/strings.rb similarity index 61% rename from day_1/exercises/strings.rb rename to section1/exercises/strings.rb index f2f903ffc..a4b2c6a4d 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" # 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 "She had a baby with Micha and named him Forest Whitaker" diff --git a/section1/exercises/variables.rb b/section1/exercises/variables.rb new file mode 100644 index 000000000..037993abb --- /dev/null +++ b/section1/exercises/variables.rb @@ -0,0 +1,79 @@ +# 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 = "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 +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: +# YOUR CODE HERE +quote = "Harry Potter must not return to Hogwarts" + +puts quote + +# Write code that adds 2 to the `students` variable and +# prints the result: +students = 22 +# YOUR CODE HERE +puts students + 2 + +# Write code that subracts 2 from the `students` variable and +# prints the result: +# YOUR CODE HERE +puts students - 2 + + +# YOU DO: +# Declare three variables, named `first_name`, `is_hungry` and `number_of_pets`. +# Store the appropriate data types in each. +# print all three variables to the terminal. +first_name = "Micha" +is_hungry = false +number_of_pets = 1 + +puts first_name +puts is_hungry +puts number_of_pets + +# IN WORDS: +# How did you decide to use the data type you did for each of the three variables above? + +# Explain. +# My first name is a word so I made it a string +# Whether or not I am hungry is a boolean so I used that +# The number of pets I have is an integer so I used that + +# 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 = "Not Micha" +is_hungry = true +number_of_pets = 17 + +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? + #yes I did 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/reflection.md b/section1/reflection.md new file mode 100644 index 000000000..b8493ec2e --- /dev/null +++ b/section1/reflection.md @@ -0,0 +1,44 @@ +## 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? + +One thing that resonated with me is how much truly goes into being a 'SuperLearner'. It will definitely take a lot of work in order to change myself from where I am now to being a 'SuperLearner'. That being said I already do steps 2, 3, and 5. Step 4 I also do as much as I can. However, steps 1 and 6 I am going to have to do far more often. I would also add that SuperLearners need to have an excellent work ethic and a lot of personal discipline. They also would need to procrastinate much less than the average person. + +1. How would you print the string `"Hello World!"` to the terminal? + +You would need to type: +puts "Hello World!" + +Then you would need to run the file in the terminal by typing ruby file_name + +1. What character is used to indicate comments in a ruby file? + +The character to indicate comments in a ruby file is # + +1. Explain the difference between an integer and a float? + +An integer is a whole number (4) where as a float has a decimal point (4.0) + +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 when you insert data into a string from an outside location. + +puts "A #{animal} is a striped animal" + +1. What method is used to get input from a user? + +gets and gets.chomp if you want to chomp off the line break + +1. Name and describe two common string methods: + +The first string method is .length and it tells you how many characters are in a string, including spaces. + +The second string method is .split and it splits your sting into sections based on the added argument. If no argument is added it will split it up by spaces. 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/ex18.rb b/section2/exercises/ex18.rb new file mode 100644 index 000000000..733153d86 --- /dev/null +++ b/section2/exercises/ex18.rb @@ -0,0 +1,21 @@ +def print_two(*args) + arg1, arg2 = args + puts "arg1: #{arg1}, arg2: #{arg2}" +end + +def print_two_again(arg1, arg2) + puts "arg1: #{arg1}, arg2: #{arg2}" +end + +def print_one(arg1) + puts "arg1: #{arg1}" +end + +def print_none() + puts "I got nothin'." +end + +print_two("Micha","Bernhard") +print_two_again("Micha","Bernhard") +print_one("First!") +print_none() diff --git a/section2/exercises/ex19.rb b/section2/exercises/ex19.rb new file mode 100644 index 000000000..abce47032 --- /dev/null +++ b/section2/exercises/ex19.rb @@ -0,0 +1,34 @@ +def cheese_and_crackers(cheese_count, boxes_of_crackers) + puts "You have #{cheese_count} cheeses!" + puts "You have #{boxes_of_crackers} boxes of crackers!" + puts "Man that's enough for a party!" + puts "Get a blanket. \n" +end + + +puts "We can just give the function numbers directly" +cheese_and_crackers(20, 30) + + +puts "OR, we can use variables from our script:" +amount_of_cheese = 10 +amount_of_crackers = 50 + +cheese_and_crackers(amount_of_cheese, amount_of_crackers) + + +puts "We can even do math inside too:" + +cheese_and_crackers(10 + 20, 5 + 6) + +puts "And we can combine the two, variables and math:" +cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000) + + + + +def to_the_power_of(x, y) + puts x ** y +end + +to_the_power_of(2, 4) diff --git a/section2/exercises/ex21.rb b/section2/exercises/ex21.rb new file mode 100644 index 000000000..d00074c81 --- /dev/null +++ b/section2/exercises/ex21.rb @@ -0,0 +1,37 @@ +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(20, 6) +height = subtract(78, 8) +weight = multiply(100, 2) +iq = divide(80, 2) + +puts "Age: #{age}, Height: #{height}, Weight: #{weight}, IQ: #{iq}" + + + +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?" diff --git a/section2/exercises/ex29.rb b/section2/exercises/ex29.rb new file mode 100644 index 000000000..1bcf231f6 --- /dev/null +++ b/section2/exercises/ex29.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/ex30.rb b/section2/exercises/ex30.rb new file mode 100644 index 000000000..b1dd7fc5f --- /dev/null +++ b/section2/exercises/ex30.rb @@ -0,0 +1,26 @@ +people = 30 +cars = 40 +trucks = 15 + + +if cars > people + puts "We should take the cars." +elsif cars < people + puts "We should not take the cars." +else + puts "We can't decide." +end + +if trucks > cars + puts "That's too many trucks." +elsif trucks < cars + puts "Maybe we could take the trucks." +else + puts "We still can't decide." +end + +if people > trucks + puts "Alright, let's just take the trucks." +else + puts "Fine, let's stay home then." +end diff --git a/section2/exercises/ex31.rb b/section2/exercises/ex31.rb new file mode 100644 index 000000000..d11a2a5db --- /dev/null +++ b/section2/exercises/ex31.rb @@ -0,0 +1,39 @@ +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." + + 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!" + else + puts "Well, doing %s is probably better. Bear runs away." % bear + end + +elsif door == "2" + puts "You stare into the endless abyss at Cthulhu's retina." + 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/day_3/exercises/if_statements.rb b/section2/exercises/if_statements.rb similarity index 79% rename from day_3/exercises/if_statements.rb rename to section2/exercises/if_statements.rb index a80b96840..be30bafbb 100644 --- a/day_3/exercises/if_statements.rb +++ b/section2/exercises/if_statements.rb @@ -1,23 +1,23 @@ # 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 = 'sunny' if weather == 'sunny' p "sunscreen" elsif weather == 'rainy' p "umbrella" elsif weather == 'snowy' - p "coat" + p "snow shoes" elsif weather == 'icy' p "yak traks" else @@ -35,21 +35,24 @@ # 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 -puts "I have enough money for a gumball" -puts "I don't have enough money for a gumball" +if num_quarters < 2 + puts "I don't have enough money for a gumball" +else + puts "I have enough money for a gumball" +end ##################### # 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 +64,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 = 3 has_sauce = true + +if cups_of_flour < 2 || has_sauce == false + puts "I cannot make pizza" +else + puts "I can make pizza" +end diff --git a/section2/exercises/launchschool.rb b/section2/exercises/launchschool.rb new file mode 100644 index 000000000..98bf5c82f --- /dev/null +++ b/section2/exercises/launchschool.rb @@ -0,0 +1,25 @@ +def say(words = "hello") + puts words + '.' +end + +say() +say("hi") +say("how are you") +say("I'm fine") + +# say is the name of the method +# words is the parameter +# words is essentially set equal to the text in the parentheses after say is called + +a = 5 + +def some_method + a = 3 +end + +puts a + +[1, 2, 3].each do |num| + puts num +end +# I dont know what this is. I will have to look into it diff --git a/section2/exercises/methods.rb b/section2/exercises/methods.rb new file mode 100644 index 000000000..3bac00efc --- /dev/null +++ b/section2/exercises/methods.rb @@ -0,0 +1,57 @@ +# 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 + p "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(n1, n2) + puts n1 + n2 +end + +sum(1, 2) +sum(3, 4) +sum(3223, 2332) + +# 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 combining_strings(str1, str2) + puts "#{str1} #{str2}" +end + +combining_strings("I like", "to eat pizza") +combining_strings("I hope", "this works") +combining_strings("Lets run it", "to see if it did") + +#------------------- +# 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: + +#I named the method combining_strings because it says exactly what the function is going to do and it isn't too long to type. + +#I named the two parameters str1 and str2 because I knew the inputs were going to be two strings. I figured naming them that way would be an easy and short solution while still saying what they are. diff --git a/section2/reflection.md b/section2/reflection.md new file mode 100644 index 000000000..b9c7bba1b --- /dev/null +++ b/section2/reflection.md @@ -0,0 +1,77 @@ +## 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? + +I definitely wait too long to ask another human questions when I am stuck. However I think that I ask google questions at the right time, usually when I realize for sure that I can't find the answer on my own. I feel that it is better to ask a question and get an answer in a couple minutes then spending hours looking for the answer yourself. I like the idea of the rubber duck technique, in which you have an item on your desk and explain your problem to it and by speaking it out loud you might think of a way to solve the problem. + +### If Statements + +1. What is a conditional statement? Give three examples. + +A conditional statement is something that can be evaluated as true or false. + +1 < 2 + +2 == 2 + +3 > 2 + +1. Why might you want to use an if-statement? + +You would want to use an if statement if you are going to want different outcomes to do different things. For example if a variable is greater than 5 you want it to do one thing and if it is less than 5 you want it to do something else. + +1. What is the Ruby syntax for an if statement? + +if (conditional statement) + do this +end + +1. How do you add multiple conditions to an if statement? + +In order to add two conditions to an if statement you need to add an else statement. If you want to add even more conditions then you need to add elsif to the if statement. + +1. Provide an example of the Ruby syntax for an if/elsif/else statement: + +if (conditional statement) + do this +elsif (conditional statement) + do this +elsif (conditional statement) + do this +else + do this +end + +1. Other than an if-statement, can you think of any other ways we might want to use a conditional statement? + +You can also use conditional statements if you are assigning a variable a range of numbers. For example: + +belowFreezing = temperature < 32 + +### Methods + +1. In your own words, what is the purpose of a method? + +A method is used to run a section of code as many times as needed, while being able to input multiple different parameters each time if wanted. + +1. Create a method named `hello` that will print `"Sam I am"`. + +def hello + puts "Sam I am" +end + +hello + +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? + +What is the difference between using return to return the answer from a function and just printing that answer? diff --git a/section3/README.md b/section3/README.md new file mode 100644 index 000000000..d08a448b3 --- /dev/null +++ b/section3/README.md @@ -0,0 +1,76 @@ +# 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 Arrays + Hashes + +Today you will learn about two common data structures: arrays and hashes. + +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. + - [ ] Read about what an [array](https://learnrubythehardway.org/book/ex32.html) is from Learn Ruby the Hard Way. + + - [ ] Learn how arrays are [index-based](https://learnrubythehardway.org/book/ex34.html) from Learn Ruby the Hard Way. + + - [ ] [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 arrays.rb file in the section3/exercises directory. + +1. Work through the hashes.rb file in the section3/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..940723283 --- /dev/null +++ b/section3/exercises/arrays.rb @@ -0,0 +1,93 @@ + +# 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 + +# EXAMPLE: Write code below that will print "Zebra" from the animals array +# YOUR CODE HERE +print animals[0] + +# YOU DO: Write code below that will print the number of elements in array of +# animals from above. +puts "There are #{animals.count} animals" + +# 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] = "Panda" + +# YOU DO: Write code that will print the String "Elephant" in the animals array +puts animals[2] + +#------------------- +# PART 2: Foods: Array Methods +#------------------- + +# YOU DO: Declare a variable that will store an an array of at least 4 foods (strings) +foods = ["Pizza", "Tacos", "Burgers", "Rice"] + +# YOU DO: Write code below that will print the number of elements in the array of +# foods from above. +puts "There are #{foods.count} foods" + +# 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 +def add_food(food) + foods.push(food) + puts foods +end + +add_food("Broccoli") + +# 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 +puts food + +# YOU DO: Write code to add 3 new foods to the array. + # There are several ways to do this - choose whichever you'd like! +# Then, print the changed array to verify the new items have been added +foods.push("Beans", "Pasta", "Quesadilla") +puts food + +# YOU DO: Remove the food that is in index position 0. +foods.delete_at(0) +#------------------- +# 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: Twitter: tweets = ["Tweet_1", "Tweet_2", "Tweet_3"] +# 2: Email: email = ["Email_1", "Email_2", "Email_3"] +# 3: Netflix show = ["Episode_1", "Episode_2", "Episode_3"] diff --git a/section3/exercises/ex32.rb b/section3/exercises/ex32.rb new file mode 100644 index 000000000..6e399b827 --- /dev/null +++ b/section3/exercises/ex32.rb @@ -0,0 +1,34 @@ +the_count = [1, 2, 3, 4, 5] +fruits = ['apples', 'oranges', 'pears', 'apricots'] +change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] + +the_count.each do |number| + puts "This is count #{number}" +end + +the_count.each {|i| puts "This is count #{i}"} + +for word in fruits + puts "This is #{word}" +end + +fruits.each do |fruit| + puts "A fruit of type: #{fruit}" +end + +the_count.each do |number| + puts "This is count: #{number}" +end + +change.each {|i| puts "I got #{i}"} + +the_count.each {|i| puts "The count is at #{i}"} + +elements = [] + +(0..5).each do |i| + puts "adding #{i} to the list." + elements << i +end + +elements.each {|i| puts "Element was: #{i}"} diff --git a/section3/exercises/ex34.rb b/section3/exercises/ex34.rb new file mode 100644 index 000000000..bba9fcf59 --- /dev/null +++ b/section3/exercises/ex34.rb @@ -0,0 +1,10 @@ +animals = ['bear', 'ruby', 'peacock', 'kangaroo', 'whale', 'platypus'] + +# the animal at 1 is ruby +# the 3rd animal is peacock +# the first animal is bear +# the animal at 3 is kangaroo +# the fifth animal is whale +# the animal at 2 is peacock +# the 6th anumal is platypus +# the animal at 4 is whale diff --git a/section3/exercises/ex39.rb b/section3/exercises/ex39.rb new file mode 100644 index 000000000..ea6e26783 --- /dev/null +++ b/section3/exercises/ex39.rb @@ -0,0 +1,69 @@ +states = { + 'Oregon' => 'OR', + 'Florida' => 'FL', + 'California' => 'CA', + 'New York' => 'NY', + 'Michigan' => 'MI' +} + +cities = { + 'CA' => 'San Francisco', + 'MI' => 'Detroit', + 'FL' => 'Jacksonville' +} + +cities['NY'] = 'New York' +cities['OR'] = 'Porland' + +puts '-' * 10 +puts "NY State has: #{cities['NY']}" +puts "OR State has: #{cities['OR']}" + +puts '-' * 10 +puts "Michigan's abbreviation is: #{states['Michigan']}" +puts "Florida's abbreviation is: #{states['Florida']}" + +puts '-' * 10 +puts "Michigan has: #{cities[states['Michigan']]}" +puts "Florida has: #{cities[states['Florida']]}" + +puts '-' * 10 +states.each do |state, abbrev| + puts "#{state} is abbreviated #{abbrev}" +end + +puts '-' * 10 +cities.each do |abbrev, city| + puts "#{abbrev} has the city #{city}" +end + +puts '-' * 10 +states.each do |state, abbrev| + city = cities[abbrev] + puts "#{state} is abbreviated #{abbrev} and has city #{city}" +end + +puts '-' * 10 + +state = states['Texas'] + +if !state + puts "Sorry, no Texas." +end + +city = cities['TX'] +city ||= 'Does Not Exist' +puts "The city for the state 'TX' is: #{city}" + + +my_states = { + 'Colorado' => 'CO', + 'Pennsylvania' => 'PA', + 'New Jersey' => 'NJ' +} + +my_cities = { + 'CO' => 'Denver', + 'PA' => 'Pittsburgh', + 'NJ' => 'Princeton' +} diff --git a/section3/exercises/hashes.rb b/section3/exercises/hashes.rb new file mode 100644 index 000000000..8174d648f --- /dev/null +++ b/section3/exercises/hashes.rb @@ -0,0 +1,137 @@ +# 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} +p foods + +# Write code that prints a hash holding zoo animal inventory: +zoo = {pandas: 47, monkeys: 32, zebras: 21} +puts zoo + +# Write code that prints all of the 'keys' of the zoo variable +# you created above: +# YOUR CODE HERE +puts zoo.keys + +# Write code that prints all of the 'values' of the zoo variable +# you created above: +# YOUR CODE HERE +puts zoo.values + +# Write code that prints the value of the first animal of the zoo variable +# you created above: +# YOUR CODE HERE +puts zoo.fetch(pandas) + +# Write code that adds an animal to the zoo hash. +# Then, print the updated hash: +# YOUR CODE HERE +zoo.merge!(bears: 55) +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 = { + "sender" => "email@gmail.com", + "recipient" => "mail@yahoo.com", + "subject" => "Test Email", + "body" => "This is a test email", + "time_sent" => "3:45" +} +# Write code that prints your email hash to the terminal. +puts email + +# Write code that prints all of the 'keys' of the email hash +# you created above: +# YOUR CODE HERE +puts email.keys + +# Write code that prints all of the 'values' of the email hash +# you created above: +# YOUR CODE HERE +puts email.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. +email = [ + { + "sender" => "email@gmail.com", + "recipient" => "mail@yahoo.com", + "subject" => "Test Email", + "body" => "This is a test email", + "time_sent" => "3:45" + }, + { + "sender" => "example@hotmail.com", + "recipient" => "electronicmail@gmail.com", + "subject" => "Just checking in", + "body" => "Hey man just seeing how youre doing", + "time_sent" => "9:32" +}, + { + "sender" => "yahoo@hotmail.com", + "recipient" => "outofideas@yahoo.com", + "subject" => "Due date", + "body" => "The project is now due on Jan 20th", + "time_sent" => "12:59" + } +] + +puts email diff --git a/section3/reflection.md b/section3/reflection.md new file mode 100644 index 000000000..be2ed28fd --- /dev/null +++ b/section3/reflection.md @@ -0,0 +1,38 @@ +## 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? + +I had never heard about S.M.A.R.T. goals before, however it is definitely something I plan on using in the future. Something that resonated with me was in the video when Carmen Popoviciu said that the growth mindset really comes into play when she is struggling with something or she faces a challenge. This is relatable because I agree that challenges are usually motivating. + +1. In which ways do you currently demonstrate a Growth Mindset? In which ways do you _not_? + +The blog post talks about seeking out challenges and that is something I already do. I am comfortable facing challenges and even often times find enjoyment in it. Something that I do not do, which the article mentioned, is not hesitating to ask for help. I usually spend far too long trying to figure out a solution before I concede and ask for someones help. + +1. What is a Hash, and how is it different from an Array? + +A hash is full of keys and their respective values. An array is just a list of elements. + +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 = { + "dogs" => 32, + "cats" => 24, + "fish" => 123, + "hamsters" => 4 +} + +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? + +puts states.keys +and +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? + +Another example where you could use a hash is if you wanted to make a hash of your computer and have all the keys be the type of part and the values the parts you have in your computer + +1. What questions do you still have about hashes? +How common is the use of hashes compared to the other data types diff --git a/section4/README.md b/section4/README.md new file mode 100644 index 000000000..8fc2b4761 --- /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 Prep](../final_prep) diff --git a/day_6/exercises/burrito.rb b/section4/exercises/burrito.rb similarity index 53% rename from day_6/exercises/burrito.rb rename to section4/exercises/burrito.rb index 967f68b6c..d42353e3c 100644 --- a/day_6/exercises/burrito.rb +++ b/section4/exercises/burrito.rb @@ -1,4 +1,4 @@ -# Add the following methods to this burrito class and +# Add the following methods to this burrito class and # call the methods below the class: # 1. add_topping # 2. remove_topping @@ -11,9 +11,25 @@ def initialize(protein, base, toppings) @base = base @toppings = toppings end + + def add_topping(topping) + toppings.push(topping) + end + + def remove_topping(index) + toppings.delete_at(index) + end + + def change_protein(new_protein) + @protein = new_protein + end end dinner = Burrito.new("Beans", "Rice", ["cheese", "salsa", "guacamole"]) p dinner.protein p dinner.base p dinner.toppings +dinner.add_topping("parsley") +dinner.remove_topping(2) +dinner.change_protein("Chicken") +p dinner diff --git a/day_6/exercises/dog.rb b/section4/exercises/dog.rb similarity index 79% rename from day_6/exercises/dog.rb rename to section4/exercises/dog.rb index 03221314d..0b3a9369a 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 @@ -19,6 +19,10 @@ def bark def eat @hungry = false end + + def play + @hungry = true + end end fido = Dog.new("Bernese", "Fido", 4) @@ -28,3 +32,5 @@ def eat p fido.hungry fido.eat p fido.hungry +fido.play +p fido.hungry diff --git a/section4/exercises/jumpstartlab.rb b/section4/exercises/jumpstartlab.rb new file mode 100644 index 000000000..74d7846dc --- /dev/null +++ b/section4/exercises/jumpstartlab.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("Katarina") +puts "Frank's favorite number is #{frank.favorite_number}" diff --git a/section4/exercises/launchschool.rb b/section4/exercises/launchschool.rb new file mode 100644 index 000000000..a33d0b57c --- /dev/null +++ b/section4/exercises/launchschool.rb @@ -0,0 +1,37 @@ +# "hello".class + +# "world".class + +class GoodDog + attr_accessor :name, :height, :weight + + def initialize(n, h, w) + @name = n + @height = h + @weight = w + end + + def speak + "#{name} says arf!" + end + + def change_info(n, h, w) + self.name = n + self.height = h + self.weight = w + end + + def info + "#{self.name} weighs #{self.weight} and is #{self.height} tall." + end + + def some_method + self.info + end +end + +sparky = GoodDog.new("Sparky", "12 inches", "10 lbs") # => "This object was initialized" +puts sparky.info + +sparky.change_info('Spartacus', '24 inches', '45 lbs') +puts sparky.info diff --git a/section4/exercises/launchschool_exercises.rb b/section4/exercises/launchschool_exercises.rb new file mode 100644 index 000000000..afc4c34ef --- /dev/null +++ b/section4/exercises/launchschool_exercises.rb @@ -0,0 +1,53 @@ +class MyCar + attr_accessor :year, :color, :model, :speed + attr_reader :year + + def initialize(year, color, model) + @year = year + @color = color + @model = model + @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 now going #{@current_speed} mph" + end + + def shut_down + @current_speed = 0 + puts "Lets park this bad boy!" + end + + def spray_paint(new_color) + self.color = new_color + puts "The car is now #{@color}" + end + + def view_year + puts "The year is #{@year}" + end +end + +volkswagon = MyCar.new(2016, "red", "GTI SE") +volkswagon.spray_paint("green") +puts volkswagon.year +#volkswagon.speed_up(75) +#volkswagon.current_speed +#volkswagon.speed_up(20) +#volkswagon.current_speed +#volkswagon.brake(20) +#volkswagon.current_speed +#volkswagon.brake(75) +#volkswagon.current_speed +#volkswagon.shut_down +#volkswagon.current_speed diff --git a/section4/exercises/person.rb b/section4/exercises/person.rb new file mode 100644 index 000000000..ee94ed854 --- /dev/null +++ b/section4/exercises/person.rb @@ -0,0 +1,26 @@ +# 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 +class Person + attr_accessor :name, :age + def initialize(name, age) + @name = name + @age = age + end + + def introduction + puts "Hi! My name is #{name} and I am #{age} years old." + end + + def change_age(new_age) + @age = new_age + end +end + +steve = Person.new("Steve", 26) +steve.introduction +steve.change_age(27) +steve.introduction +puts steve diff --git a/section4/reflection.md b/section4/reflection.md new file mode 100644 index 000000000..4321da8df --- /dev/null +++ b/section4/reflection.md @@ -0,0 +1,56 @@ +## Section 4 Reflection + +1. How different did your workflow feel this week, considering we asked you to follow the Pomodoro technique? + +After using the pomodoro technique I definitely didnt feel as overwhelmed as I usually did previously when I did these exercises. I could also work for a longer period of time before my brain felt fried. + +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)? + +When setting the realistic goals it felt nice to have something short term to work for. That being said sometimes my goals would take a little longer than expected which I was surprised by. Over all I was able to work longer than if I just work straight with sporadic breaks sprinkled in. + +1. In your own words, what is a Class? + +A class is almost like a blueprint that given things fit into. It is used to define other objects. + +1. What is an attribute of a Class? + +An attribute of a class is information that an object within that class has about it. + +1. What is behavior of a Class? + +The behavior of a class is set by the methods within it. Each object put into the class interacts with the methods put within that class. + +1. In the space below, create a Dog class with at least 2 attributes and 2 behaviors: + +```rb +class Dog + attr_accessor :name, :breed + + def initialize(name, breed) + @name = name + @breed = breed + end + + def dog_info + puts "This dog is a #{breed} and his name is #{name}." + end + + def best_friend("friend_name") + puts "His best friend is #{friend_name}" + end +end + +doug = Dog.new("Doug", "Australian Shepard") +doug.dog_info +doug.best_friend("Harry") +``` + +1. How do you create an instance of a class? + +In order to create and instance of a class you need to have: + +instance_name = ClassName.new(any_attributes) + +1. What questions do you still have about classes in Ruby? + +Can you have a method outside of a class that calls an instance of a class?