- #1
hnnhcmmngs
- 19
- 0
Homework Statement
Question 1:
Python:
def convert(degrees):
degrees += 273.15
return degrees
degrees = 10
print(convert(degrees))
Which of these statements are true after the code executes? (There may be more than 1 correct answer)
a) The value of degrees in the main namespace is 283.15
b) Two variables called degrees have been created
c) The value of degrees in the function namespace is 10
d) This code generates an error because you cannot use the same variable name twice.
Question 2:
Python:
def convert():
print('After conversion, there are', degrees + 273.15, 'degrees')
degrees = 10
print(convert())
Which of these statements are true after the code executes? (There may be more than 1 correct answer)
a) The return value of the function is 283.15
b) This code generates an error.
c) A line of output is printed from inside the function.
d) Two variables called degrees have been created
e) The value of degrees in the main namespace is 283.15
Homework Equations
[/B]
N/A
The Attempt at a Solution
[/B]
For Question 1, I think b) is one of the correct solutions and I know that d) can't be right because I ran the program and it didn't generate an error.
For Question 2, a) should be one of the correct answers and b) can't be right because the code doesn't generate an error.
Last edited by a moderator: