Summary
- For loop can make iterations with in the range (with being mentioning the range)
x = [1,2,3,4,5]
for i in x:
x = i * i
print(x)
- In python List comprehension can utilize conditional statements to modify existing list or tuple and can store the modify values another list/tuple which creates statements in one line only and makes more readable and efficient
x = [1,2,3,4,5]
y=[i*i for i in x]
y
# o/p: [1, 4, 9, 16, 25]
- Function is a set of statements executed when the function call until it is not perform any operations.
- To define the function can use def keyword before the function name
def iiec():
print("hi")
iiec()
- Parentheses used in the function to call the function to perform the operation in the block of code in function.