What is the result of the program?
❌ 4
✅ 5
❌ 6
❌ Error will occur
❌ None of the mentioned
Explanation:
The task of append() method is to append a passed obj into an existing list. But instead of passing a list to the append method will not merge the two lists, the entire list which is passed is added as an element of the list ([1, 2, 3, 4, [5, 6]])
So the output is 5.
❌ 4
✅ 5
❌ 6
❌ Error will occur
❌ None of the mentioned
Explanation:
The task of append() method is to append a passed obj into an existing list. But instead of passing a list to the append method will not merge the two lists, the entire list which is passed is added as an element of the list ([1, 2, 3, 4, [5, 6]])
So the output is 5.
What is the result of the program?
❌ Runs normally, doesn’t display anything
❌ Displays 0, which is the automatic default value
✅ Error as one argument is required while creating the object
❌ Error as display function requires additional argument
❌ None of the mentioned
Explanation:
Since, the init special method has another argument a other than self, during object creation, one argument is required. For example: obj=test(“Hello”)
❌ Runs normally, doesn’t display anything
❌ Displays 0, which is the automatic default value
✅ Error as one argument is required while creating the object
❌ Error as display function requires additional argument
❌ None of the mentioned
Explanation:
Since, the init special method has another argument a other than self, during object creation, one argument is required. For example: obj=test(“Hello”)
What is the output of the program?
❌ Woof!
❌ Arff!
✅ *walking*
❌ AttributeError: 'JackRussellTerrier' object has no attribute 'walk'
❌ None of the mentioned
Explanation:
While bobo is an instance of JackRussellTerrier it still has a .walk() method. This method was inherited from the parent Dog class.
❌ Woof!
❌ Arff!
✅ *walking*
❌ AttributeError: 'JackRussellTerrier' object has no attribute 'walk'
❌ None of the mentioned
Explanation:
While bobo is an instance of JackRussellTerrier it still has a .walk() method. This method was inherited from the parent Dog class.
What is the output of the program?
❌ [1, 2, 3, 4, 5]
❌ [1, 2, 3, 4, 5, 6]
❌ [2, 3, 4, 5]
✅ [2, 3, 4, 5, 6]
❌ Error will occur
❌ None of the mentioned
Explanation:
The code line “second = first ” creates the shallow copy of the list. It means there will be a single list in memory. The first and second variables are pointed to the same list.
It does not maintain two separate lists, but only one. If you modify using one list variable, it will make the changes in the list for both variables.
If you want to maintain two separate lists for two list objects, you need to create a deep copy of the list.
❌ [1, 2, 3, 4, 5]
❌ [1, 2, 3, 4, 5, 6]
❌ [2, 3, 4, 5]
✅ [2, 3, 4, 5, 6]
❌ Error will occur
❌ None of the mentioned
Explanation:
The code line “second = first ” creates the shallow copy of the list. It means there will be a single list in memory. The first and second variables are pointed to the same list.
It does not maintain two separate lists, but only one. If you modify using one list variable, it will make the changes in the list for both variables.
If you want to maintain two separate lists for two list objects, you need to create a deep copy of the list.
What is the output of the program?
❌ 2 4
❌ 0 0
✅ 1 2 1 2
❌ -1 -2 -1 -2
❌ Error will occur
❌ None of the mentioned
Explanation:
"a * 2" means, string prints 2 times. "a * 0" means, string is empty.
Any string cannot be negative. Therefore, the string in the 3rd case will not print any word.
❌ 2 4
❌ 0 0
✅ 1 2 1 2
❌ -1 -2 -1 -2
❌ Error will occur
❌ None of the mentioned
Explanation:
"a * 2" means, string prints 2 times. "a * 0" means, string is empty.
Any string cannot be negative. Therefore, the string in the 3rd case will not print any word.
What is the result of the code?
❌ 300 400
✅ 100 400
❌ 100 200
❌ 300 200
❌ None of the above
❌ Error
Explanation:
In the above code x is a private variable declared in the class P. Thus value of x cannot be changed in the class C which inherits class P. But y is not a private variable thus its value can be changed.
❌ 300 400
✅ 100 400
❌ 100 200
❌ 300 200
❌ None of the above
❌ Error
Explanation:
In the above code x is a private variable declared in the class P. Thus value of x cannot be changed in the class C which inherits class P. But y is not a private variable thus its value can be changed.
What is the output of the code?
❌ 1 2 3
❌ 1 3 2
❌ 1 (3, 2)
❌ 1 (2, 3)
✅ 1 {'c': 3, 'b': 2}
❌ 1 {'c': 2, 'b': 3}
❌ Error
❌ None of the above
Explanation:
The code prints '1 {'c': 3, 'b': 2}', because 1 is passed to a by name and the **kargs collects the remaining keyword arguments into a dictionary. We could step through the extra keyword arguments dictionary by key with any iteration tool (e.g., for key in kargs: ...)
❌ 1 2 3
❌ 1 3 2
❌ 1 (3, 2)
❌ 1 (2, 3)
✅ 1 {'c': 3, 'b': 2}
❌ 1 {'c': 2, 'b': 3}
❌ Error
❌ None of the above
Explanation:
The code prints '1 {'c': 3, 'b': 2}', because 1 is passed to a by name and the **kargs collects the remaining keyword arguments into a dictionary. We could step through the extra keyword arguments dictionary by key with any iteration tool (e.g., for key in kargs: ...)