0% found this document useful (0 votes)
8 views2 pages

CBSE Class 12 Python Functions Guide

The document provides Python programming exercises related to functions and scope for CBSE Class 12 students. It includes tasks to identify and correct errors in a given program, fill in blanks in a function, and predict outputs of various function calls. The exercises emphasize understanding of variable scope, default parameters, and function behavior.
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)
8 views2 pages

CBSE Class 12 Python Functions Guide

The document provides Python programming exercises related to functions and scope for CBSE Class 12 students. It includes tasks to identify and correct errors in a given program, fill in blanks in a function, and predict outputs of various function calls. The exercises emphasize understanding of variable scope, default parameters, and function behavior.
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

CBSE Class 12 - Python (Functions & Scope)

Q2. Rewrite the program after finding the error(s):

def exceMain():

x = int(input("Enter a number:"))

if abs(x) == x:

print("You entered a positive number")

else:

x *= -1

print("Number made positive:", x)

exceMain()

Q3. Fill in the blanks and output:

def fun(x, y): # Statement-1

global a # Statement-2

x, y = y, x # Statement-3

print(a, b, x, y) # Statement-4

a, b, x, y = 1, 2, 3, 4

return [50, 100] # Statement-5

a = 10

b = 20

x = 30

c = 30

fun(1, 2)

print(a, b, x, y) # Statement-6

# Statement-4 Output: 10 20 2 1

Q4. Output of the following code:


CBSE Class 12 - Python (Functions & Scope)

def func(a, b=5, c=10):

print('a is', a, 'b is', b, 'and c is', c)

func(3, 7)

# Output: a is 3 b is 7 and c is 10

func(25, c=24)

# Output: a is 25 b is 5 and c is 24

func(c=50, a=100)

# Output: a is 100 b is 5 and c is 50

You might also like