0% found this document useful (0 votes)
15 views19 pages

Python Functions and Output Analysis

The document contains Python code examples demonstrating function definitions and variable scopes. It includes a function 'ChangeVal' that modifies a list based on specific conditions and another function 'add' that modifies a global variable. The code also illustrates the use of local and global variables with print statements to show the output at different stages.

Uploaded by

kundureeddhi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views19 pages

Python Functions and Output Analysis

The document contains Python code examples demonstrating function definitions and variable scopes. It includes a function 'ChangeVal' that modifies a list based on specific conditions and another function 'add' that modifies a global variable. The code also illustrates the use of local and global variables with print statements to show the output at different stages.

Uploaded by

kundureeddhi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Working on Functions

Class - XII
1
2
Find and write the output of the following code:
def ChangeVal(M,N):
for i in range(N):
if M[i]%5 = = 0 :
M[i]//=5
if M[i]%3==0:
M[i]//=3
L=[25,8,75,12]
ChangeVal(L,4)
for i in L :
print(i, end =‘#’)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
a=1
def f( ):
a=10
print(a)
18
c=10
def add ( ) :
global c
c=c+2
print(“Inside add”,c)
add( )
c=15
print(“In main”,c)

You might also like