0% found this document useful (0 votes)
4 views20 pages

Complete Recursion

The document contains code snippets demonstrating the use of recursion, global and nonlocal variables, and variable packing in Python. It includes examples of functions that manipulate variables and print outputs based on different parameter types. The document appears to be a tutorial or instructional material on these programming concepts.

Uploaded by

Katti Arul
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)
4 views20 pages

Complete Recursion

The document contains code snippets demonstrating the use of recursion, global and nonlocal variables, and variable packing in Python. It includes examples of functions that manipulate variables and print outputs based on different parameter types. The document appears to be a tutorial or instructional material on these programming concepts.

Uploaded by

Katti Arul
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

Recursion

06 March 2025 16:18

New Section 6 Page 1


New Section 6 Page 2
New Section 6 Page 3
New Section 6 Page 4
New Section 6 Page 5
New Section 6 Page 6
New Section 6 Page 7
a=10
b=20
print(a-b)
def sam():
global a
a=600
print(a,b)
print(a+b)
sam()
print(a,b)
print(a*b)

a=10
b=20
print(a-b)
def sam():
global c
c=600
print(a,b)
print(a+b)
print(c)
sam()
print(a,b)
print(a*b)
print(c)

New Section 6 Page 8


a,b=10,20
print(a,b)
def outer():
m=1000
n=2000
print(a,b,m,n)
def inner():
nonlocal m
m=55
print(m,n,a,b)
inner()
print(m,n)
outer()

New Section 6 Page 9


New Section 6 Page 10
def sam(*v):
print(v)
sam(10,20,30,40,250)

New Section 6 Page 11


def sam(**v):
print(v)
sam(a=10,b=20,c=30,d=40,e=250)

New Section 6 Page 12


def pack(*a,**b):
print(a,b)
pack(10,20,30,b=500,c=600)

def pack(*args,**kwargs):
print(args,kwargs)
pack(10,20,30,b=500,c=600)

New Section 6 Page 13


New Section 6 Page 14
New Section 6 Page 15
New Section 6 Page 16
New Section 6 Page 17
New Section 6 Page 18
New Section 6 Page 19
7

New Section 6 Page 20

You might also like