diff --git a/final_prep/DTR_guiding_questions.md b/final_prep/DTR_guiding_questions.md new file mode 100644 index 000000000..42f3b2793 --- /dev/null +++ b/final_prep/DTR_guiding_questions.md @@ -0,0 +1,64 @@ +**CAREFULLY READ ALL THE INSTRUCTIONS BEFORE STARTING THESE EXERCISES!** + +To start this assignment: + +1. Click the button in the upper right-hand corner that says Fork. This is now your copy of the document. +1. Click the Edit button when you're ready to start adding your answers. +1. To save your work, click the green button in the bottom right-hand corner. You can always come back and re-edit your gist. + +## Purpose +You will be a contributor in several paired/group project throughout your Turing career working on complex technical challenges. You may be surprised to find out that < 1% of failing projects at Turing are due solely to technical definicines - in fact, the majority of failing projects are due to intrapersonal/team issues. In order to set yourself (and your teammates) up for success, it is critical to clearly communicate and set expectations with your teammates. + +Before every project kickoff, we ask students to participate in a exercise known as **Defining the Relationship (DTR)**, where you will work to set realistic expectations with your teammates around workflow, communication, etc. + +However, prior starting Mod 1, it is crucial for you to reflect on what works for YOU! Obviously, this will change over the course of your Turing career as your learn more about your strengths and weaknesses, which is why this will be used as a living document. + +### Words of Wisdom +As you work through this document, avoid the following pitfalls: + +- "I'm flexible!" or "I'm down for whatever the group wants to do!" + - This is typically where problems start. You actually DO have preferences and opinions - it's better to communicate these from the get-go rather than have trouble come up later. + +### Collaboration Styles +- **Pair Programming**: This method involves working with your teammate(s) side-by-side/virtually on the same machine and writing code together. A common approach to this is to use a `Driver-Navigator` approach, where one person is giving direction on what to type and why (Navigator) and on person is actually typing the syntax (Driver). + - Benefits: reduces opportunities for missed communication, allows all team members to contribute, great for when all members are learning a new concept, allows for more natural brainstorming/sandboxing + - Considerations: more time consuming, more difficult to delegate tasks/features + + - **Divide and Conquer**: This method involves different team members each taking a small part of the feature/project to work on more independently and then rejoining at an agreed upon day/time to fit all the pieces together. + - Benefits: faster workflow than Pair Programmimg, easier to delegate tasks/features + - Considerations: requires excellent asynchronous communication, issues can arise when trying to combine features/work, more independent workflow (makes brainstorming/sandboxing more difficult) + +### Guiding Questions +For this initial exploration into what you bring to a team, try to avoid thinking about your TECHNICAL skills. Your answers to these questions should apply to any project/team that you work on: + +1. `How would you describe your preferred working style?` +- Divide and Conquer would be preferable to the Pair Programming style. + +2. `What strengths do you bring to a team?` +- I feel that I am a good communicator and can explain my logic and thought processes well to others. I have many years of experience working in the IT field and have worked with XP and Agile Programming methods. + +3. `How do you prefer to handle disagreements that come up? Trust me, they will come up!` +- Try to stay calm and avoid the "blame game". I find it best to talk face to face rather than email or texting back and forth. + +4. `How do you communicate best? What tools do you need to communicate well with your teammates?` +- I do best with voice/video communication. Zoom, slack and email are needed tools. +5. `How do you prefer to make decisions as a team?` +- Having a zoom meeting to discus the issues and come to a decision, then some kind of written confirmation (email/slack) to ensure everyone agrees. + +6. `What do you need (resources, environment, communication) to do your best work?` +- A quiet work space with quality internet and my MacBook Pro with external monitor. + +7. `What scheduling constraints do you have? What are your preferred work times outside of normal school hours?` +- 8-10 PM weekdays and 7-10PM Sundays + +8. `How do you prefer to receive feedback? How do you prefer to give feedback?` +- I prefer to give and receive feedback face to face when possible. + +9. `How do you want the group to solve problems when members run into blockers on the project?` +- Zoom/Slack video calls when possible. Slack communication otherwise. + +10. `What are some potential life things that could affect your ability to focus, and what plan can you come up with to approach those moments?` +- Both my wife's mother an my mother are elderly with declining health. I have siblings which can aid in case of issues. I plan on scheduling time on my calendar to ensure good communication with the "Moms". + +11. `Quarantine is tough, so it’s important to make note of our mental/emotional state when working with others. How can we make space to check in on each other’s well being, in addition to the work that needs to be done?` +- Scheduling time for personal sharing prior to getting down to business on Video meetings could be useful. diff --git a/final_prep/Gear_Up_Pre_Work.md b/final_prep/Gear_Up_Pre_Work.md new file mode 100644 index 000000000..f1ed34e54 --- /dev/null +++ b/final_prep/Gear_Up_Pre_Work.md @@ -0,0 +1,33 @@ +# Reflections: +### Unconscious Bias at Work — Making the Unconscious Conscious + ++ What were your reflections from the video? + + Until watching this video I had not heard of the term unconscious bias. The concept of most if not all your assumptions are questionable was a bit surprising as was the idea that you can access something by looking at it is most times incorrect. I like to think my life experience, background and education would have eliminated bias but this is not the case. Even with identifying unconscious bias does not solve the issue. + ++ In what ways have you examined your implicit biases before coming to Turing? + + Prior to watching the video and reading the article I was not aware of implicit biases, thus I had not examined them. + ++ What kind of software do you imagine building in the future? How will understanding biases (or avoiding understanding biases) impact your products? + + I am hopeful that I will be able to create software which can automate manual mundane human tasks which can free people to do more creative and interesting tasks. By identifying bias I can be mindful that maybe people enjoy doing simple tasks and might not want them to be automated. What I might think is good to eliminate others might disagree with. + + +### “All of us live complex lives that require a great deal of juggling for survival,” Carty and Mohanty said in an email. “What that means is that we are actually living at the intersections of overlapping systems of privilege and oppression.” + + + When you consider the way you move through the world, what elements of your identity are you most aware of on a daily basis? + + I am aware that I am a white adult man, and believe that I am non-threatening and unremarkable. I try to be positive, kind and friendly towards those I interact with. + + + What strengths does your identity give you? How will you utilize those at Turing? + + I feel that I will do well in team projects and team building. I have always enjoyed working in groups and meeting new people. + + + How do you think you could value the identities of those around you to bring out their strengths at Turing? Has there been a time where you were able to advocate or include people around you? + + I will do my best to relate to and understand the background and experiences of other classmates and instructors. + + + How will your strengths impact you as a teammate? What will you bring to your cohort? + + I try to find the best out of every situation. This attitude allows me not to get bogged down by obstacles and helps me keep moving toward problem resolutions. Hopefully I can share this with my classmates and project partners. diff --git a/final_prep/Pre-teaching_Practice.md b/final_prep/Pre-teaching_Practice.md new file mode 100644 index 000000000..e557076b1 --- /dev/null +++ b/final_prep/Pre-teaching_Practice.md @@ -0,0 +1,55 @@ +# Pre-Teaching Practice + +**CAREFULLY READ ALL THE INSTRUCTIONS BEFORE STARTING THESE EXERCISES!** + +To start this assignment: + +1. Click the button in the upper right-hand corner that says Fork. This is now your copy of the document. +1. Click the Edit button when you're ready to start adding your answers. +1. To save your work, click the green button in the bottom right-hand corner. You can always come back and re-edit your gist. + +You will be practicing pre-teaching yourself some content based on actual lessons you will be working with at Turing. There are a few things to understand about pre-teaching: + +- Pre-teaching is not designed to make you an expert about a topic before you learn it +- Pre-teaching will allow you to dedicate more focus in your lessons to areas that are unclear or confusing +- Taking some basic notes prior to a lesson will allow you to focus more on the content and less on "keeping up" +- Writing questions you have ahead of time will ensure that any areas of confusion are addressed in class + +For this exercise, you will be pre-teaching yourself the first technical lesson you'll receive at Turing! +- [BE: Variables, Methods and Return Values](https://backend.turing.io/module1/lessons/methods_and_return_values) +- [FE: Data Types, Variables, Conditionals](https://frontend.turing.io/lessons/module-1/js-data-types-variables.html) + +### Your Task + +- [x] Acquire a notebook to take hand written notes in +- [x] Setup a Table of Contents in your notebook +- [x] Add photo of your Table of Contents in the Deliverables section +- [x] Read through the lesson and take some notes in your notebook +- [x] Add a picture of one page of your notes in the Deliverables section +- [x] Write down 3-5 questions you have about the content in the lesson or questions related to the content and add to the Deliverables section +- [x] Identify 1-2 resources OUTSIDE OF TURING that you can use to clarify any of the content in the lesson and add to the Deliverables section + +A few tips for taking notes ahead of time: +- You don't need to write down every single word from the lesson - try to get down the main points in an outline form, key phrases/explanations, etc. This process will take time to figure out! +- Give yourself enough room to add notes later during class - you'll often need space to add context, create visuals, and make connections to other content during a lesson +- Consider using different colors to help organize your notes or highlight syntax + +### Deliverables + +`Add a photo of your Table of Contents below` +![20211111_190648](https://user-images.githubusercontent.com/91695954/141397451-763cbb7f-4db4-424f-9d36-078d015315b3.jpg) + + +`Add a photo of one page of your notes below` +![20211111_190711](https://user-images.githubusercontent.com/91695954/141397546-abf65953-067e-4a08-a96d-604be4f46594.jpg) + + +`Write 3-5 questions you have after pre-reading this lesson here` + +- What is good ruby programing practice concerning return. Should I use explicit returns in the majority of methods? +- When you define multiple arguments in a method and only pass in one, what are the others set to? Are the nil or does an error get thrown? +- Does Ruby have reserved names that you can't use for your own variables? + +`Add links to 1-2 resources from OUTSIDE OF TURING that relate to this lesson` +- [ruby-doc.org](https://ruby-doc.org/core-3.0.2/Method.html) +- [geeksforgeeks](https://www.geeksforgeeks.org/ruby-types-of-variables/) diff --git a/final_prep/README.md b/final_prep/README.md index 22bfb5154..1d318d656 100644 --- a/final_prep/README.md +++ b/final_prep/README.md @@ -3,13 +3,13 @@ Congrats on making it to the Mod 0 Final Prep! Complete the final exercises belo ### 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! +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) +- [x] Complete the [Mod Zero Hero Challenge](./mod_zero_hero.rb) +- [x] 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. +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? @@ -19,37 +19,43 @@ Some things to consider as you refactor include... 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. -- [ ] I have refactored my `section1` exercises to the best of my ability -- [ ] I have refactored my `section2` exercises to the best of my ability -- [ ] I have refactored my `section3` exercises to the best of my ability -- [ ] I have refactored my `section4` exercises to the best of my ability +- [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: -- [ ] Standard M1 class schedule (see M1 calendar [here](https://backend.turing.io/module1/) -- [ ] Study/Project work time -- [ ] Health + Wellness +- [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` +![Screen Shot 2021-11-12 at 8 59 20 AM](https://user-images.githubusercontent.com/91695954/141498074-8d7178f6-6b86-4631-aabe-dbeda1c57043.png) + - `Add Week 2 Screenshot Here` +![Screen Shot 2021-11-12 at 9 02 48 AM](https://user-images.githubusercontent.com/91695954/141498197-5b824cb0-50a6-4d19-b3a6-814d2c107b8c.png) + - `Add Week 3 Screenshot Here` +![Screen Shot 2021-11-12 at 9 09 23 AM](https://user-images.githubusercontent.com/91695954/141498260-3a5b2bc9-cc39-4efd-ab5e-7265d415ea07.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: -- [ ] Complete the [Mentorship DTR Prep](https://gist.github.com/ericweissman/51965bdcbf42970d43d817818bfaef3c) - - [ ] Add link to your gist here: +- [x] Complete the [Mentorship DTR Prep](https://gist.github.com/ericweissman/51965bdcbf42970d43d817818bfaef3c) +- [x] Add link to your gist here: [link to gist](https://gist.github.com/jhennerich/78d7904593974204fab4427b1457a1c4) ### 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: +- [x] Complete the [Pre Teaching Practice exercise](https://gist.github.com/ericweissman/0036e8fe272c02bd6d4bb14f42fd2f79) gist +- [x] Add a link to your gist here: [link to gist](https://gist.github.com/jhennerich/138cc762317ab5db818f00cd545b1d32) ### 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: +- [x] Complete the [DTR Guiding Questions](https://gist.github.com/ericweissman/c56f3a98cdce761808c21d498a52f5c6) +- [x] Add a link to your gist here: [link to gist](https://gist.github.com/jhennerich/0d0e90491031700f3ddf0d0dd91c816f) ## 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. @@ -86,4 +92,4 @@ What is your plan and how are you going to hold yourself to it? Specifically... - 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! \ No newline at end of file +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 index 8b938706c..aa20639a7 100644 --- a/final_prep/annotations.rb +++ b/final_prep/annotations.rb @@ -4,40 +4,66 @@ # Build a Bear +# define a method named build_a_bear passing in 5 arguments def build_a_bear(name, age, fur, clothes, special_power) + # define a string var named greeting greeting = "Hey partner! My name is #{name} - will you be my friend?!" + # declare an array containing the name and age values passed into the method demographics = [name, age] + # declare a string variable power_saying power_saying = "Did you know that I can #{special_power}?" + +# declare a hash built_bear using the above variables and those passed to the method built_bear = { + # set key basic_info to an array containing name and age 'basic_info' => demographics, + #set key clothes to values passed in from method call 'clothes' => clothes, + #set key exterior to values passed in from method call 'exterior' => fur, + #set key cost to hard coded float datatype 'cost' => 49.99, + #set key sayings to an array of strings 'sayings' => [greeting, power_saying, "Goodnight my friend!"], + #sets key is_cuddly to boolean true 'is_cuddly' => true, } + #returns the hash built_bear to the method call return built_bear end +# call build_a_bear method build_a_bear('Fluffy', 4, 'brown', ['pants', 'jorts', 'tanktop'], 'give you nightmares') +# call build_a_bear method build_a_bear('Sleepy', 2, 'purple', ['pajamas', 'sleeping cap'], 'sleeping in') # FizzBuzz +#define a method fizzbuzz expecting 3 values def fizzbuzz(num_1, num_2, range) +#define a do loop execute 1 to the value of range times (1..range).each do |i| + +#condition if i divided by num_1 remainder (modulus) is 0 and i divided by num_2 remainder (modulus) is 0 if i % num_1 === 0 && i % num_2 === 0 + # print fizzbuzz to output puts 'fizzbuzz' +#condition if i divided by num_1 remainder (modulus) is 0 elsif i % num_1 === 0 + # print fizz to output puts 'fizz' +#condition i divided by num_2 remainder (modulus) is 0 elsif i % num_2 === 0 + #print buzz to output puts 'buzz' + #catch all condition else + # print value of i to output puts i end end end -fizzbuzz(3, 5, 100) -fizzbuzz(5, 8, 400) \ No newline at end of file +fizzbuzz(3, 5, 100) #call FizzBuzz method +fizzbuzz(5, 8, 400) #call FizzBuzz method diff --git a/final_prep/mentee_DTR_prep.md b/final_prep/mentee_DTR_prep.md new file mode 100644 index 000000000..66495363c --- /dev/null +++ b/final_prep/mentee_DTR_prep.md @@ -0,0 +1,78 @@ +## Mentee: Define the Relationship (DTR) Prep +To start this assignment: + +1. Click the button in the upper right-hand corner that says Fork. This is now your copy of the document. +1. Click the Edit button when you're ready to start adding your answers. +1. To save your work, click the green button in the bottom right-hand corner. You can always come back and re-edit your gist. + +Please use the following gist to capture your thoughts, goals, priorities, etc. as outlined by each question. You will be using these questions to help give your mentor a better idea of who you are and want to become as a developer! Please note, this is meant to be a starting point for building your norms with your mentor - you may need to adjust scheduling expectations, communication expectations, etc. when you start working with your mentor! + +### Mentee Details +1. `What is your preferred name?` +- John + +2. `What are your pronouns?` +- he / him + +3. `What did you do before Turing?` +- I worked for USWEST/Qwest/CenturyLink for 20 years supporting the Voice Messaging platform as a system admin and provided tier2 support for the RX repair tool which repair call agents used to troubleshoot customer issues. For the last few years I was a project manager for the CenturyLink repair tool https://serviceassistance.centurylink.com/ + +4. `What made you decide to come to Turing?` +- I have been in the operations and maintenance side of application support my whole career. I know from my last few years with CenturyLink I do not like project management. I am wanting to modernize my skills after being "stuck" in the phone company. After talking to several Turing grads and researching coding bootcamps I feel like this is a good fit for me. + +5. `What are you most excited about exploring in your career in tech?` +- I am looking forward to being on the development side of the house vs the production and maintenance side. + +### Scheduling Details +Please review the Mod 1 calendar for [FE](https://calendar.google.com/calendar/embed?src=casimircreative.com_m6bndqol81h6jdlnpo0a6raot0%40group.calendar.google.com&ctz=America%2FDenver) or [BE](https://calendar.google.com/calendar/embed?src=casimircreative.com_59k8msrrc2ddhcv787vubvp0s4%40group.calendar.google.com&ctz=America%2FDenver) when answering the following questions. + +1. `What are your preferred times of day to connect with your mentor? (Early evening, lunch, etc.)` +- Looking at the class scheduling late afternoon would be best for me. + +2. `What are your known scheduling restrictions? (Family obligations, life obligations, etc.)` +- I am flexible and do not have any restrictions at this time. + +### Communication +1. `What is your preferred method to connect with your mentor? (Slack? Email? Text?)` +- I am learning Slack now, but I think Email would be best to start with. + +2. `What is your preferred cadence for communication? Twice a week? Weekly?` +- Once a week would be fine. + +3. `What time frame can you commit to acknowledging you have seen a message if you are too busy to send a detailed response?` +- I should be able to acknowledge a message within 15 minutes. + +4. `What time frame can you commit to sending a detailed response to a message when time permits?` +- By end of day. + +### Specific Support Requests +1. `What are the your technical strengths and areas for desired improvement?` +- I have in-depth knowledge of UNIX, computer and relational database architecture and Application Lifecycle Management (ALM). I have some background in coding Fortran77, shell and Perl but not a development level proficiency. + +2. `Is there any specific technical topic that we should focus on this inning?` +- What to expect from application development. + +3. `Are there any topics from last inning that we should focus on reviewing?` +- + +### Concerns for this Inning +1. `Do you have anything that your mentor should be aware of? (upcoming life events, concerns about the upcoming curriculum, job hunt, etc)` +- + +2. `What do I need when I get overwhelmed?` +- + +3. `Who are your supports and resources for this inning?` +- My wife Deb. + +### Write a draft of your introduction message to your mentor! +Be sure to include: +- Your name and pronouns +- Your program and cohort +- What you did before coming to Turing +- Anything else you think is relevant for your mentor to know! + +Add your draft message below ⬇️ + +Hello, my name is John Hennerich and my pronouns are he/him. I have a 20 year background in operational application support working for USWEST/Qwest/CenturyLink. I am looking forward to learning Ruby and becoming a software developer so I can build applications instead of just supporting them. +I look forward to meeting you and and learning from your experience. diff --git a/final_prep/mod_zero_hero.rb b/final_prep/mod_zero_hero.rb index 35eb2cdac..9ddc75bea 100644 --- a/final_prep/mod_zero_hero.rb +++ b/final_prep/mod_zero_hero.rb @@ -2,51 +2,81 @@ # Declare two variables - hero_name AND special_ability - set to strings +hero_name = "Big J" +special_ability = "Unbeatable in 4X games" + # 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 = "#{hero_name} is here to save the day!" +catchphrase = "You are no match because I'm #{special_ability}" + # Declare two variables - power AND energy - set to integers +power = 10 +energy = 10 # 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 = true # Declare two variables - arch_enemies AND sidekicks # arch_enemies should be an array of at least 3 different enemy strings # sidekicks should be an array of at least 3 different sidekick strings +arch_enemies = ["Larry", "Curly", "Moe"] +sidekicks = ["Groucho","Harpo","Chico"] # Print the first sidekick to your terminal +puts "#{sidekicks[0]} is the first sidekick" # Print the last arch_enemy to the terminal +puts "#{arch_enemies[2]} is the last arch enemey" # Write some code to add a new arch_enemy to the arch_enemies array +arch_enemies.push("Shemp") # Print the arch_enemies array to terminal to ensure you added a new arch_enemey +puts "#{hero_name} arch enemies are #{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 "#{hero_name} sidekicks are #{sidekicks}" # 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 +# - save_the_day should be a string a hero would say once they save the day # - bad_excuse should be a string a hero would say if they are too afraid of the danger_level # Your function should include an if/else statement that meets the following criteria # - Danger levels that are above 50 are too scary for your hero. Any danger level that is above 50 should result in printing the bad_excuse to the terminal # - Anything danger_level that is between 10 and 50 should result in printing the save_the_day string to the terminal # - If the danger_level is below 10, it means it is not worth your time and should result in printing the string "Meh. Hard pass." to the terminal. +def assess_situation( danger_level, save_the_day, bad_excuse) + if danger_level > 50 + puts "#{bad_excuse}" + + elsif danger_level >= 10 && danger_level <= 50 + puts"#{save_the_day}" + else + puts "Meh. Hard pass" + end +end #Test Cases announcement = 'Never fear, the Courageous Curly Bracket is here!' excuse = 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.' -# assess_situation(99, announcement, excuse) > Should print - 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.' -#assess_situation(21, announcement, excuse) > should print - 'Never fear, the Courageous Curly Bracket is here!' -#assess_situation(3, announcement, excuse) > should print - "Meh. Hard pass." +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) @@ -56,29 +86,77 @@ # - luckyNumbers (array) # - address (hash with following key/values: number , street , state, zip) +scary_monster = { + "name" => "Godzilla", + "smell" => "Wet lizzard", + "citiesDestroyed" => ["Denver", "St. Louis","New York City"], + "luckyNumbers" => [3,9,11], + "address" => { "number" => "1583", "street" => "Newton St.", "state" => "CO", "zip" => 80204} +} + # Create a new class called SuperHero # - Your class should have the following DYNAMIC values -# - name +# - name # - super_power -# - age +# - age # - Your class should have the following STATIC values # - arch_nemesis, assigned to "The Syntax Error" # - power_level = 100 -# - energy_level = 50 +# - 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_reader :name, :super_power, :age + def initialize( name, super_power, age) + @name = name + @super_power = super_power + @age = age + end + + @@arch_nemesis = "The Syntax Error" + @@power_level = 100 + @@energy_level = 50 + + def say_name + puts "#{@name}" + end + + def maximize_energy + energy_level = 1000 + end + def gain_power ( pwr_increase ) + puts "Power level is = #{@@power_level}" + puts "Power increase = #{pwr_increase}" + @@power_level += pwr_increase + puts "New Power level is = #{@@power_level}" + end + +end + # - Create 2 instances of your SuperHero class +bigJ = SuperHero.new("BigJ","Flight",18) +puts bigJ.say_name +puts bigJ.maximize_energy +puts bigJ.gain_power(10) + +john = SuperHero.new("John","Sleep", 48) +puts john.say_name +puts bigJ.gain_power(100) # Reflection # What parts were most difficult about this exerise? +# Remembering the syntax for hash +# Use of static variables # What parts felt most comfortable to you? +# variable declaration, if/elsif/else loops # What skills do you need to continue to practice before starting Mod 1? - +# I need to continue to study class creation and use diff --git a/section1/README.md b/section1/README.md index 4239d2a0c..eda52e5d9 100644 --- a/section1/README.md +++ b/section1/README.md @@ -36,8 +36,14 @@ Here's what we ask you do: Read [this article](https://pubs.ppai.org/pc-today/six-habits-of-super-learners/) about the habits of Super Learners. Reflect on this - what do you already do? Does this make you want to do anything new or different as you beginthis learning journey? Jot down your notes now, and we will ask you to share some reflections with your small group at the end of this section. +### +# Taking short breaks is new to me, but makes since. I know from experience that teaching +# what you have learned does work! +### + ## 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! @@ -139,7 +145,7 @@ This will open the `section1` directory in Atom. You should be able to see the d 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. 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. @@ -149,13 +155,13 @@ This will open the `section1` directory in Atom. You should be able to see the d 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) + - [x] [A Good First Program](https://learnrubythehardway.org/book/ex1.html) - - [ ] [Comments in Code](https://learnrubythehardway.org/book/ex2.html) + - [x] [Comments in Code](https://learnrubythehardway.org/book/ex2.html) - - [ ] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html) + - [x] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html) - - [ ] [Variables and Names](https://learnrubythehardway.org/book/ex4.html) + - [x] [Variables and Names](https://learnrubythehardway.org/book/ex4.html) - [ ] [Strings](https://learnrubythehardway.org/book/ex5.html) diff --git a/section1/exercises/booleans.rb b/section1/exercises/booleans.rb index d3216d9d5..bc9a0444b 100644 --- a/section1/exercises/booleans.rb +++ b/section1/exercises/booleans.rb @@ -9,7 +9,11 @@ p 7 > 2 # YOU DO: log to the console the result of "hello" is equal to "Hello": +p "hello" === "Hello" +puts "hello is equal to Hello is #{"hello" === "Hello"}" # YOU DO: log to the console the result of 3 is not equal to 4: +puts "3 is not equal to 4 is #{ 3 != 4}" # YOU DO: log to the console the result of 4 is less than or equal to 5: +puts "4 is <= to 5 is #{ 4 <= 5 }" diff --git a/section1/exercises/interpolation.rb b/section1/exercises/interpolation.rb index 2988c5181..faa6360be 100644 --- a/section1/exercises/interpolation.rb +++ b/section1/exercises/interpolation.rb @@ -15,16 +15,20 @@ speedy = "quick red fox" slow_poke = "lazy brown dog" -p # YOUR CODE HERE +puts "The #{speedy} jumped over the #{slow_poke}" # YOUR CODE HERE # 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. +movie_star_name = "Harrison Ford" +movie_roll = "Han Solo" +number_of_movies = 4 + +puts "#{movie_star_name} has played #{movie_roll} #{number_of_movies} times" diff --git a/section1/exercises/loops.rb b/section1/exercises/loops.rb index e8e69523e..4e7f43758 100644 --- a/section1/exercises/loops.rb +++ b/section1/exercises/loops.rb @@ -5,18 +5,27 @@ # Example: Write code that prints your name five times: 5.times do - p "Hermione Granger" + p "John" end # Write code that prints the sum of 2 plus 2 seven times: 7.times do - # YOUR CODE HERE + p 2 + 2 end +#sum = 0 +#7.times do +# sum = sum + 2 +# p sum +#end + # Write code that prints the phrase 'She sells seashells down by the seashore' # ten times: -# YOUR CODE HERE - +10.times do + p "She sells seashells down by the seashore" +end # Write code that prints the result of 5 + 7 a total of 9 timees -# YOUR CODE HERE +9.times do + p 5 + 7 +end diff --git a/section1/exercises/numbers.rb b/section1/exercises/numbers.rb index 91435ffb2..8dee96da6 100644 --- a/section1/exercises/numbers.rb +++ b/section1/exercises/numbers.rb @@ -7,10 +7,12 @@ p 2 + 2 # Write code that prints the result of 7 subtracted from 83: -p #YOUR CODE HERE +puts "The result of 7 subtracted from 83 is #{83 - 7}" # Write code that prints the result of 6 multiplied by 53: -# YOUR CODE HERE - +puts "The result of 6 times 53 is #{6 * 53}" + # Write code that prints the result of the modulo of 10 into 54: -# YOUR CODE HERE +puts "The result of the modulo of 10 into 54 is #{54 % 10}" +puts "#{54.modulo(10)}" + diff --git a/section1/exercises/strings.rb b/section1/exercises/strings.rb index b514a5a63..622e02577 100644 --- a/section1/exercises/strings.rb +++ b/section1/exercises/strings.rb @@ -4,12 +4,14 @@ # `ruby section1/exercises/strings.rb` # Example: Write code that prints your name to the terminal: -p "Alan Turing" +#p "Alan Turing" +puts "John Hennerich" # 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. \ No newline at end of file +# Write out code to log one line from your favorite song or movie. +puts "I've got a meeting with the Bobs in a few minutes" diff --git a/section1/exercises/variables.rb b/section1/exercises/variables.rb index d765e886a..b55657cc0 100644 --- a/section1/exercises/variables.rb +++ b/section1/exercises/variables.rb @@ -5,27 +5,34 @@ # Example: Write code that saves your name to a variable and # prints what that variable holds to the terminal: -name = "Harry Potter" -p name + +name = "John" +puts "Hello #{name}" +#puts "What is your name? " +#name = gets.chomp +#puts "Hello #{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 "Hello #{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 +warning_msg = "Harry Potter must not return to Hogwarts!" +puts "#{warning_msg}" # Write code that adds 2 to the `students` variable and # prints the result: students = 22 -# YOUR CODE HERE +students = 22 + 2 p students # Write code that subracts 2 from the `students` variable and # prints the result: -# YOUR CODE HERE + +students = 22 +students = 22 -2 p students @@ -33,27 +40,47 @@ # 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 = "John" +is_hungry = false +number_of_pets = 0 + +puts "Hello #{first_name}" +puts "Is #{first_name} hungry #{is_hungry}" +puts "#{first_name} has #{number_of_pets} pets" # IN WORDS: # How did you decide to use the data type you did for each of the three variables above? - # Explain. +# +# first_name is a string as it is text +# is_hungry is boolan as I am saying you either are or are not hungry (True/False) +# number_of_pets is an interger as you can only have whole numbers of pets # 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 = "John Hennerich" +is_hungry = true +number_of_pets = 100 + +puts "Hello #{first_name}" +puts "Is #{first_name} hungry #{is_hungry}" +puts "#{first_name} has #{number_of_pets} 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? \ No newline at end of file +# as you would expect? +# +# Yes! diff --git a/section1/gasmileage.rb b/section1/gasmileage.rb new file mode 100644 index 000000000..61a95ae23 --- /dev/null +++ b/section1/gasmileage.rb @@ -0,0 +1,6 @@ +### +# 100 miles +# 10 galllons of gas +### + +puts "Miles per gallon = #{100.00/10.00}" diff --git a/section1/orderofoperatons.md b/section1/orderofoperatons.md new file mode 100644 index 000000000..3a669b566 --- /dev/null +++ b/section1/orderofoperatons.md @@ -0,0 +1,2 @@ +In the United States we use an acronym called PEMDAS which stands for Parentheses Exponents Multiplication Division Addition Subtraction. That's the order Ruby follows as well. The mistake people make with PEMDAS is to think this is a strict order, as in "Do P, then E, then M, then D, then A, then S." The actual order is you do the multiplication and division (M&D) in one step, from left to right, then you do the addition and subtraction in one step from left to right. So, you could rewrite PEMDAS as PE(M&D)(A&S). + diff --git a/section1/reflection.md b/section1/reflection.md index 7ce0895a6..0bc27222f 100644 --- a/section1/reflection.md +++ b/section1/reflection.md @@ -2,18 +2,49 @@ 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? -1. How would you print the string `"Hello World!"` to the terminal? ++ I agree that all 6 habits listed in the article are important. It has been my experience that teaching what you have learned is the most effective for retention. A habit I could use to develop is eating better. -1. What character is used to indicate comments in a ruby file? +2. How would you print the string `"Hello World!"` to the terminal? +``` +puts "Hello World!" +``` -1. Explain the difference between an integer and a float? +3. What character is used to indicate comments in a ruby file? -1. In the space below, create a variable `animal` that holds the string `"zebra"` + The pound or hash sign # -1. How would you print the string `"zebra"` using the variable that you created above? +4. Explain the difference between an integer and a float? -1. What is interpolation? Use interpolation to print a sentence using the variable `animal`. + An integer is a whole number, a float is a decimal -1. What method is used to get input from a user? +5. In the space below, create a variable `animal` that holds the string `"zebra"` +``` +animal = "zebra" +``` -1. Name and describe two common string methods: \ No newline at end of file +6. How would you print the string `"zebra"` using the variable that you created above? +``` +puts "#{animal}" +``` + +7. What is interpolation? Use interpolation to print a sentence using the variable `animal`. + + #{} represents string interpolation in ruby. Anything inside the {} is evaluated as ruby code and will be embedded into the string around it. + + An example using interpolation: +``` +puts "You can see #{animal} in the zoo" +``` + +8. What method is used to get input from a user? + + `gets` + + `gets.chomp` + + +9. Name and describe two common string methods: + + `str.each_char` Evaluates each individual character of a given string + + `str.include` Evaluates the object for a given string or character and returns true if found our false if not. diff --git a/section1/ruby_the_hard_way_exercises/ex1.rb b/section1/ruby_the_hard_way_exercises/ex1.rb new file mode 100644 index 000000000..ebec88bd6 --- /dev/null +++ b/section1/ruby_the_hard_way_exercises/ex1.rb @@ -0,0 +1,7 @@ +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.' diff --git a/section1/ruby_the_hard_way_exercises/ex10.rb b/section1/ruby_the_hard_way_exercises/ex10.rb new file mode 100644 index 000000000..ea423c42b --- /dev/null +++ b/section1/ruby_the_hard_way_exercises/ex10.rb @@ -0,0 +1,14 @@ +tabby_cat = "\tI'm tabbed in." +persian_cat = "I'm split\non a line." +backslash_cat = "I'm \\ a \\ cat." + +fat_cat = ''' +I\'ll do a list: +\t* Cat food +\t* Fishies +\t* Catnip\n\t* Grass +''' +puts tabby_cat +puts persian_cat +puts backslash_cat +puts fat_cat diff --git a/section1/ruby_the_hard_way_exercises/ex11.rb b/section1/ruby_the_hard_way_exercises/ex11.rb new file mode 100644 index 000000000..4bd3b1902 --- /dev/null +++ b/section1/ruby_the_hard_way_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/ruby_the_hard_way_exercises/ex2.rb b/section1/ruby_the_hard_way_exercises/ex2.rb new file mode 100644 index 000000000..dffb2b27c --- /dev/null +++ b/section1/ruby_the_hard_way_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/ruby_the_hard_way_exercises/ex3.rb b/section1/ruby_the_hard_way_exercises/ex3.rb new file mode 100644 index 000000000..0b7380c60 --- /dev/null +++ b/section1/ruby_the_hard_way_exercises/ex3.rb @@ -0,0 +1,23 @@ +puts "I will now count my chickens:" + +puts "Hens #{25 + 30 / 6}" +puts "Roosters #{100 - 25 * 3 % 4}" + +puts "Now I will count the eggs:" + +puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 + +puts "Is it true that 3 + 2 < 5 - 7?" + +puts 3 + 2 < 5 - 7 + +puts "What is 3 + 2? #{3 + 2}" +puts "What is 5 - 7? #{5 - 7}" + +puts "Oh, that's why it's false." + +puts "How about some more." + +puts "Is it greater? #{5 > -2}" +puts "Is it greater or equal? #{5 >= -2}" +puts "Is it less or equal? #{5 <= -2}" diff --git a/section1/ruby_the_hard_way_exercises/ex4.rb b/section1/ruby_the_hard_way_exercises/ex4.rb new file mode 100644 index 000000000..8ab3641de --- /dev/null +++ b/section1/ruby_the_hard_way_exercises/ex4.rb @@ -0,0 +1,29 @@ +#total number of cars is 100 +cars = 100 + +# 4 people per car +space_in_a_car = 4.0 + +#30 people who will drive cars +drivers = 30 + +#90 people will be passengers +passengers = 90 + +# +cars_not_driven = cars - drivers + +cars_driven = drivers + +carpool_capacity = cars_driven * space_in_a_car + +average_passengers_per_car = passengers / cars_driven + + +puts "There are #{cars} cars available." +puts "There are only #{drivers} drivers available." +puts "There will be #{cars_not_driven} empty cars today." +puts "We can transport #{carpool_capacity} people today." +puts "We have #{passengers} to carpool today." +puts "We need to put about #{average_passengers_per_car} in each car." + diff --git a/section1/ruby_the_hard_way_exercises/ex5.rb b/section1/ruby_the_hard_way_exercises/ex5.rb new file mode 100644 index 000000000..ae56db83a --- /dev/null +++ b/section1/ruby_the_hard_way_exercises/ex5.rb @@ -0,0 +1,17 @@ + name = 'Zed A. Shaw' + age = 35 # not a lie in 2009 + height = 74 # inches + weight = 180 # lbs + eyes = 'Blue' + teeth = 'White' + hair = 'Brown' + +puts "Let's talk about #{ name}." +puts "He's #{ height} inches tall or #{ height * 2.54} cm tall." +puts "He's #{ weight} pounds or #{ weight * 0.453592} kg heavy." +puts "Actually that's not too heavy." +puts "He's got #{ eyes} eyes and #{ hair} hair." +puts "His teeth are usually #{ teeth} depending on the coffee." + +# this line is tricky, try to get it exactly right +puts "If I add #{ age}, #{ height}, and #{ weight} I get #{ age + height + weight}." diff --git a/section1/ruby_the_hard_way_exercises/ex6.rb b/section1/ruby_the_hard_way_exercises/ex6.rb new file mode 100644 index 000000000..7df0d653b --- /dev/null +++ b/section1/ruby_the_hard_way_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/section1/ruby_the_hard_way_exercises/ex7.rb b/section1/ruby_the_hard_way_exercises/ex7.rb new file mode 100644 index 000000000..76e46ed35 --- /dev/null +++ b/section1/ruby_the_hard_way_exercises/ex7.rb @@ -0,0 +1,23 @@ +puts "Mary had a little lamb." +puts "Its fleece was white as #{'snow'}." +puts "now using p" +p "Its fleece was white as #{'snow'}." +puts "And everywhere that Mary went." +puts "." * 10 # what'd that do? + +end1 = "C" +end2 = "h" +end3 = "e" +end4 = "e" +end5 = "s" +end6 = "e" +end7 = "B" +end8 = "u" +end9 = "r" +end10 = "g" +end11 = "e" +end12 = "r" + +# watch that print vs. puts on this line what's it do? +print end1 + end2 + end3 + end4 + end5 + end6 +puts end7 + end8 + end9 + end10 + end11 + end12 diff --git a/section1/ruby_the_hard_way_exercises/ex8.rb b/section1/ruby_the_hard_way_exercises/ex8.rb new file mode 100644 index 000000000..752cfdca1 --- /dev/null +++ b/section1/ruby_the_hard_way_exercises/ex8.rb @@ -0,0 +1,13 @@ +formatter = "%{first} %{second} %{third} %{fourth}" + +puts formatter % {first: 1, second: 2, third: 3, fourth: 4} +puts formatter % {first: "one", second: "two", third: "three", fourth: "four"} +puts formatter % {first: true, second: false, third: true, fourth: false} +puts formatter % {first: formatter, second: formatter, third: formatter, fourth: formatter} + +puts formatter % { + first: "I had this thing.", + second: "That you could type up right.", + third: "But it didn't sing.", + fourth: "So I said goodnight." +} diff --git a/section1/ruby_the_hard_way_exercises/ex9.rb b/section1/ruby_the_hard_way_exercises/ex9.rb new file mode 100644 index 000000000..3b3fdf5ef --- /dev/null +++ b/section1/ruby_the_hard_way_exercises/ex9.rb @@ -0,0 +1,15 @@ +# Here's some new strange stuff, remember type it exactly. + +days = "Mon Tue Wed Thu Fri Sat Sun" +months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" + +puts "Here are the days: #{days}" +puts "Here are the months: #{months}" + +puts %q{ +There's something going on here. +With this weird quote +We'll be able to type as much as we like. +Even 4 lines if we want, or 5, or 6. +} + diff --git a/section2/exercises/if_statements.rb b/section2/exercises/if_statements.rb index f29c45cdd..04d8bd266 100644 --- a/section2/exercises/if_statements.rb +++ b/section2/exercises/if_statements.rb @@ -3,14 +3,16 @@ # file by entering the following command in your terminal: # `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 = 'snowy' + #weather = 'rainy' + weather = 'icy' if weather == 'sunny' p "sunscreen" @@ -35,21 +37,25 @@ # Right now, the program will print # out both "I have enough money for a gumball" and -# "I don't have enough money for a gumball". Write a +# "I don't have enough money for a gumball". Write a # conditional statement that prints only one or the other. # Experiment with manipulating the value held within num_quarters # to make sure both conditions can be achieved. -num_quarters = 0 +#num_quarters = 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 have enough money for a gumball" +else + puts "I don't 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 +67,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 + p "I can make pizza" +else + p "I cannot make pizza" +end diff --git a/section2/exercises/methods.rb b/section2/exercises/methods.rb index f2517f1b3..3cd90ddc2 100644 --- a/section2/exercises/methods.rb +++ b/section2/exercises/methods.rb @@ -12,20 +12,32 @@ def print_name # Write a method that takes a name as an argument and prints it: def print_name(name) - # YOUR CODE HERE + p name end print_name("Albus Dumbledore") -# Write a method that takes in 2 numbers as arguments and prints +# 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: -# 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 three times with different arguments passed in. +def sumitup(num1, num2) + sum = num1 + num2 + p sum +end +sumitup(10,10) +sumitup(2, 2) +sumitup(4, 2) + +# Write a method that takes in two strings as arguments and prints +# a concatenation of those two strings. Example: The arguments could be +# (man, woman) and the end result might output: "When Harry Met Sally". +# Then call your method three times with different arguments passed in. +def dancername(pet, street) + p "Your dance name is #{pet} #{street}" +end +dancername("Duke", "Orchard") +dancername("Punkey", "Vrain") +dancername("Rosabell", "Newton") #------------------- # PART 3: Naming is Hard @@ -35,7 +47,10 @@ def print_name(name) # 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? + +# My method is called dancername as my idea is taken from the joke of take your pet name and the street name where you grew up and that is your stage name or "Dancer name" + # What did you name each parameter, and why? +# As my idea is your dancer name is your childhood pet plus your street name I used pet and street for the parameters # EXPLAIN: - diff --git a/section2/reflection.md b/section2/reflection.md index 49f0606df..af1977089 100644 --- a/section2/reflection.md +++ b/section2/reflection.md @@ -2,28 +2,88 @@ 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 have never had trouble asking questions as my family can surely confirm. I can relate to the notion of not wanting to ask to many questions early into a new job or role, but also feel why make your own mistakes when you can learn from others. Finding the right time to ask questions can be tricky but I think I a have a good feel on it. Google and search engines are a great resource but can let you down if dealing with proprietary or new technology. + ### If Statements 1. What is a conditional statement? Give three examples. ++ A statement used to perform a certain set of instructions if a specified condition is met. + +``` +if time < 12 + p "Its morning" +end + +if time >= 12 +p "Its afternoon" +end + +if time == 12 +p "Its exactly noon" +end +``` + 1. Why might you want to use an if-statement? -1. What is the Ruby syntax for an if statement? ++ You could use an if-statement to make decisions on what to display to the user depending on what input was received + +2. What is the Ruby syntax for an if statement? + +if `var` condition `value` + +*do something here* + +end -1. How do you add multiple conditions to an if statement? +3. How do you add multiple conditions to an if statement? + ++ You can use the and operator `&&` and the or operator `||` 1. Provide an example of the Ruby syntax for an if/elsif/else statement: +``` +if variable condition value + #do something +elsif variable condition value + #do something +else + #do something +end +``` + 1. Other than an if-statement, can you think of any other ways we might want to use a conditional statement? ++ setting a variable from user input could use a conditional statement + + ### Methods 1. In your own words, what is the purpose of a method? ++ a method allows you to create reusable code which can be called many times. + +2. Create a method named `hello` that will print `"Sam I am"`. + +``` +def hello() + p "Sam I am" +end +``` + +3. Create a method named `hello_someone` that takes an argument of `name` and prints `"#{name} I am"`. + +``` +def hello_someone(name) + p "#{name} I am" +end +``` -1. Create a method named `hello` that will print `"Sam I am"`. +4. How would you call or execute the method that you created above? -1. Create a method named `hello_someone` that takes an argument of `name` and prints `"#{name} I am"`. + `hello_someone("John")` -1. How would you call or execute the method that you created above? +5. What questions do you have about methods in Ruby? ++ What is good programing practice for where to define methods. Do they go at the top of a file or do you use a separate file and call that into your primary program? -1. What questions do you have about methods in Ruby? \ No newline at end of file ++ should you use return in methods or is it better not to? + diff --git a/section3/exercises/arrays.rb b/section3/exercises/arrays.rb index f710c6000..87737443f 100644 --- a/section3/exercises/arrays.rb +++ b/section3/exercises/arrays.rb @@ -15,50 +15,71 @@ # EXAMPLE: write code below that will print an array of animals. # Store the array in a variable. animals = ["Zebra", "Giraffe", "Elephant"]; -print animals +#print animals +puts animals +#p "animals array = #{animals}" # EXAMPLE: Write code below that will print "Zebra" from the animals array # YOUR CODE HERE -print animals[0] +puts animals[0] # YOU DO: Write code below that will print the number of elements in array of # animals from above. +puts "there are #{animals.length} elements in the array" # YOU DO: Write code that will reassign the last item in the animals # array to "Gorilla" - +animals[2] = "Gorilla" +#puts animals # YOU DO: Write code that will add a new animal (type of your choice) to position 3. - +animals.push("dog") +puts animals # YOU DO: Write code that will print the String "Elephant" in the animals array - +# this code finds the string Elephant inside the animals array and prints it to stdout +animals = ["Zebra", "Giraffe", "Elephant"]; +if animals.include? "Elephant" + puts "Array contains Elephant" +end #------------------- # PART 2: Foods: Array Methods #------------------- # YOU DO: Declare a variable that will store an an array of at least 4 foods (strings) +foods = ["Hamburger","Hotdog","Corn","Fries"]; # YOU DO: Write code below that will print the number of elements in the array of # foods from above. +puts "there are #{foods.length} elements in the array" # YOU DO: Write code below that uses a method to add "broccoli" to the foods array and # print the changed array to verify "broccoli" has been added - +foods.push("Broccoli") +puts foods # 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 foods - -# YOU DO: Write code to add 3 new foods to the array. +# 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("Ice Cream","Meatball","Pizza") +puts foods # YOU DO: Remove the food that is in index position 0. +puts "-----------" +puts foods +puts "-----------" +foods.shift() +puts foods +puts "-----------" #------------------- # PART 3: Where are Arrays used? @@ -77,11 +98,9 @@ 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 +# may be storing data? Come up with 3 examples - they could be from different web applications or # all from the same one. -# 1: -# 2: -# 3: - - +# 1: Netflix, watchlist = ["favorite movie1","movie2"] +# 2: Amazon shopping list, wishlist = ["favorite thing","thing2"] +# 3: King Scoopers grocery list, grocery_list = ["Milk","Flour","Yeast"] diff --git a/section3/exercises/hashes.rb b/section3/exercises/hashes.rb index 9d368c753..4dc81bbc1 100644 --- a/section3/exercises/hashes.rb +++ b/section3/exercises/hashes.rb @@ -1,6 +1,6 @@ # 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: +# 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: @@ -8,25 +8,26 @@ p foods # Write code that prints a hash holding zoo animal inventory: -zoo = #YOUR CODE HERE +zoo = {"lion" => 2, "tiger" =>3, "bear" => 4} p zoo -# Write code that prints all of the 'keys' of the zoo variable +# Write code that prints all of the 'keys' of the zoo variable # you created above: -# YOUR CODE HERE +puts"The keys of zoo are #{zoo.keys()}" -# Write code that prints all of the 'values' of the zoo variable +# Write code that prints all of the 'values' of the zoo variable # you created above: -# YOUR CODE HERE +puts"The values of zoo are #{zoo.values()}" -# Write code that prints the value of the first animal of the zoo variable +# Write code that prints the value of the first animal of the zoo variable # you created above: -# YOUR CODE HERE +puts "The value of lion is #{zoo["lion"]}" +puts "The value of tiger is #{zoo["tiger"]}" -# Write code that adds an animal to the zoo hash. +# Write code that adds an animal to the zoo hash. # Then, print the updated hash: -# YOUR CODE HERE - +zoo.store("dog", 10) +puts zoo #------------------- # Part 2: Email @@ -35,21 +36,34 @@ # 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 = { + "from_email_address" => "John.Hennerich@gmail.com", + "to_email_address" => "alkirewins@gmail.com", + "cc_email_address" => nil, + "subject" => "Test email", + "body" => "This is the body of the email message" +} + + # Write code that prints your email hash to the terminal. +p email -# Write code that prints all of the 'keys' of the email hash +# Write code that prints all of the 'keys' of the email hash # you created above: # YOUR CODE HERE +puts "----------" +puts"The keys of my email hash are #{email.keys()}" +puts "----------" -# Write code that prints all of the 'values' of the email hash +# Write code that prints all of the 'values' of the email hash # you created above: -# YOUR CODE HERE - +puts "----------" +puts"The values of my email hash are #{email.values()}" +puts "----------" #------------------- # Part 3: Many Emails - OPTIONAL EXTENSION @@ -64,7 +78,7 @@ # 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 +# 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: @@ -76,7 +90,7 @@ 'timestamp' => "4:37 PM August 13, 2019", 'number_likes' => 0, 'comments' => [] - }, + }, { 'image_src' => "./images/holiday-party.png", 'caption' => "What a great holiday party omg", @@ -86,16 +100,48 @@ } ] +puts "-----------" puts posts +puts "-----------" puts posts[0] +puts "-----------" -# 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 +# 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 +# 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. \ No newline at end of file +# Then, log the email Array to the console. + +email_msgs = [ + { + "from_email_adress" => "John.Hennerich@gmail.com", + "to_email_address" => "alkirewins@gmail.com", + "cc_email_address" => nil, + "subject" => "Hello Alkire", + "body" => "This is the body of the email message to Alkire" + }, + { + "from_email_adress" => "Paul.Hennerich@gmail.com", + "to_email_address" => "Ben.Hennerich@gmail.com", + "cc_email_address" => "John.Hennerich@gmail.com", + "subject" => "Hello brothers", + "body" => "This is the body of the email message to Ben" + }, + { + "from_email_adress" => "Jane.Hennerich@gmail.com", + "to_email_address" => "John.Hennerich@gmail.com", + "cc_email_address" => nil, + "subject" => "Hello kids", + "body" => "This is the body of the email message to John" + } +] +puts "-----------" +puts email_msgs +puts "-----------" +puts email_msgs[0] +puts "-----------" diff --git a/section3/reflection.md b/section3/reflection.md index cda726fd3..997e9de70 100644 --- a/section3/reflection.md +++ b/section3/reflection.md @@ -2,16 +2,42 @@ 1. What are two points from the Growth Mindset article and/or video that either resonated with you, or were brand new to you? + Some points from the podcast that resonated with me are: + + Track your own progress, don't compare yourself to others. As long as you keep going and make progress that is what is important. + + Don't panic if you don't know something, use your resources to learn and problem solve. + + You can be fixed mindset in some parts of your life and growth mindset in others. + 1. In which ways do you currently demonstrate a Growth Mindset? In which ways do you _not_? + To me Growth Mindset is similar or even the same as the saying "You can do anything if you put your mind to it". Applying and being accepted into the Turing program is an example for me. I find comfort in routines and planning. This fits more into the fixed mindset. 1. What is a Hash, and how is it different from an Array? + Per [Geeksforgeeks.com]( https://www.geeksforgeeks.org/ruby-hash-class/) +In ruby a hash is a collection of unique keys and their values. Hash is like an Array, except the indexing is done with the help of arbitrary keys of any object type. + 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 = { + "dogfood" => 10, + "catfood" => 10, + "dogs" => 5, + "cats" => 5 +} +``` 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? +``` +states.keys() +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? + Apps which require customer information could use a hash using their phone number for the key and other info like name and email as values. Searching the hash via phone number key would be faster. Also using a number instead of a name removes issues like misspelling. + 1. What questions do you still have about hashes? diff --git a/section4/exercises/burrito.rb b/section4/exercises/burrito.rb index 967f68b6c..ef5e70383 100644 --- a/section4/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,28 @@ def initialize(protein, base, toppings) @base = base @toppings = toppings end + + def add_topping + @toppings.push("tomato") + puts "adding #{@toppings} to the burrito" + end + + def remove_topping + puts "remove #{@toppings} from the burrito" + end + + def change_protein + orig_protein = @protein + @protein = "Beef" + puts "Changing #{orig_protein} to #{@protein}" + end + end dinner = Burrito.new("Beans", "Rice", ["cheese", "salsa", "guacamole"]) p dinner.protein p dinner.base p dinner.toppings +puts dinner.add_topping +puts dinner.remove_topping +puts dinner.change_protein diff --git a/section4/exercises/dog.rb b/section4/exercises/dog.rb index 03221314d..cff216ed6 100644 --- a/section4/exercises/dog.rb +++ b/section4/exercises/dog.rb @@ -19,6 +19,15 @@ def bark def eat @hungry = false end + + def play + @hungry = true + end + + def fetch + puts "#{@name} doesn't want to play" + end + end fido = Dog.new("Bernese", "Fido", 4) @@ -28,3 +37,6 @@ def eat p fido.hungry fido.eat p fido.hungry +fido.play +puts "After fido plays he is hungry: #{fido.hungry}" +fido.fetch diff --git a/section4/exercises/person.rb b/section4/exercises/person.rb index 2c26e9570..317ca03ef 100644 --- a/section4/exercises/person.rb +++ b/section4/exercises/person.rb @@ -1,5 +1,37 @@ -# Create a person class with at least 2 attributes and 2 behaviors. +# 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_reader :first_name, :last_name, :bday, :email_address + + def initialize( first_name, last_name, bday, email_address ) + @first_name = first_name + @last_name = last_name + @bday = bday + @email_address = email_address + end + + def sing + puts "Happy Birthy Day to You" + end + + def full_name + @full_name = @first_name + @last_name + puts "Your full name is #{@full_name}" + end + + def birthday + time = Time.new + today_date = time.month.to_s + time.day.to_s + time.year.to_s + if @bday == today_date + puts "Happy Birthday! #{@first_name}" + end + end + +end +john = Person.new("John","Hennerich","1182021","john.hennerich@gmail.com") +puts john.first_name +john.sing +john.full_name +john.birthday diff --git a/section4/reflection.md b/section4/reflection.md index 68b044b00..1e6d92aeb 100644 --- a/section4/reflection.md +++ b/section4/reflection.md @@ -2,21 +2,46 @@ 1. How different did your workflow feel this week, considering we asked you to follow the Pomodoro technique? + Honesty without knowing it I was kind of already following the Pomodoro technique, at least with respect to taking short breaks every 50 minutes or so. As I do not have a mechanical timer I did use my computer to track the time. + 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)? + I realized that I was more distracted than I thought I would be. By defining an issue to focus on until time was up allowed me to realize how much multitasking I was trying to do. + 1. In your own words, what is a Class? + A class is a basic guide line of what an object should be made of and what it should be able to do. + 1. What is an attribute of a Class? -1. What is behavior of a Class? + Attributes are specific properties of an object. In ruby instance variables are attributes. -1. In the space below, create a Dog class with at least 2 attributes and 2 behaviors: - -```rb +1. What is behavior of a Class? + Instance methods define the behavior of a class. +1. In the space below, create a Dog class with at least 2 attributes and 2 behaviors: +``` +class Dog + attr_reader :name, :breed, :owner + + def initialize(name, breed, owner) + @name = name + @breed = breed + @owner = owner + end + + def bark + puts "woof woof arf arf" + end + + def fetch + puts "#{@name} doesn't want to play" + end +end ``` 1. How do you create an instance of a class? ++ use the class method `.new`. For example if you have a class called Person, you would use `Person.new` -1. What questions do you still have about classes in Ruby? \ No newline at end of file +1. What questions do you still have about classes in Ruby?