OneMarksPython
OneMarksPython
incrementing by step.
my_set = {1, 2, 3, 4, 5}
print(my_set) # Output: {1, 2, 3, 4, 5}
my_set.add(6) # Adding an element
print(my_set) # Output: {1, 2, 3, 4, 5, 6}
# my_module.py
def greet(name):
return f"Hello, {name}!"
# In another file
from my_module import greet
print(greet('Alice')) # Output: Hello, Alice!
21.What is indentation?
● Indentation in Python refers to the use of spaces or tabs to define the
structure and flow of the code. It indicates a block of code belonging to a
specific control structure (like loops, functions, classes). Proper
indentation is crucial as it determines the grouping of statements.
22.Write code to print the elements of the list lst = [10, 20, 30, 40, 50].
string.
○ re.sub(): Replaces occurrences of the pattern with a specified string