Python: Create a lambda function that adds 15 to a given number passed in as an argument
Python Lambda: Exercise-1 with Solution
Write a Python program to create a lambda function that adds 15 to a given number passed in as an argument, also create a lambda function that multiplies argument x with argument y and print the result.
Sample Solution:
Python Code :
r = lambda a : a + 15
print(r(10))
r = lambda x, y : x * y
print(r(12, 4))
Sample Output:
25 48
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Python Lambda Home.
Next: Write a Python program to create a function that takes one argument, and that argument will be multiplied with an unknown given number.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters)
Example:
def tips_anagram(s1, s2): _str1, _str2 = s1.replace(" ", ""), s2.replace(" ", "") return False if len(_str1) != len(_str2) else sorted(_str1.lower()) == sorted(_str2.lower()) print(tips_anagram("TRIANGLE", "INTEGRAL")) print(tips_anagram("anagram", "Nag a ram"))
Output:
True True
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework