3.1 +Variables+&+Assignments
3.1 +Variables+&+Assignments
a) 3 –4 6
b) –1 –4 6
c) 5 4 –1
d) –4 6 9
Model Answer(1)
a) 3 –4 6
b) –1 –4 6
c) 5 4 –1
d) –4 6 9
Question(2)
A) 0 12 0
B) Error; a cannot be added to a.
C ) 6 12 0
D) 0 12 5
Model Answer(3)
A) 0 12 0
B) Error; a cannot be added to a.
C ) 6 12 0
D) 0 12 5
Question(4)
a) 20
b) 15
c) 10
d) 4
Model Answer(4)
a) 20
b) 15
c) 10
d) 4
Question(5)
Which of the following code segments would swap the values of a and b?
Which of the following code segments would swap the values of a and b?
a) True True
b) False True
c) False False
d) True False
Model Answer(6)
a) True True
b) False True
c) False False
d) True False
Reflection
Q1.Now that you've learned about variables and assignments, how do you think they help in creating a
program? Can you describe a simple example where using a variable made solving a problem easier or more
organized?