Python Guide
Python Guide
1. Python Functions
-------------------
Syntax:
def function_name(parameters):
Function docstring
statement(s)
return value
Example:
def greet(name):
2. Lambda Functions
-------------------
Syntax:
Example:
square = lambda x: x * x
print(square(5)) # Output: 25
add = lambda x, y: x + y
--------
3.1 1D List:
lst = [1, 2, 3, 4]
print(lst[0]) # Output: 1
3.2 2D List:
print(matrix[1][0]) # Output: 3
3.3 3D List:
print(cube[1][0][0]) # Output: 3
print(mixed[2][0][1]) # Output: 5
4. Input
--------
# print("Hello", name)
--------
for i in range(5):
print(i) # Outputs 0 to 4
i=0
while i < 5:
print(i)
i += 1
for i in range(2):
for j in range(2):
print(f"i={i}, j={j}")
Conclusion:
This document gives an overview of Python's essential syntax for functions, lambda, lists of various types,