Exam Questions for Chapters 1 and 2¶
The following questions test what you have learned in chapters 1 and 2. Click the “Start” button when you are ready to begin the exam. Click the “Pause” button to pause the exam (you will not be able to see the questions when the exam is paused). It will show how much time you have used, but you have unlimited time. Click on the “Finish Exam” button at the end when you are done. The number correct, number wrong, and number skipped will be displayed at the bottom of the page. Feedback for each answer will also be shown as well as your answer.
You will not be able to change your answers after you hit the “Finish Exam” button.
- dog
- The value of var3 is first set to "bird" but then changed to be the value of var1. The value of var1 is first set to "cat" but later changed to the value of var2 which was set to "dog".
- fish
- Only var2 has the value of fish. When you assign the value of a variable to the value of another variable the value is copied to the new variable. No relationship is created between the two variables.
- cat
- The value of var3 is first set to "bird" but then changed to be the value of var1. However, the value of var1 also is changed after it is originally set.
- bird
- While var3 is originally set to "bird" the value is changed later.
- variable
- A variable is a name associated with space (computer memory) that holds a value. That value can change or vary.
- turtle
- A turtle is an object that can move forward and turn. As it moves it can draw with a pen.
- string
- A string is a sequence of characters.
- program
- A program is a set of instructions that a computer can execute.
- integer
- An integer is a positive or negative whole number like -30 or 23028.
- turtle
- A turtle is an object that can move forward and turn. As it moves it can draw with a pen.
- string
- A string is a sequence of characters.
- image
- An image is a representation of a digital picture and you can get and change the color values at pixels in the image.
- 3
- That is the original value of var1. What is the value of var2?
- 2
- When var1 is assigned to have the same value as var2 the value from var2 is copied and not changed.
- 5
- That is the original value of var3. What is the value of var2?
- 0
- When one variable (var1) is set to the value of another (var2) it copies the value from the other (var2). It does't change the value in the other (var2).
- A square
- This would be true if all the forward amounts were the same.
- A rectangle that is taller than it is wide
- Zari's heading is set to 90 which turns her to point due north. So, the rectangle is taller than it is high.
- A diamond
- This would be true if all the forward amounts were the same and the heading was 45 to start.
- A rectangle that is wider than it is tall
- Turtles start off facing east and setting the heading to 90 turns it to face north.
2-5-1: What is the value of var3 after the following code executes?
var1 = "cat"
var2 = "dog"
var3 = "bird"
var1 = var2
var3 = var1
var2 = "fish"
2-5-2: A named space that can hold a value is which of the following?
2-5-3: The kind of data that can be letters, digits, and other characters inside a pair of single or double quotes is which of the following?
2-5-4: What is the value of var2 after the following code executes?
var1 = 3
var2 = 2
var3 = 5
var1 = var2
2-5-5: What shape would the following code draw?
from turtle import * # use the turtle library
space = Screen() # create a turtle screen (space)
zari = Turtle() # create a turtle named zari
zari.setheading(90)
zari.forward(100) # tell zari to move forward by 100 units
zari.right(90) # turn by 90 degrees
zari.forward(50) # tell zari to move forward by 100 units
zari.right(90) # turn by 90 degrees
zari.forward(100) # tell zari to move forward by 100 units
zari.right(90) # turn by 90 degrees
zari.forward(50) # tell zari to move forward by 100 units
zari.right(90) # turn by 90 degrees