Back to questions
JuniorTheoryCommon
What does the program print?
def double(x):
return x * 2
print(double(double(3)) + 1)13
- Expecting
7, as if the outerdoublewere skipped: the inner call returns6, the outer call doubles it to12, and only then+ 1gives13. - Expecting
14, as if+ 1ran before the outerdouble:+ 1stands outside both calls, so it is added to the finished result12.
- What does
print(double(3 + 1))print, and why? - What would the program print if
doublehad noreturnline?