0% found this document useful (0 votes)
15 views

Lambda Exercise - I

The document contains 13 questions asking to write Python programs using lambda functions to perform tasks like adding a number, sorting a list of tuples, filtering lists, applying math operations on list elements, finding intersections and palindromes.

Uploaded by

shubhamcollege11
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 views

Lambda Exercise - I

The document contains 13 questions asking to write Python programs using lambda functions to perform tasks like adding a number, sorting a list of tuples, filtering lists, applying math operations on list elements, finding intersections and palindromes.

Uploaded by

shubhamcollege11
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

Q.

1) Write a Python program to create a lambda function that adds 15 to a given number passed in as an
argument.

Q.2) Write a Python program to sort a list of tuples using Lambda.


Original list of tuples:
[('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]

Sorting the List of Tuples:


[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]

Q.3) Write a Python program to filter a list of integers using Lambda.


Original list of integers:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Even numbers from the said list:


[2, 4, 6, 8, 10]
Odd numbers from the said list:
[1, 3, 5, 7, 9]

Q.4) Write a Python program to square and cube every number in a given list of integers using Lambda.
Original list of integers:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Square every number of the said list:
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
Cube every number of the said list:
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]

Q.5) Write a Python program to extract year, month, date from given date, using Lambda.
Sample Output:
2020-01-15
2020
1
15

Q.6) Write a Python program to create Fibonacci series up to n using Lambda.


Fibonacci series upto 2:
[0, 1]
Fibonacci series upto 5:
[0, 1, 1, 2, 3]
Fibonacci series upto 6:
[0, 1, 1, 2, 3, 5]
Fibonacci series upto 9:
[0, 1, 1, 2, 3, 5, 8, 13, 21]

Q.7) Write a Python program to find the intersection of two given arrays using Lambda.
Original arrays:
[1, 2, 3, 5, 7, 8, 9, 10]
[1, 2, 4, 8, 9]
Intersection of the said arrays: [1, 2, 8, 9]
Q.8) Write a Python program to count the even and odd numbers in a given array of integers using Lambda.
Original arrays:
[1, 2, 3, 5, 7, 8, 9, 10]
Number of even numbers in the above array: 3
Number of odd numbers in the above array: 5

Q.9) Write a Python program to rearrange positive and negative numbers in a given array using Lambda.
Original arrays:
[-1, 2, -3, 5, 7, 8, 9, -10]
Rearrange positive and negative numbers of the said array:
[2, 5, 7, 8, 9, -10, -3, -1]

Q.10) Write a Python program to filter a given list to determine if the values in the list have a length of 6 using
Lambda.
Sample Input: [“ABHAY“, “AMIT“,“MONDAY“,“THURSDAY“,“SAM“,“VISHWAMBHAR“,“JOSHI“,“KULDEEP“]

Sample Output:
MONDAY
THURSDAY
VISHWAMBHAR
KULDEEP

Q.11) Write a Python program to add two given lists using map and lambda.
Original list:
[1, 2, 3]
[4, 5, 6]
Result: after adding two list
[5, 7, 9]

Q.12) Write a Python program to find numbers divisible by nineteen or thirteen from a list of numbers using
Lambda.
Orginal list:
[19, 65, 57, 39, 152, 639, 121, 44, 90, 190]

Numbers of the above list divisible by nineteen or thirteen are:


[19, 65, 57, 39, 152, 190]

Q.13) Write a Python program to find palindromes in a given list of strings using Lambda.
Orginal list of strings:
['php', 'w3r', 'Python', 'abcd', 'Java', 'aaa']
List of palindromes:
['php', 'aaa']

You might also like