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

Chapter 3 Worksheet

The document contains a series of Python programming exercises and functions, including defining functions, using lambda expressions, and manipulating lists. It also includes tasks such as summing numbers in a list, checking number ranges, and demonstrating the use of global variables. Additionally, it covers function arguments, swapping values, and nested functions.

Uploaded by

shanthanking2311
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)
51 views2 pages

Chapter 3 Worksheet

The document contains a series of Python programming exercises and functions, including defining functions, using lambda expressions, and manipulating lists. It also includes tasks such as summing numbers in a list, checking number ranges, and demonstrating the use of global variables. Additionally, it covers function arguments, swapping values, and nested functions.

Uploaded by

shanthanking2311
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
You are on page 1/ 2

iv.

def myFun(x): cube = lambda x: x*x*x


Class : XII Worksheet on print(cube(7))
x[0] = 20
lst = [10, 11, 12, 13, 14, 15]
Chapter-3 Functions myFun(lst);
ix. Write a Python function to sum all the
numbers in a list.
print(lst)
Find the output:
x. Write a Python function to check whether a
v. def myFun(x): number is in a given range.
i. x=5
x = [20, 30, 40]
def func2(): print(x)
global x lst = [10, 11, 12, 13, 14, 15] xi. def func(name, job='developer'):
x=3 myFun(lst); print(name,'i a', job)
x=x+1 print(lst) func('Bob', 'manager')
func('Bob')
print (x)
print (x) vi. def swap(x, y): xii. def print_arguments(**kwargs):
temp = x;
func2() print(kwargs)
x = y;
y = temp; print_arguments(name='Bob',
print(x)
x = 2 age=25, job='dev')
y = 3
ii. Remove the error and rewrite the code: swap(x, y) xiii. def increment(n):
print(x) n.append([4])
for Name in [Amar, Shivani, Pradeep] print(y) return n
if Name [0] = ‘s’: L=[1,2,3]
Print (Name) vii. def myFun(*argv): M=increment(L)
for arg in argv: print(L,M)
print (arg)
iii. Find the output of: myFun('Hello', 'Welcome', 'to', xiv. def add(x,y,z):
'Python Functions') return x+y+z
def multiply(numbers): print (“Answer=”,x+y+z)
total = 1 viii. (A lambda fn. is a small anonymous add(3,4,5)
for x in numbers: function. It can take any no. of
total *= x arguments, but can only have one xv. def outer(a, b):
expression.) def inner(c, d):
return total
print(multiply((8, 2, 3, -1, 7))) return c + d
Syntax return inner(a, b)
lambda arguments : expression result = outer(2, 4)
print(result)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy