pre-interview
A tuple is an immutable sequence type, which means its elements cannot be changed once they are assigned. A list is a mutable sequence type, which means its elements can be modified.
A dictionary is a built-in data type in Python that allows you to store data as key-value pairs. It is commonly used for lookups and data organization.
The __init__ method is a special method in Python classes that is automatically called when an instance of the class is created. It is used to initialize the attributes of the class.
Both x = x + 1 and x += 1 increment the value of x by 1. But x=x+1 creates a new object for x and assigns it to x whereas x+=1 increments the value of x in place.
A local variable is a variable that is defined within a function or a method and can only be accessed within that function or method. A global variable is a variable that is defined outside of any function or method and can be accessed and modified throughout the entire program.
The yield keyword is used in Python to define a generator function. A generator function is a special type of function that allows you to return multiple values one at a time, rather than returning them all at once.
Both and and or are logical operators in Python. and operator returns True if both the conditions are true otherwise False. or operator returns True if at least one of the conditions are true otherwise False.
No comments