Scratch Lab 6

Name: Shreya Raj

Period: 7

Assignment: Lab #6

Lab 6 Overview

This weeks lab was all about conditionals. To learn and understand how to use conditionals we had to do a pair programming problem and two individual lab problems. But before we actually started coding, we got to further understand the if-then conditional statements by learning truth tables. After learning how truth tables work, doing the problems made doing lab problems a lot easier. Click HERE to get to the lab instructions.

My Solution Problem Number 1

This problem asked you to pick a sprite and make it move up, down, left and right. As the sprite moves, lines should be drawn as the sprite moves across the screen. We also needed to make it that, when you click the spacebar the screen "refreshes" and all the lines disappear. To solve this problem, I used 5 different conditoinal statements. Within the "if-then" statements, I used a sensing operator to establish what the program should do if a certain button is clicked. Then within the conditionals, I put in the different commands accordind to the button. So for example if the down arrow pressed, then change y by -3.

My Project Link

My Solution Problem Number 3

This problem required a sprite to take a word as an input and then spell the word back to the user one letter at a time. But if the word is longer than 10 letters, then the sprite should ask for another word from the user. My solution to this problem involved 3 variables, two of which I created. I used the given "answer" variable and created the two variables "letter" and "word". Then I set the letter variable to -1 and the word to answer. I then added an if, then, else, conditional. Inside the condtional I used the answer and the letter variable to have the word spelled back to the user.

My Project Link

Questions

  1. What is the difference between and if and and if-else statement?
      The if statement gives an oppurtunity for only one outcome. The if-else statement gives an oppurtunity to be able to execute two different outcomes.
  2. Is there a simpler way to write the following code? Explain.
      There is a simpler way to write the code. Instead of using the if-else condtional statement you can just use an if statement. Within the if statement, you would just say the first part of the code where if mousex=0 then say "My mouse is at 0". And after that condtional you would just put move 10 steps because that would be on all the other situations.
  3. Which students are described by the following conditional? “if you are not a Senior and you are on the soccer team or you are in band then…”
      Someone who is in the band or someone who is a freshmen, sophomore, or junior on the soccer team.
  4. If the statement from Question 3 is changed as shown below, who else is included in the condition? “if you are not a Senior OR you are on the soccer team or you are in band then…”
      If you are a non-senior, or you are on the soccer team, or you are in the band. So it basically involves everyone that is not a senior.
  5. Write the condition for a number being a multiple of 15. (hint: look at the block).
      By using a mod block it would show the remainder of the division when it is divided by something. So you would put a operator mod of 15 into a condtional know the multiples of 15.
  6. Click HERE to return to homepage.