Links
Welcome to CS 61A! Although we didn’t go over any material in discussion today, I recommend trying to work through the problems below, using lecture and the textbooks as references, to prepare for next week.
Concepts
- (values, expressions)
_________evaluate to___________. - What is a name? Can one object have many names? Can one name refererence many objects?
- What is the difference between a function and a function call?
Problems
Question 1
>>> a = 3
>>> b = a
>>> c = "a"What is a + b? What is data type of the value stored in c?
a + bis6. The value3gets assigned tobin the second statement. The value stored incis"a"which is a string.
Question 2
The following code is entered into the Python interpreter.
>>> x = 30
>>> def foo(x):
x = 50
return x + 50 If I call the function foo with argument x, what would the return value be?
The value30is passed in as an argument and is bound tox. Inside of the function body,xassigned to the number 50 in the local frame. Variables in the local frame have priority over variables in the global frame, so the value that is returned is100.