0% found this document useful (0 votes)
3 views3 pages

F025 PF Exp8.1

The document contains several Python code snippets demonstrating different functionalities such as using reduce to calculate the product of a list, generating multiplication tables, and applying lambda functions for addition and multiplication. It also includes functions for generating Fibonacci numbers and filtering even numbers from a list. Overall, the code illustrates basic programming concepts and operations in Python.

Uploaded by

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

F025 PF Exp8.1

The document contains several Python code snippets demonstrating different functionalities such as using reduce to calculate the product of a list, generating multiplication tables, and applying lambda functions for addition and multiplication. It also includes functions for generating Fibonacci numbers and filtering even numbers from a list. Overall, the code illustrates basic programming concepts and operations in Python.

Uploaded by

gigganegga6969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Jash Pancholi, F025

1.

from functools import reduce

l = [5, 4, 5]

sum = reduce((lambda x, y: x * y), l)

print (sum)

2.

def func(n):

for i in range(1,11):

print(f"{n} x {i} = {n*i}")

n=int(input())

func(n)

3.

add=lambda x: x + 26

mult=lambda x,y: x*y

x=int(input("enter x, x will be added to 26: "))

y=int(input("enter y, x,y will be multiplied: "))

print(f"x + 26 = {add(x)}")

print(f"x * y = {mult(x,y)}")
Jash Pancholi, F025

4.

def fib():

a,b=0,1

f=[]

for i in range(1,11):

f.append(a)

a,b=b,a+b

return f

l=[]

l=fib()

print(l)

l1=map(lambda x:x*x,l)

print(list(l1))

5.

l=[1,2,3,4,5,6,7]

l1=map(lambda x:x*x*x,l)

print(list(l1))
Jash Pancholi, F025

6.

l = [1,2,3,4,5,6,7,8,9]

final_list = filter(lambda x: ( x % 2 == 0) , l)

print(list(final_list))

7.

l=[1,2,3,4,5,6,7]

l1=map(lambda x:x*x*x,l)

final_list=filter(lambda x:(x%2==0),l1)

print(list(final_list))

You might also like