Code Yourself! An Introduction to Programming Quiz Answers

Get Code Yourself! An Introduction to Programming Quiz Answers

Have you ever wished you knew how to program, but had no idea where to start from? This course will teach you how to program in Scratch, an easy to use visual programming language. More importantly, it will introduce you to the fundamental principles of computing and it will help you think like a software engineer.

Enroll on Coursera

Code Yourself! An Introduction to Programming Week 01 Quiz Answers

Quiz 1

Q1. Which of the following is an algorithm?

  • Is it raining?
  • Shopping List:
  • milk
  • bread
  • sugar
  • How to make a cup of tea:

Put a teabag in a cup

If you don’t have any hot water

boil some

Pour the hot water into the cup

Wait for 3 minutes

Remove the teabag from the cup

  • Tidy your room!

Q2. Which programming construct can you identify in this algorithm for making breakfast?

Take a clean bowl

Pour 125ml of milk in the bowl

Add 30gr of cereal in the bowl

Take a clean spoon

Stir the milk and cereal

  • Sequence
  • Selection
  • Iteration
  • None of the above

Q3. Please use a pen and paper and follow the algorithm below. Which letter will be drawn?

Position the pen at the top right part of the page

Draw a horizontal line

From the middle point of this line draw a vertical line downwards, until it reaches the bottom part of the page

  • C
  • T
  • I
  • L

Q4. The following algorithm:

turn the tap on
wet your hands
apply some soap on your hands
lather and scrub your hands
rinse your hands
turn the tap off
dry your hands

describes the process for:

  • washing clothes
  • washing your hands
  • washing the car
  • cleaning the kitchen

Q5. We have created a new project in Scratch and we have defined the following program for the cat:

We have chosen the following rotation style for the cat:

What happens when we execute this program?

  • The cat keeps moving and every time it bounces its image turns upside down.
  • The cat keeps moving and every time it bounces it flips to the other direction, so if it was initially facing right it will then face left.
  • The cat keeps moving and every time it bounces its image stays the same.
  • The cat stands still.

Q6. The following flowchart depicts an algorithm for leaving your house on a winter’s day. Which of the following are not valid execution paths?

  • Take the keys, exit the flat.
  • Take the keys, put a scarf on, exit the flat.
  • Take the keys, take an umbrella, put a scarf on, exit the flat.
  • All the above options are valid execution paths.

Q7. We want to create a program where the cat keeps moving all the time and bounces whenever it touches the edge of the screen. If at any point the cat touches something green, the cat should change colour. Which of the following scripts captures this?\

  • .
  • .
  • .
  • correct Answers

Q8. In a new project, we have created the following program for the cat:

When we run this program, the cat first points to the right and it is located at -200, 0. What happens next?

  • It will keep moving to the left, and whenever it touches the edge, it will be repositioned at -200,0.
  • It will move 10 steps to the right, and if it is touching the edge, it will disappear from the screen.
  • It will keep moving to the right, and whenever it touches the edge, it will be repositioned at -200,0.
  • It will keep moving to the right, and whenever it touches the edge, it will be repositioned at the centre of the stage.

Q9. Let’s suppose that in the project for “Sunny Day” the stage background looked like this, so the sun is located on the right:

The program for the cloud in the original “Sunny Day” project (where the sun was located on the left) is the following:

We want to modify the original program so that the cloud is initially placed on the right and every time we blow, it moves to the left. To do this, we need to:

  • set the block “point in direction” to -90
  • set the coordinates in the “go to” block to x: 200, y: 105, and set the block “point in direction” to -90
  • within the condition, increase the value of the sound intensity, e.g. 100
  • set the coordinates in the “go to” block to x: 200, y: 105

Q10. We have created an animation with two characters, Tim and Lucy. Tim’s code is:

Lucy’s code is:

According to this program, will Tim and Lucy have a normal dialogue when we click the green flag?

  • Yes, Tim and Lucy will have a normal dialogue.
  • No, Tim and Lucy will talk at the same time.
  • No, Lucy talks first, saying all her lines, and then Tim talks, saying all his lines.
  • No, Tim talks first, saying all his lines, and then Lucy talks, saying all her lines.

Code Yourself! An Introduction to Programming Week 02 Quiz Answers

Quiz 2

Q1. How many meters does Cody walk in total according to this algorithm?

walk 100m
repeat 3 times
   walk 100m
   jump 5 times
  • 400
  • 415
  • 205
  • 300

Q3. We are preparing a cup of tea for Mary by following the algorithm depicted in the flowchart below. What is the minimum number of teaspoons of sugar to add?

Note that we have not given you any information about Mary’s sugar preferences. You are expected to to think about the minimum number of teaspoons Mary would like in her tea.

  • 1
  • 0, in other words Mary likes her tea without sugar
  • many!
  • 2

Q3. Which of the following statements is correct about these three programs?

Program 1:

Program 2:

Program 3:

  • The three programs are equivalent, in other words they reproduce the same melody.
  • The three programs play different melodies.
  • Program 1 and Program 2 reproduce the same melody.
  • Program 2 and Program 3 reproduce the same melody.

Q4.

We have created the following program

.

What does this program draw?

  • .Correct Answers
  • .
  • .
  • .

Q5. In Scratch we can set the video transparency to values between 0 and 100. We have used the “set video transparency to” block in a program that makes the cat dance, and we have obtained a rather transparent background, like the one shown in the following picture:

It is likely that we have set the video transparency in this program to:

  • a low positive value, such as 10
  • a high value, such as 80
  • a negative value, such as -100
  • 0

Q6. When designing our interface, we should think about:

  • how the user will interact with the program
  • how easy it is for a new user to use our program
  • what the different program elements should look like
  • all of the above

Q7. Are these two programs equivalent?

  • Yes
  • No

Q8. We are designing a car racing game. Which of the following could be requirements for this game?

  • The game should include several car models.
  • The time of the race should be visible on the screen.
  • It should be possible to change the car speed during the game.
  • All the above options are possible requirements.

Q9. When designing a car racing game, we decided to represent the car in a simplified form (i.e. as a red rectangle with 4 black circles for the wheels) and to enable its driving with the use of the arrow keys. Surely, the actual car shapes and the process of driving a car are far more complex. Thus, when designing this game, we are applying the concept of

  • abstraction
  • iteration
  • divide and conquer
  • requirements engineering

Q10. Michael is creating a new game. He wants to move a dinosaur with the arrow keys. More particularly, he wants the dinosaur to move 5 steps to the right when the right arrow key is pressed, and 5 steps to the left when the left arrow key is pressed. He has created the following program, he tested it, but it does not seem work as intended:

One way to fix it would be to replace Michael’s code with:

  • .Correct Answers
  • .
  • .
  • .

Code Yourself! An Introduction to Programming Week 03 Quiz Answers

Quiz 3

Q1. “A space in the computer’s memory where we can hold information used by our program” would be a definition of:

  • any Scratch block
  • selection
  • program
  • variable

Q2. The use of comments in a program:

  • is recommended, as it helps the program run faster and without errors.
  • is recommended, as it could help programmers understand the program more easily.
  • is mandatory.
  • is part of “user documentation”.

Q3.

The following code:

  • checks whether the user’s answer is YES or NO.
  • ensures that we do not continue with the any code following it until the user has indicated “YES” or “NO”.
  • is an example of verifying data entered by the user.
  • All the above are correct.

Q4. We have created a program in which an octopus keeps moving across the screen and whenever it touches the starfish, it says “Hiya!”. Here is the code for the octopus:

We now want to modify this program so that the route followed by the octopus is visible on the screen. To achieve this, we could change the current code as follows:

  • Introduce a “pen down” block right after the “clear” block (before the “forever” block).
  • Introduce a “pen up” block right after the “clear” block (before the “forever” block).
  • Introduce a “pen down” block inside the “if” block, right after the “say” block.
  • We cannot achieve this behaviour.

Q5. We have created a simple basketball game in Scratch, and we have defined the variable “points” to represent the number of points a player has scored. We want to increase the player’s points by 3, every time he/she makes a field goal beyond the three-point line. Which of the following instructions should we use to capture this increase?

  • change points by 3
  • set points to 3
  • change points by 2
  • We cannot increase the variable’s value by 3, it is always by 1.

Q6. We want to enrich a penalty shootout game as follows: When pressing the up arrow key it should announce whether we have scored many goals (if more than 5 goals), some (if 1, 2, 3, 4 or 5 goals) or none (if 0 goals). One way to program this would be:

  • .
  • .correct Answers
  • .
  • .

Q7. In the game “Guess the number” we have defined the variable “secret number”, which corresponds to the number the player needs to guess, and we have set its value with the use of the following block:

We want to modify the game, so that instead of having to guess a random number between 1 and 10, it should be a random number between 1 and a value indicated by the player. One way to program this is by replacing the previous block with:

  • .correct Answers
  • .
  • .
  • .

Q8. Rebecca has modified the program for the game “Guess the Number”, so it looks like this:

Which of the following statements does not hold for Rebecca’s version of the game?

  • The secret number does not have a randomly generated value, it is always 5.
  • If at the beginning the player enters a number different to 5, the program says “Not really…try again!”, and then the player can enter a new number.
  • The program will keep saying “Not really…try again!” until the user answer equals the secret number.
  • If at the beginning the player enters the number 5, the program says “Brilliant!” and it ends.

Q9. Here is the program that we have created for the “Flower Garden” animation:

We have modified the interface of the program to have two costumes for the flower: a purple and a blue one.

We now want to modify our code so that each row will have flowers of the same colour, with the colours alternating by row, for example as shown in this picture:

To achieve this, we need to introduce a “next costume” block:

  • inside the first “repeat” block, right before the second “repeat” block.
  • right after the “show” block and before the first “repeat” block.
  • inside the second “repeat” block, right before the block “change x by 40″.
  • We cannot achieve this effect.

Q10. We have modified our penalty shootout game so that when pressing the up arrow key, it announces whether we have scored many goals (if more than 5 goals), some (if 1, 2, 3, 4 or 5 goals) or none (if 0 goals). We now want to test our modified program. Out of the following options, which cases would it be best to choose to test this modification?

  • One case: where 2 goals have been scored.
  • Three cases: where 0 goals have been scored, 4 goals have been scored and 7 goals have been scored.
  • Two cases: where 2 goals have been scored and 6 goals have been scored.
  • Three cases: where 2 goals have been scored, 3 goals have been scored and 4 goals have been scored.

Code Yourself! An Introduction to Programming Week 04 Quiz Answers

Quiz 4

Q1. We have created the following program for a balloon. The block “say y position” involves saying the value of the y-coordinate of the character at the current point of execution.

What will the balloon say when we run this program?

  • 40
  • 0
  • 10
  • 4

Q2. In the game for “Catch the mouse”, we assume that the cat is always located at x = -18, y = 0 at the beginning of the program execution. In this game, we have defined a “jump” procedure as follows:

Anna and Bob have implemented this procedure in a different way, as shown in the following examples:

Example A:

Example B:

Which of the following statements is not correct?

  • Example A involves moving 100 steps upwards and then 100 steps downwards.
  • Example B involves gliding first to position -18,100 and then to position -18, 0.
  • The 3 examples are relatively similar, in that in all of them the cat moves 100 steps up and then 100 steps down.
  • Example A does not implement the “jump” procedure correctly, as it involves moving 100 steps downwards and then 100 steps upwards.

Q3. What does the following program draw?

  • .
  • .
  • .correct Answers
  • .

Q4. John has built the following program for drawing a triangle, the sides of which should have a user-specified length.

He has tested his program, but it seems to always draw a triangle, the sides of which have length 100 steps. Can you identify the bug in his code?

  • There is no bug in John’s code. It always draws a triangle, the sides of which have length as indicated by the user, such as 30 or 60.
  • Instead of “repeat 3” it should be “repeat side_length “.
  • Instead of “move 100 steps” it should be “move side_length steps”.
  • Instead of “turn 120 degrees”, it should be “turn 60 degrees”.

Q5. We have created the following program for drawing a staircase that has a user-specified number of stairs:

To complete this program, we need to specify a “drawStaircase” block that has the number of stairs to be drawn as a parameter, and which uses the “drawStair” block. Which of the following block definitions captures this?

  • .
  • .
  • .correct Answers
  • .

Q6. In Scratch there are several blocks related to cloning. In particular, if we want to specify the behaviour a clone will have when it is created, we should use the block:

  • “when I start as a clone”
  • “create clone of myself”
  • “delete this clone”
  • None of the above. We cannot specify the behaviour of clones.

Q7. Modularity is the extent to which a program is separated into different components, which are dedicated to a particular functionality. We have created two equivalent programs for drawing a hexagon. Which of these can be characterised as modular?

  • .
  • .

Q8. We want to create a program with several tigers. In which of the following cases would you recommend not to use clones in our program?

  • We want to have a variable number of tigers, where the user can specify the number of tigers at the beginning of the program execution. Each tiger will roar when touching the mouse-pointer.
  • We want to have 2 tigers. The first tiger will roar when touching the mouse-pointer, while the second will roar when the spacebar is pressed.
  • We want to have 50 tigers, each of which will roar when touching the mouse-pointer.
  • We want to have a random number of tigers, each of which will roar when touching the mouse-pointer.

Q9. In the animation of the “Wave” we have specified the following code for populating the stands:

In addition to this code, we have defined the behaviour of each spectator with the use of the “when I start as a clone” block, and we have also defined their costumes.

Would it have been the same, if instead of “create clone of myself” we had used the “stamp” block?

  • No, the populated stands would look similar, but they would not have the same behaviour. The “stamp” block creates a fixed image of the sprite at the time of stamping, and the stamped sprite has no behaviour.
  • Yes, it would have been exactly the same.
  • Yes, but it runs faster if we use “create clone of myself” instead of “stamp”.
  • No, if the “stamp” block is used we cannot use the block “create clone of myself”.

Q10. We have created a program for drawing squares. We now want to modify it so that it draws rectangles. Our rectangle-drawing program is a(n) __________ of our square-drawing program.

  • selection
  • iteration
  • generalisation
  • parameter

Code Yourself! An Introduction to Programming Week 05 Quiz Answers

Quiz 5

Q1. When creating a new game, it would be good to follow the different software development phases in the following order:

  • Requirements, Design, Implementation, Testing
  • Design, Implementation, Testing
  • Design, Requirements, Implementation, Testing
  • Requirements, Design, Testing, Implementation

Q2. Concurrent processes:

  • run one after the other
  • run simultaneously
  • cannot be implemented in Scratch
  • take a long time to execute

Q3. We want to create our version of the “Flappy Bird” game, where the player makes a bird fly between rows of pipes without touching them. If the bird touches a pipe, the game ends.

The pipes appear every 5 seconds. Each pipe appears at the right edge of the screen and it slides towards the left. When it reaches the left edge of the screen, it disappears.

We have successfully built the code for the bird, and we have the following code for the pipe:

How should we complete this code for the pipe? Note that the block “y position” reports the y position of the sprite.

  • We should introduce a “create clone of myself” block inside the forever block, and we should also introduce a “delete this clone” block right after the “glide” block.
  • We should introduce a “create clone of myself” block inside the forever block.
  • We should introduce a “delete this clone” block right after the “glide” block.
  • There is no need to introduce new blocks in this code.

Q4. We want to create a program for a dinosaur, where it keeps moving (and bouncing if on edge) without ever stopping. Three seconds after the program starts execution, the dinosaur should say “It’s time to get bigger!” and then it should get bigger. Which of the following programs implements this behaviour?

  • .correct Answers
  • .
  • .
  • It is not possible to implement this behaviour.

Q5. There is only one approach to developing software: the incremental approach.

  • False
  • True

Q6. We’ve created a new project with 2 characters: a cat and a dog. This is the program for the cat:

We want to create a program for the dog so that it says “So there you are!” once the cat becomes visible on the screen. Which of the following scripts achieves this?

  • .
  • .correct Answers
  • .
  • .

Q7. We have specified the following condition:

This condition is true when:

  • the score variable has a value greater than 10, and the object is not touching the edge.
  • the score variable has a value greater than or equal to 10, and the object is not touching the edge.
  • the score variable has a value greater than 10 or the object is not touching the edge.
  • the score variable has a value greater than 10 and the object is touching the edge.

Q8. In the zombie game, if we wanted to have another costume for the Hero sprite that makes zombies go away (in addition to those for the broom and Cody), we could do the following:

  • We could introduce a new sprite with a similar behaviour to that of the broom or Cody.
  • We cannot have another costume for the Hero, just those for the broom and Cody.
  • We could remove the costume for the broom and add the new costume.
  • We could add another costume for the Hero sprite and we could extend the program for the Hero so that the user can choose this costume.

Q9. We have created a program where we have a wizard and a knight. The wizard’s code looks like this:

while the knight’s code looks like this:

When will the knight turn into a frog?

  • Whenever the wizard passes by the centre of the stage.
  • As soon as the program starts execution.
  • Once there is a loud sound.
  • The first time that the wizard is located at the centre of the stage.

Q10. You have created a game in Scratch that is similar to Pacman. By sharing your project on the Scratch website, you allow other people to:

  • play the game that you’ve created
  • look inside the code of your project
  • remix your project
  • all of the above
Code Yourself! An Introduction to Programming Course Review:

In our experience, we suggest you enroll in Code Yourself! An Introduction to Programming courses and gain some new skills from Professionals completely free and we assure you will be worth it.

Code Yourself! An Introduction to Programming course is available on Coursera for free, if you are stuck anywhere between a quiz or a graded assessment quiz, just visit Networking Funda to get Code Yourself! An Introduction to Programming Quiz Answers.

Conclusion:

I hope this Code Yourself! An Introduction to Programming Quiz Answers would be useful for you to learn something new from this Course. If it helped you then don’t forget to bookmark our site for more Quiz Answers.

This course is intended for audiences of all experiences who are interested in learning about new skills in a business context; there are no prerequisite courses.

Keep Learning!

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!