Wednesday, November 30, 2016

Space Ship Scene Reflection



  1. The purpose of the code is to create a scene in space. It works by calling multiple functions that create objects such as spaceships and planets. The most important features are randomized planets with craters, a ufo, a black hole, and a spaceship with animated fire.

  1. The most difficult part for me was the fire for the spaceship. It had to be animated, and look like fire. I achieved the fiery look by making the fire made out of 2 curves, one to the left and one to the right. I then turned the turtle 180 degrees and repeated it, so it got to the original start position of the flame. I then took a stored variable of the distance away from the center of the ship, and had it return to the center. To animate the flames, I had the draw flames loop for infinity, which made new flames constantly, making it animated.

  1. An abstraction I used was to split up the main function of drawing the spaceship into smaller sub functions. I had a simple main function that was split up into smaller more complex functions. The main function called functions to draw the body of the ship, the top, the rocket, and the flames. The main function also had a parameter to rotate the ship. Functions with parameters are a type of abstraction.


  1. We used collaboration to split up the tasks into manageable chunks. We each had sections of code we chose to make. Collaboration was also used for feedback. Before putting everything in the main code, we shared our result and our team mates gave their feedback on it so it could be improved.

CODE:
function drawShip(angle) {
  hide();
  turnTo(angle);
  drawBody();
  drawTop();
  drawRocket();
  drawFlames();
}
function drawBody() {
  penDown();
  penColor("#FA6323");
  penWidth(20);
  turnLeft(90);
  moveForward(15);
  for (var i = 0; i < 3; i++) {
    turnRight(90);
    moveForward(30);
  }
  turnRight(90);
  moveForward(15);
  turnRight(90);
  moveForward(15);
  dot(21);
  penColor("black");
  dot(15);
  penColor("#FACF23");
  dot(13);
}
function drawTop() {
  penUp();
  penColor("#7A7A7A");
  moveForward(40);
  dot(15);
  moveBackward(10);
  turnRight(90);
  moveForward(15);
  turnLeft(90);
  penDown();
  turnLeft(30);
  for (var i = 0; i < 2; i++) {
    moveForward(30);
    turnLeft(120);
  }
  moveForward(30);
  penUp();
  moveBackward(15);
  turnLeft(90);
  moveBackward(22);
}
function drawRocket() {
  penUp();
  moveBackward(40);
  penColor("#4A4A4A");
  penDown();
  penWidth(15);
  turnLeft(90);
  moveForward(5);
  turnLeft(30);
  moveForward(15);
  turnLeft(150);
  moveForward(30);
  turnLeft(150);
  moveForward(15);
  turnRight(60);
  penUp();
  turnLeft(90);
  moveForward(3);
  turnLeft(90);
}
function drawFlames() {
moveForward(15);
speed(100);
var originalDist;
var arcDist;
for (var i = 0; i < 1; i) {
  turnRight(90);
  penRGB(255, randomNumber(104, 175), 17, 1);
  penWidth(randomNumber(2, 6));
  penDown();
  originalDist = randomNumber(-20, -2);
  arcDist = randomNumber(15,40);
  moveForward(originalDist);
  turnLeft(90);
  arcRight(30, arcDist);
  arcLeft(30, arcDist);
  turnRight(180);
  arcLeft(30, arcDist);
  arcRight(30, arcDist);
  turnRight(180);
  arcLeft(30, arcDist);
  arcRight(30, arcDist);
  turnRight(180);
  arcRight(30, arcDist);
  arcLeft(30, arcDist);
  turnRight(90);
  moveForward(originalDist);
  turnRight(90);
}
}
drawShip(0);

Wednesday, November 23, 2016

Smiley Face

https://studio.code.org/projects/applab/U_jdUmHE-fs-h2KCsjBu8w

https://studio.code.org/projects/applab/gZij3sn3oweRYoALNHxD9A

Monday, November 21, 2016

Functions with parameters

Prompt: 1.  Develop a rule for deciding when to create a function with a parameter rather than a normal function. Below your rule write a couple sentences justifying your rule.
Whenever you have a function that needs an input, use parameters. For example, if you had a function that took 2 numbers and added them, then multiplied them together, you would want a parameter for the input.

Prompt 2. When do you need a function with a parameter?
Whenever you need a outside input to the function.

Iteration

Define and provide examples of iteration:
Iteration: loops, repeating something.

examples: loops in code. for loops, while loops, and do while.

Friday, November 18, 2016

Smiley code reflection


Copy and paste your code to create your smiley face.  

penColor("lightgreen");
dot(500);
penUp();
penColor("purple");
penWidth(5);
move(0, -175);
penDown();
move(0, 50);
penUp();
move(0, 50);
turnRight(45);
penColor("red");
penDown();
arcRight(180, 25);
moveForward(50);
penUp();
moveTo(160, 165);
turnTo(-45);
penDown();
arcLeft(180, 25);
moveForward(50);
penColor("purple");
penUp();
moveTo(140, 300);
penDown();
turnTo(-90);
arcLeft(180, 25);
penUp();
moveForward(40);
penDown();
moveForward(10);
arcLeft(180, 12.5);
arcRight(180, 12.5);
moveForward(10);



What challenges did you face in this lab?
The biggest challenge was finding where to put all of the dots/curves

How did you solve these challenges?  
I figured out the center of the coordinate grid by guess and check, then offset the dots a equal distance from the center.

Did you collaborate with others in class?
no

Did you get or provide help to other "programmers" in class?  With what?  What documentation did you use for this lab today?  
I used the documentation from code.org

Provide examples of other libraries you are familiar with in other programming languages.

I’m familiar with a lot of the libraries in Java, such as the input, and the math librarys.

Wednesday, November 16, 2016

Unit 3 stage 5 reflection

function drawStep(){
 moveForward();
 turnLeft();
 moveForward();
 right();
}

function right(){
 turnLeft();
 turnLeft();
 turnLeft();
}
function drawSide() {
 drawStep();
 drawStep();
 drawStep();
 moveForward();
 right();
}
function drawDiamond() {
 drawSide();
 drawSide();
 drawSide();
 drawSide();
}
drawDiamond();

1. Prompt: “List the benefits of being able to define and call functions in a program. Who specifically gets to enjoy those benefits?”
Everyone enjoys the benefits of functions. It makes programmer’s lives easier, and also makes the code easier to read and understand. It organizes code, saves you from writing repeating code, and makes the code easier to read.

2. Prompt: “How is the use of a function an example of abstraction?”
Functions are an example of abstraction because it can make parts of your code reduced to essential commands. It reduces large chunks of code into nicely named functions, which give only the essential data. Within the function, only the relevant data is passed into it, making it simplified.

3. Prompt:  Explain more than one reason why programming languages have functions.

Functions are useful tools to split up code and make it look logical, while also being able to reuse sections of code. For example, if I had a section of code that calculated (number A x number B - 52)/5, or something that took out a section of a string, instead of rewriting that code, I could just use a function, and call that function inputting the numbers. They also organize code. Instead of having a large chunk of code that does a complicated math function, you could send it to a function, which might be named takeDerivative(). That way you know it takes the derivative of the function, without seeing the large chunk of code.

Monday, November 14, 2016

Ch 3 Stage 4 reflections

Define efficiency in programming.
When we are trying to be "efficient" in our programming what are some (valuable) resources we might be concerned with?  Why does it matter?

I think efficiency in programming is using the minimum amount of code to run a program with the minimum amount of resources needed. The resources we might be concerned with is storage space, amount of ram used, and how much computing power your program requires. It matters because if your computer uses too many of one of these resources, it will slow down the program and any other program being used on the user's computer. This will end up with frustration from the user, and drive them away from your program.


Thought Prompt: What is the “most efficient” way to program the solution for the 3x3 grid?
I know for sure that my solution was not the most efficient, but I think that the most efficient would be a program that minimizes right turns. Right turns take up 3 commands, and cutting down on those would be the easiest way to cut down on code.


  • What surprised you about programming with such a small set of basic commands?
I was surprised there  was no right turn.

  • Were you able to be creative with such a limited set of tools?

I was not very creative, but looking back, if I started out the second program with a right turn, and made the box the opposite direction, it would create 3 left turns  and a right, instead of 4 right turns, which is 12 left turns.

  • What was most frustrating about this activity? If you could add one additional simple command, what would it be, and why?
It was frustrating not having a right turn. I would add a right turn command, because it would cut down on a lot of left turn commands needed.

  • Draw (on paper) the simplest image you can that we would be unable to create with our “building block” commands, and explain why it would be impossible to create.
One simple image would be a triangle. The program is unable to create angled lines.



  • Draw a second image we would be unable to create with the given simple commands, but for a different limiting reason than you cited in the first drawing
One other image would be a circle. The program is unable to draw curved lines.

Thursday, November 10, 2016

Sorting Algorithm Reflection

Write a human machine language program that: Repeatedly shifts the left hand to the right until it finds a 5 or 6 The program should stop when the left hand is at (or past) the end of the list, or it finds a 5, or it finds a 6.

1
Shift LH right
2
if LHCard EQ 5, jump to line 6
3
if LHCard EQ 6, jump to line 6
4
if LHPosition EQ 7, jump to line 6
5
jump to line 1
6
stop



Find min:


1
jump to line 3 if RHand LT LHand
2
shift RHand right
3
move LHand to RHand if RHand LT LHhand
4
jump to line 1 if RHPos NE 7
5
Stop

When working with your partner in class, what challenges did you face in writing your algorithm? Were you able to solve it? If yes, then How did you solve it?  

     One challenge we had to solve was when our partition algorithm got stuck in a infinite loop. It would keep going through the lower value cards with no stop point. To fix this, we made it so the cards don't go to position 0 if they were smaller than the initial card value, and instead stayed in their original position. That way, we could end the "program" when the left hand reached the card at position 0.

Make connections with our algorithms and previous coding experience we have:
What programming statements have you used in the past that you would use in writing your algorithms?  Have you written similiar programs?  If yes write the programs that you remember writing.(you are not giving me the code just making connections here and remembering what you have done)

     Some statements I would use are if, >, <, =, and while loop. I think I have written a program in the past to sort numbers.


Wednesday, November 9, 2016

Minimum Card Algorithm Reflection

  • “How do you know when to stop?”
Our instructions told them to stop when they ran out of new cards or picked up a ace of diamonds

  • “Do your instructions state where and how to start?”
Our instructions told them how to start, but not where. They could choose wherever they wanted to start.

  • “Is it clear where to put cards back down after you’ve picked them up?”
It is specified to put the cards back into their original positions.



“As we look at these algorithms you came up with, we can see they are not all the same. However, there are common things that you are all making the human machine do and commonalities in some of your instructions. Can we define a language of common Human Machine commands for moving cards around? What are the commands or actions most of these instructions have in common?”

We could define a language to move cards around. Common commands and actions would be: move, compare, if, place, pick up, and repeat.


Feedback: The feedback we got was that we had no end point. It kept telling them to pick up cards, but we never specified new cards, so they were stuck in an infinite loop.

Monday, November 7, 2016

Lego Reflection

  • Were you always able to create the intended arrangement? Were your instructions as clear as you thought?”
We were not always able to create the arrangement and our instructions weren’t as clear as we thought.
  • “Why do you think we are running into these miscommunications? Is it really the fault of your classmates or is something else going on?”
I think these miscommunications come from instructions that weren't clear enough. It wasn’t the fault of our classmates because they might have made assumptions from their experiences building their object.

  • If we were going to change human language to improve our odds of succeeding at this activity, what types of changes would we need to make?
I would make it clearer where each piece went. I think that our description of the pieces were good, but people got stuck on where to put them.

Friday, November 4, 2016

Data story reflection

The data was collected over the period of a 11 days, through an online survey that put the data into google sheets. 8 people answered this quiz almost every day for the time period of the collection. It asked questions such as, how are you feeling, how many hours you slept, how many hours you spent relaxing, how many hours you spent working, how you felt, if you were an only child or had siblings, and what you did to relax.

To create my data visualization, I used google sheets to organize and find trends in my data. With the use of pivot tables, I was able to compare data and find correlations. I then took the data that had a relationship, and put it into a new sheet and cleaned the data into a format that was more graphing friendly. Using the graphs function, I was able to more clearly show the trends in the data.

From our data, I found that hours spent working and sleeping had a relationship. In my graph, as hours spent working goes down, hours spent sleeping goes up. My explanation for this is that people who spend more time working often work late into the night, cutting into their sleep time. If they spend 10 hours working and 2 hours sleeping, there is a high chance that they stayed up all night working on something.

To the people who only slept 3-5 hours, I recommend that they go to sleep earlier, even if they still have work to do. A teacher will understand that getting sleep is essential for teenagers, and if they are staying up until 4 in the morning doing homework, they will probably let you pass on that homework. Another suggestion would be to get your homework done before relaxing. If you stay up until 3 am doing homework, when you were playing video games until 10 pm, that's something that needs to change. Getting more sleep is crucial for teenagers. Studies have shown that teenagers need at least 8 hours of sleep per night to be healthy. My recommendation is strongly supported by my data, but would need further investigation to be sure. Adding a section of asking when that person fell asleep and when they woke up would make things clearer. That way, it would show if people were going to sleep really late, or had to wake up early to go to school.


Thursday, November 3, 2016

Clean Data reflection Unit 2 Stage 13

Write in your blogs what you did to clean up the data and respond to the following prompt in your blog with the title Unit 2 Stage 13

“In order to analyze data with a computer, we need to clean the data first. Based on your experience today, would you say that data analysis is a perfectly objective process? Why or why not?”

To clean up the data, I first made sure all of the numbers were in the same format. One person did a range of numbers of 1-2 and 3-9, so I averaged them and put in 1.5 and 6. For the free form text answers, I split them up into categories such as netflix, games, music, and put a 1 there if they did it. The feeling free form text were mostly categorized, but I generalized it even more by making the categories, good, bad, and ok.

I think data analysis is not a perfectly objective process. You are the one who is deciding what category to put it in. Some people might have different ideas of what category it should go in, so it's not perfectly objective. 

Wednesday, November 2, 2016

Data visualization


  

1. The dataset I chose to visualize was the Hour Created vs Retweet Count. It compared the amount of retweets to the hour it was created.

2. The pattern found in the data implies that tweets around mid day to night (1-10 pm) get retweeted the most. This is shown by the spike in retweet numbers starting around 1 pm.

3. It can be assumed that after 1 pm is usual twitter hours for the U.S. It would make sense because that is when kids start to get out of school and they are a large chunk of the users of Twitter. Interestingly there is a spike of retweets of tweets made at 3 in the morning, but I couldn't really come up with an explanation for it.