Difference between revisions of "CSC111 Exercises with Global Variables"
(Created page with "--~~~~ ---- =Exercises= <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> [[category...") |
|||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 15:57, 24 April 2014 (EDT) | --[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 15:57, 24 April 2014 (EDT) | ||
---- | ---- | ||
− | = | + | <br /> |
+ | Predict the output of the following programs, of if they crash, indicate why. | ||
+ | <br /> | ||
+ | ==Exercise1== | ||
+ | <br /> | ||
+ | <source lang="python"> | ||
+ | A = 3 | ||
+ | |||
+ | def f1( x ): | ||
+ | print( "f1", x, A ) | ||
+ | print( "A = ", A ) | ||
+ | f1( 30 ) | ||
+ | |||
+ | </source> | ||
<br /> | <br /> | ||
+ | ==Exercise2== | ||
<br /> | <br /> | ||
+ | <source lang="python"> | ||
+ | |||
+ | def f1( x ): | ||
+ | print( "f1", x, A ) | ||
+ | |||
+ | f1( 30 ) | ||
+ | print( "A = ", A ) | ||
+ | |||
+ | </source> | ||
+ | |||
+ | <br /> | ||
+ | |||
<br /> | <br /> | ||
<br /> | <br /> |
Revision as of 15:38, 24 April 2014
--D. Thiebaut (talk) 15:57, 24 April 2014 (EDT)
Predict the output of the following programs, of if they crash, indicate why.
Exercise1
A = 3
def f1( x ):
print( "f1", x, A )
print( "A = ", A )
f1( 30 )
Exercise2
def f1( x ):
print( "f1", x, A )
f1( 30 )
print( "A = ", A )