CSC108_MidEV_2012F Solutions
Question 1 part a)
Solution
4
2
Explanation
x=3
y=x-1=2
x=4
print (x) = print (4)
print (y) = print (2)
Since ints are immutable, the value of y does not change when x = 4, the value used in y is an
address referring to 3 that
CSC108_MidAM_2013W Solutions
Question 1 part a)
Solution
43
Explanation
1.
2.
3.
4.
k=3
w=k
k=k+1
print(k, w)
1. <k> is assigned to an int, 3.
2. <w> is assigned to the value of <k>, which is 3 (remember ints are immutable)
3. <k> is incremented by 1, now
CSC 108 2011S MIDTERM SOLUTIONS
Question 1)
Solution
1. 20
2.
3.
4.
5.
I like trees
1
[4, 5, 6]
[7, 8, 9, 4]
Explanation
1.
number = 10
number = func1(number)
print number 20
We can see that the variable <number> is initialized to 10, afterwhich it is mad
CSC108_MidPM_2013F Solutions
Question 1)
Solution
1.
2.
3.
4.
5.
6.
[ball, car, doll]
[ball, car]
o
Dec
False
[Dec, 6]
Explanation
1.
1.
2.
3.
4.
1. <toys> is a list of strings
2. <stuff> is equal to a new list that is the slice of <toys> from 0:2
3. <stu
CSC108_MidAM_2012F Solutions
Question 1 part a)
Solution
79
Explanation
x=4
y=x+5=9
x=7
print (x, y) = print (7 9)
Since ints are immutable, the value of y does not change when x = 7, the value used in y is an
address referring to 4 that is not the same a
CSC108_MidPM_2012F Solutions
Question 1 part a)
Solution
42
Explanation
x=3
y=x-1=2
x=4
print (x, y) = print (4 2)
Since ints are immutable, the value of y does not change when x = 4, the value used in y is an
address referring to 3 that is not the same a
CSC108_MidEV_2013W Solutions
Question 1 part a)
Solution
5.6 5.5
Explanation
1.
2.
3.
4.
x = 5.5
y=x
x = x + 0.1
print(x, y)
1. <x> is assigned to an int, 5.5.
2. <y> is assigned to the value of <x>, which is 5.5 (remember floats are immutable)
3. <x> is
#
Include Crazy Toys
def can_post_cs(one, two, three, four, five, six, seven, eight, nine, ten):
'(string, string, string, string, string, string, string, string, string, string) ->
bool
Given ten courses (one, two. ten), returns if the student is able to