The assignments listed here should take you approximately 2 hours.
To start this assignment, click the button in the upper right-hand corner that says Fork. This is now your copy of the document. Click the Edit button when you're ready to start adding your answers. To save your work, click the green button in the bottom right-hand corner. You can always come back and re-edit your gist.
Documentation of a langauge, framework, or tool is the information that describes its functionality. For this part of the practice tasks, you're going to practice digging into documentation and other reference material.
NOTE: The linked documentation for each question below is a good starting place, but you should also be practicing your Googling skills and sifting through the results to find relevant and helpful sites.
-
In your own words, what does the Ruby array drop method do? As you're explaining, be sure to provide an example. Your answer: The drop method returns results after a defined number of elements in the array.
-
What did you Google to help you with this task, and how did you pick your results? I used google becuase the provided page didn't use simple enough terms for me to understand. I picked my result because it was on an online education platform, so it was specifically targetted for new learners.
-
In your own words, what does the Ruby string split method do? As you're explaining, be sure to provide an example. Your answer: A split function seperates elements in a string into individual elements in an array. This division can happen at any point specified by the split funciton.
-
What did you Google to help you with this task, and how did you pick your results? I googled ruby string "split method". The first two results were from thoughtco.com and after I looked at the first one I didn't think they worked for me or were reputable. I went to teh 3rd result and it was much mroe helpful.
-
In your own words, what does the JavaScript array slice method do? As you're explaining, be sure to provide an example. Your answer: The Javascript array slice method extracts a selection of an array based on a starting and stopping point. This result is in the form of a new array.
An example would be var sports = ["basketball", "climbing", "swimming", "chess"] sports.slice(1,3) would return ["climbing", "swimming"]
- What did you Google to help you with this task, and how did you pick your results? I googled JavaScript array "slice method". The second result had tutorial in it's title so I chose that. Next time I can use that word in my search.
Imagine that you're taking your favorite board game and turning it into a computer-based game.
-
Name of board game: Settlers of Catan
-
Use the space below to categorize game data into each of the following data types. You should have a minimum of two pieces of data for each category.
- String data: Text on instructions and text on cards.
- Integer and/or float data: Integer would be amount of players, Float data would be average amount of sheep cards on the board during the game.
- Boolean data: Has someone reached 9 points, yes or no?
- Array data: Array data could be the cards in a person's hand ex. ["sheep", "sheep", "brick", "knight"]
- Hash or Object data: This could show the amount of each type of card in the game. Ex. var cardAmount ["sheep": 8, "brick": 8}
-
Create a list below of three real-life situations where iteration is used. For each situation, explain why it would be an example of iteration.
-
A factory assembly line is a good example. It's a repeated process, and may undergo changes or upgrades in it's lifespan that creates new "iterations."
-
An author can be iterative. First they will write a skeleton or plotline of the story they want to tell. Then they will keep going back and adding more and more detail to the story.
-
A sculptor is iterative. They first create a general shape, then slowly go back and perfect it until they get to a desired result.
-
Create a list below of three programming situations where iteration would be used. For each situation, explain why it would be an example of iteration.
-
Most for loops are iterative. An algorithm can be created, and then used repeatedly on each item within something like an array. This process could go until it reaches the end of the array, and then repeated or finish.
-
Another example of iteration could be in "proof-reading" your code. First you go through looking for certain types of potential errors. Once finished, you could then go back through and look for specific things that would help streamline your code and make it more efficient.
-
A sort of combination between programming and real world could be a situation where you have a list of employees first and last names, as well as phone number and email. You could create an algorith that goes through the list and attaches all of the information of one person together, so that it can be later made into an employee directory.
The following code examples each contain a mistake. Describe the problem for each.
Original | Mistakes | Problem |
---|---|---|
students.each do |student| puts "Welcome, #{student}" end |
students.each do |student| puts "Welcome, #(student)" end |
The problem is the first student used curly brackets, while the second student used parentheses. |
.main-content { font-size: 12px; border: 3px solid black; font-family: sans-serif; } |
.main-content { font-size: 12px; border: 3px solid black; font-family: sans serif; } |
The problem is sans-serif in the second example doesn't have a dash inbetween the two parts, so the computer wouldn't understand what font that is. |
log(2, (1022 * ((score - min(score) over ()) / ((max(score) over ()) - (min(score) over ()))) + 2)::numeric) | log(2, (1022 * ((score - min(score) over ()) / ((min(score) over ()) - (min(score) over ()))) + 2)::numeric) | The problem is the second examples uses ((min(score) when it should be max score. It may give a result, but the answer will not be what was intended. |
arr.product(arr).reject { |a,b| a == b }.any? { |a,b| a + b == n } | arr.product(arr).reject { |a,b| b == b }.any? { |a,b| a + b == n } | The problem is the second example used b == b instead of a == b, which will yield different results. |
class Cat attr_reader :color, :name def initialize(data) @name = data[:name] @color = data[:color] end end |
class Cat attr_reader :color, :name def intialize(data) @name = data[:name] @color = data[:color] end end |
The problem is the second example misspelled initialize, and instead wrote intialize. |
- Watch this video and follow each step to modify your own bash profile. As mentioned in the video, you will need this snippet below:
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
echo ""
fi
}
# get current status of git repo
function parse_git_dirty {
status=`git status 2>&1 | tee`
dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
bits=''
if [ "${renamed}" == "0" ]; then
bits=">${bits}"
fi
if [ "${ahead}" == "0" ]; then
bits="*${bits}"
fi
if [ "${newfile}" == "0" ]; then
bits="+${bits}"
fi
if [ "${untracked}" == "0" ]; then
bits="?${bits}"
fi
if [ "${deleted}" == "0" ]; then
bits="x${bits}"
fi
if [ "${dirty}" == "0" ]; then
bits="!${bits}"
fi
if [ ! "${bits}" == "" ]; then
echo " ${bits}"
else
echo ""
fi
}
export PS1="\u\w\`parse_git_branch\`$ "
If you have any questions, comments, or confusions from the any of the readings that you would an instructor to address, list them below: