Python 2 Marks Important Questions
Python 2 Marks Important Questions
List:
- Mutable (can be changed)
- Defined using [ ]
- Slower due to flexibility
Tuple:
- Immutable (cannot be changed)
- Defined using ( )
- Faster and memory efficient
Example:
my_list = [1, 2, 3]
my_tuple = (1, 2, 3)
Syntax:
def function_name(parameters):
# code block
Example:
def greet():
print("Hello")
Syntax:
lambda arguments: expression
Example:
square = lambda x: x*x
print(square(5)) # Output: 25