Skip to content

Commit

Permalink
Start weekend revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitvan committed Jul 16, 2022
1 parent 8b3e9a7 commit 440d18e
Show file tree
Hide file tree
Showing 65 changed files with 3,107 additions and 14 deletions.
28 changes: 28 additions & 0 deletions be-weekend-new/archive/code-challenge/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
layout: lesson
---

# Final Challenge

Now that we've learned about until loops, if/else statements, integers, strings, and variables, we're ready to write our first program that brings it all together! (And let's be honest, probably the only thing your friends will think is somewhat cool from today).

We'll do this challenge all together, and we'll start by writing pseudocode to fully understand all of the discrete pieces.

Pseudocode is an English-like version of code that will help us define all of the individual steps that need to happen in order to play the number guessing game. We'll act it out as humans, pausing to jot down everything that needs to happen.

Here are the specifications:

<div class="try-it-new">
<h2>Try It: Guess the Number</h2>
<p>Use what you know about while loops and if/else statements to write a program that sets a secret number, then allows a user to guess. If the number is too high, print "Too high!" and prompt the user to guess again. If the number is too low, print "Too low!" and prompt the user to guess again. If the number guessed is the secret number, then print "Correct!" and exit the game.</p>
<p>Important: <code class="try-it-code">gets</code> stands for "get string". This means that even if the user enters a number, like 9, the computer reads it as "9" (which is not the same as 9). </p>
<pre>Guess a number.
5
Too low!
10
Too high!
9
Correct!</pre>
</div>

<a href="../">Back to Curriculum Index</a>
92 changes: 92 additions & 0 deletions be-weekend-new/archive/control-flow/1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
layout: lesson
---

# Control Flow

<a href="../">Back to Curriculum Index</a>

## Goals

- Write loops using `while`
- Write branches using `if`
- Engage in a productive struggle while you write programs without being taught 100% of what you need to know

## Control Flow

**Control Flow** refers to being able to determine what the program does given certain inputs. It controls the flow of the program!

**Loops** are one type of control flow. Let's dig in to how they work by taking a look at the program below, focusing on these questions:

1. What happens if you continually press c?
2. What happens if you press capital C?
3. What happens if you press any key other than c?
4. What part(s) of the code are repeated when the program runs?
5. What part(s) of the code only run once?
6. What happens if you remove line 1? Why does this happen?
7. What happens if you replace line 1 with `input = "a"`? Why?
8. What does the `==` on line 3 do? What happens if you change it to `!=`? Why?

<iframe height="400px" width="100%" src="https://repl.it/@turingschool/Loop-Example?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>

<!-- Now let's look at a slightly more complex example, focusing on these questions:
1. What new variable has been introduced and how is it used?
2. What happens if you change the variable to `count = 10`?
3. What does `count += 1` do?
4. What happens if you remove line 7? Why?
5. What happens if you remove line 6? Why? -->

<!-- <iframe height="400px" width="100%" src="https://repl.it/@turingschool/Loop-Example-With-Counter?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe> -->

<div class="try-it-new">
<h2>Try It: Writing a Loop</h2>
<p>Make a new repl (or use <a href="https://repl.it/@turingschool/Todo-List" target="blank">this one</a> if you're more comfortable starting with training wheels!). Use what you know about loops and arrays to write a program that collects items on a user's "To-Do" list. Your program should continue asking for more to-dos UNLESS the user presses "e" for exit. Then print out all of the to-do items.</p>
<p>Here's an example of how your program should function:</p>
<pre>Add an item to your todo list or press 'e' to exit:
unpack suitcase
Add an item to your todo list or press 'e' to exit:
bring ballot to drop box
Add an item to your todo list or press 'e' to exit:
finish reading book
Add an item to your todo list or press 'e' to exit:
e
-----------------------------
Here is your todo list:
unpack suitcase
bring ballot to drop box
finish reading book
e
</pre>
<p>NOTE: the "e" for exit will print out in your todo list for now. That's ok! We'll learn how to remove it in the next exercise.</p>
<div class="spicy-container">
<p class="spicy-click">🌶Spicy Challenge🌶</p>
<div class="spicy-toggle">
<p>Can you report to the user how many times they've let the loop continue?</p>
<p>Can you report to the user how many times they've pressed a specific letter (for example, "You've pressed 'a' 2 times")?</p>
</div>
</div>
</div>


## If statements

We're going to dive right in to reading some code! Before you run the example, guess what the program will do.

<iframe height="400px" width="100%" src="https://repl.it/@turingschool/Loops-and-If-Statements?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>

<div class="try-it-new">
<h2>Try It: Writing a Loop</h2>
<p>Modify your todo program (or use <a href="https://repl.it/@turingschool/Todo-Starter" target="blank">this one</a> if you haven't quite finished your own) to make it so that the letter "e" doesn't get included in your final list.</p>

<div class="spicy-container">
<p class="spicy-click">🌶Spicy Challenge🌶</p>
<div class="spicy-toggle">
<p>Can you tell the user how many todos they have on their list each time they are prompted to enter another one? Check out <a href="https://apidock.com/ruby/Array/length">this resource</a> if you need a starting place.</p>
<p>Can you change the interaction pattern of your program so that it will ONLY ask for five todo items and then quit?</p>
</div>
</div>
</div>


<a href="../">Back to Curriculum Index</a>
133 changes: 133 additions & 0 deletions be-weekend-new/archive/control-flow/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
layout: lesson
---

# Control Flow

<a href="../">Back to Curriculum Index</a>

## Goals

- Describe the purpose of a conditional statement
- Write programs that incorporate `if`, `elsif`, and `else` portions of a conditional statement
- Engage in a productive struggle while you write programs without being taught 100% of what you need to know

## Control Flow

**Control Flow** refers to being able to determine what the program does given certain inputs. It controls the flow of the program!

**If statements** are a type of control flow. An if statement sets up different paths that the program can take depending on what is true at a given moment.

<div class="try-it-new">
<h2>Try It: Reading if Statements</h2>
<ol>
<li>Look at the code in the repl below. Jot down your prediction of what will happen when we run this code.</li>
<iframe height="400px" width="100%" src="https://repl.it/@turingtrycoding/controlflowbasic?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>
<li>Once you've made your predictions, run the code and look at the output. Review your original guesses and correct anything you wrongly predicted.</li>
</ol>

<div class="spicy-container">
<p class="spicy-click">Finished Early?</p>
<div class="spicy-toggle">
<p>How could you modify this code so that it doesn't matter whether or not the user types capital letters or lower case letters?</p>
</div>
</div>

</div>

Great! Let's make it slightly more complicated:


## if/elsif/else Statements

We can provide our program with as many options as we'd like by utilizing the `elsif` keyword. Check out an example:

```ruby
print "What is the best type of cookie: "
cookie_type = gets.chomp

if cookie_type == "Chocolate Chip"
puts "Correct!"
elsif cookie_type == "Oatmeal Raisin"
puts "Yuck!"
else
puts "Hmm. I don't recognize that kind of cookie."
end
```

Some important things to note:
- An if statement must always begin with one `if` keyword and end with one `end` keyword
- We can have as many `elsif` conditions as we want
- Like `if`, we must provide a condition to `elsif`
- `else` can be used once or not at all

<div class="try-it-new">
<h2>Try It: Writing if/elsif/else Statements</h2>
<p>In a repl, write a small program that asks a user what their favorite season is.</p>
<p>Once you have their response, give them some a seasonally appropriate greeting of your choice!</p>

<div class="help-container">
<button class="help-click">🤚Help Me!</button>
<div class="help-toggle">
<p>Check out <a target="blank" href="https://repl.it/@ameseee/GrossMysteriousSupercollider">this example</a>.</p>
</div>
</div>
</div>

## One Level Up

<div class="try-it-new">
<h2>Try It: Checking for Long Words</h2>
<p>Write a program in Ruby that asks the user for a word. If it is longer than 10 characters, print out "Wow, that's a big word!". If it's shorter, print out "That's all you've got?".</p>
<p>This is what the program should look like when it runs:</p>
<pre>Gimme a word:
Coding
That's all you've got?</pre>
<pre>Gimme a word:
floccinaucinihilipilification
Wow, that's a big word!</pre>

<div class="help-container">
<button class="help-click">🤚Help Me!</button>
<div class="help-toggle">
<p>Check out <a target="blank" href="https://repl.it/@ameseee/MagnificentUncomfortableDll">this example</a>.</p>
</div>
</div>

</div>

## Solving Problems Without Knowing Everything

As a programmer, you will constantly be solving problems that you don't necessarily know how to solve. This is the fun of coding! Coding involves solving puzzles, guess-and-check, and figuring things out.

The next Try It section asks you to build something, but we have only taught you about 80% of what you need to know in order to build this! 🙀 This is meant to mimic how projects work at Turing -- we purposefully leave out key pieces of information so that you get practice Googling and reading documentation in order to build a solution.

Luckily for you, we won't make this _too_ difficult today. The following resources should lead you down the right track:

- <a href="https://stackoverflow.com/questions/22640570/i-have-a-simple-odd-or-even-test-in-ruby-but-its-not-working" target="blank">A Stackoverflow post on Ruby even/odd methods</a>
- <a href="https://riptutorial.com/ruby/example/16995/even-and-odd-numbers" target="blank">even? and odd? methods in Ruby</a>
- Spicy: <a href="https://stackoverflow.com/questions/3517238/what-does-the-operator-do-in-ruby-in-n-2" target="blank">Modulo operator</a>

<div class="try-it-new">
<h2>Try It: Control Flow</h2>
<p>Create a new repl. Write a program that asks a user for a piece of text. It would output "even" if the number of characters in the text is even, and "odd" if the number of characters in the text is odd.</p>
<p>This is what the program should look like when it runs:</p>
<pre>Enter a piece of text:
Turing
Even!</pre>
<pre>Enter a piece of text:
Hello
Odd!</pre>
<p>Try running your program a few times with different inputs.</p>
<div class="spicy-container">
<p class="spicy-click">🌶 Click here for a Spicy Challenge 🌶</p>
<div class="spicy-toggle">
<ul>
<li>Can you make your program tell the user not only if a word has an even or odd number of characters, but also how many characters they entered? For example, your program would say: Even! (6) or Odd! (3)</li>
<li>Can you make your program only count characters, but ignore spaces? For example, if the user types in chocolate chip cookies are the best, your program should return 30, not 35. It might help to google something like how do you ___________ in Ruby?</li>
</ul>
</div>
</div>
</div>

<a href="../">Back to Curriculum Index</a>
83 changes: 83 additions & 0 deletions be-weekend-new/archive/looping/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
layout: lesson
---

# Looping

## Goals

- Describe what a loop is and why we would use a loop
- Define "loop condition" and "sentry variable"
- Write a program that uses a loop to execute a set of instructions indefinitely

## Looping

Looping is the idea that something will happen **until** a condition is met. Here are some examples of looping in real life:

- Keep counting **until** you reach 100
- Keep taking bites **until** your dinner is finished
- Keep pressing keys **until** your essay is finished
- (on a page of 20 math problems) Keep solving math problems **until** you have done all 20
- Keep making burritos **until** you have enough to feed all of your friends
- Keep washing dishes **until** until there are no more in the sink

In the examples above, the portion after **until** represents what we call the _loop condition_. This specifies what must be true in order for the loop to keep running.

A _sentry variable_ is the piece of data that is in full control of whether or not the loop condition is true or false. Look at the two examples of sentry variables below:
- Keep counting until you reach 100: sentry variable is `count`
- Keep taking bites until your dinner is finished: sentry variable is `dinner_finished`

<div class="try-it-new">
<h2>Try It: Looping Examples</h2>
<p>Brainstorm:</p>
<ol>
<li>An example of a loop in real life that happens a set number of times. What is the sentry variable? </li>
<li>An example of a loop in real life that might happen an indefinite number of times. What is the sentry variable? </li>
</ol>
</div>

```ruby
# this code snippet is for the Try It: Reading Looping Code section
stomach = 0

until stomach == 10
puts "keep eating!"
stomach += 1
end

puts "done eating."
```

<div class="try-it-new">
<h2>Try It: Reading Looping Code</h2>
<p>Read through the code above line by line. Focus on the following questions:</p>
<ol>
<li>How many times will "keep eating!" print out? Why?</li>
<li>How many times will "done eating." print out? Why?</li>
<li>What is the sentry variable?</li>
<li>What is the looping condition?</li>
<li>What would happen if you changed <code class="try-it-code">stomach += 1</code> to <code class="try-it-code">stomach += 2</code>?</li>
<li>What problem would arise if you changed <code class="try-it-code">stomach += 1</code> to <code class="try-it-code">stomach += 3</code>? What could you change about the loop condition to prevent this problem?</li>
<li>What would happen if you removed line <code class="try-it-code">stomach += 1</code> altogether?</li>
</ol>
<p>Once you're done predicting, <a href="https://repl.it/@turingtrycoding/looping">run the code in this repl</a>! Try experimenting with all of the scenarios above by modifying the code and re-running it.</p>
</div>

## Programming a 5 year old

Have you ever been a car with a five-year-old?

<div class="try-it-new">
<h2>Try It: Are we there yet?</h2>
<p>Back on repl.it, create a new repl.</p>
<p>Write a program that asks a user "Are we there yet?" The user can enter anything. If they enter "yes", then the loop should stop and the program should print out "Finally!"</p>
<p><b>Training Wheels:</b> If you're not sure how to start, you can use <a target="blank" href="https://repl.it/@turingtrycoding/loopingtrainingwheels">this starter code</a>.</p>
<div class="spicy-container">
<p class="spicy-click">🌶 Click here for a Spicy Challenge 🌶</p>
<div class="spicy-toggle">
<p>Can you make your program case-insensitive? This means that the user should be able to enter "YES" or "Yes" or "yes" or "yEs", etc.</p>
</div>
</div>
</div>

<a href="../">Back to Curriculum Index</a>
46 changes: 46 additions & 0 deletions be-weekend-new/archive/programming/1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
layout: lesson
---

# Programming is Hard

<a href="../">Back to Curriculum Index</a>

## Tweets From Experienced Developers

In the final section of today's class, we'll dive deeper into the fundamentals of Ruby. **It will be hard**. That said, it's entirely possible to learn and get better at! It's also 100% ok to not know everything. It's important to develop a **positive relationship with struggle** in addition to understanding the mindset of a successful developer.

Take a moment to look through some tweets from experienced developers, while reflecting on the questions below.

<ol>
<li>What themes do you notice?</li>
<li>When was the last time you failed at something? How did you react? What did you do?</li>
<li>What strategies do you personally use to learn something new?</li>
</ol>

<ul>
<li><a target="blank" href="https://twitter.com/getify/status/972495616600293381?lang=en">Tweet #1</a></li>
<li><a target="blank" href="https://twitter.com/MollyATX/status/834605666887151617">Tweet #2</a></li>
<li><a target="blank" href="https://twitter.com/StabbyCutyou/status/1019567754968485888">Tweet #3</a></li>
<li><a target="blank" href="https://twitter.com/Malarkey/status/1009825823262588929">Tweet #4</a></li>
<li><a target="blank" href="https://twitter.com/hacks4pancakes/status/835979787248222212">Tweet #5</a></li>
<li><a target="blank" href="https://twitter.com/OneDevloperArmy/status/1028964083813560320">Tweet #6</a></li>
<li><a target="blank" href="https://twitter.com/jschauma/status/835960607606202375">Tweet #7</a></li>
</ul>


## A Developers Mindset

To be a developer, you don't have to remember everything. What's more important is that you're curious, resourceful, communicative, and you're not afraid to question how things work.

At Turing, we frame our thinking (which informs curriculum, instruction, and coaching) around two things that are essential for students to gain the skills they need while at Turing, and be successful on the job:
1. When people have a **growth mindset**, a belief that intelligence can be developed, they display the following behaviors:
- willingness to embrace challenge
- persist in the face of setbacks
- see effort as part of the path to success
- solicit feedback to improve
- view others' success as inspiration
2. **Productive struggle** is a state of engagement where learners can work through increasingly challenging problems and problems they have never seen before. Strong developers learn to monitor their struggle and assess whether it is productive or unproductive. When it becomes unproductive, it's important to ask for help! Productive struggle helps people continue to develop their grit and creative problem solving!

<br>
<a href="../">Back to Curriculum Index</a>
Loading

0 comments on commit 440d18e

Please sign in to comment.