Name: Shreya Raj
Period: 7
Assignment: Lab #6
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.
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.
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.