Kernel: Python 3
In [ ]:
In [ ]:
Return() is not mandatory in Python
In [ ]:
Different variable class can be passed within a function
In [ ]:
In [ ]:
Use math module for mathemathical functions
In [13]:
Out[13]:
Enter any number =45
6.708
- Q Write a Python function to sum all the numbers in a list.
In [ ]:
- Q Write a Python funtion to check whether a given number is the given range?
In [ ]:
- Q Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters
In [ ]:
In [ ]:
Lamba Function
ambda function
The lambda keyword is used to create anonymous functions - This function can have any number of arguments but only one expression, which is evaluated and returned. - One is free to use lambda functions wherever function objects are required. - You need to keep in your knowledge that lambda functions are syntactically restricted to a single expression.
In [ ]:
In [ ]:
In [ ]:
Write a Python program to sort a list of tuples using Lambda
In [ ]:
The power of lambda is better shown when you use them as an anonymous function inside another function.
In [19]:
Out[19]:
12
In [28]:
Out[28]:
The number: 6
1296
def mydata(n):
return lambda a,b:(a+b)*n var = mydata(4) print(var(2,3))
Classes in Python &OO programming
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: