Revision as of 11:55, 16 August 2019 by Amanjosan2008(talk | contribs)(Protected "Python Interviews" ([Delete=Allow only logged in users] (indefinite) [Edit=Allow only logged in users] (indefinite) [Move=Allow only logged in users] (indefinite)))
List is mutable while the Tuple is not.
A tuple is allowed to be hashed. E.g: using it as a key for dictionaries.
List: a = [1,3,6]
Tuple: b = (1,4,8)
Lambda vs. def.
Def can hold multiple expressions while lambda is a uni-expression function.
Def generates a function and designates a name to call it later. Lambda forms a function object and returns it.
Def can have a return statement. Lambda can’t have return statements.
Lambda supports to get used inside a list and dictionary.
Optional statements possible inside a try-except block:
“else” clause: It is useful if you want to run a piece of code when the try block doesn’t create an exception.
“finally” clause: It is useful when you want to execute some steps which run, irrespective of whether there occurs an exception or not.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.