Question: ( read StanfordCSFunctions.pdf ) Compare these two functions ( saved as e . g . hw 2 . py ) : def f 1 (

(read StanfordCSFunctions.pdf)
Compare these two functions (saved as e.g. hw2.py):
def f1(x):
print x +1
def f2(x):
return x +1
1.1 Run hw2.py in the shell. What happens when we call these functions?
>>> f1(3)
>>> f2(3)
It looks like they behave in exactly the same way. But they really dont. Try this:
>>> print (f1(3))
>>> f2(3)
Explain the difference.
1.2 Finally, we can see the difference here:
>>> f1(3)+1
>>> f2(3)+1
Explain the difference.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!