-
What is the difference between a function and a method in Python?
Answer: A function is a block of code within a module or class, while a method is a specific function within an object.
-
What is a class in Python?
Answer: A class is a blueprint that defines the structure and behavior of objects in a program. Classes define attributes (data members) and methods (functions that operate on those attributes).
-
What is an object in Python?
Answer: An object is an instance of a class, which contains data and methods that can be used by other objects.
-
What is the difference between a variable and a list in Python?
Answer: A variable is a named entity that stores a specific value, while a list is an unordered collection of values stored as a sequence of elements.
-
What is the difference between a variable and a list in Python?
Answer: A variable is a named entity that stores a specific value, while a list is an unordered collection of values stored as a sequence of elements.
-
What is the role of variables in Python?
Answer: Variables play a key role in Python, as they are used to store values that can be changed and used within the program.
-
What is a for loop in Python?
Answer: A for loop is a basic control structure used to iterate over a sequence of items. It works by specifying the starting index, the ending index, and a step value.
-
What is the difference between a class and a module in Python?
Answer: A class is a blueprint that defines the structure and behavior of objects in a program, while a module is a collection of related classes and functions that can be imported and used in other parts of the program.
-
What is the difference between a variable and a list in Python?
Answer: A variable is a named entity that stores a specific value, while a list is an unordered collection of values stored as a sequence of elements.
-
What is the difference between a variable and a list in Python?
Answer: A variable is a named entity that stores a specific value, while a list is an unordered collection of values stored as a sequence of elements.