What will be the output of the following Python code?
>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)
a) 1
b) 2
c) 5
d) Error
Answer: d
Explanation: Tuples are immutable and don’t have an append method. An exception is thrown in this case.
Related Posts
What will be the output of the following JavaScript code?
var a1 = [,,,];
var a2 = new Array(3);
0 in a1
0 in a2What is the observation made in the following JavaScript code?
var count = [1,,3];What will be the output of the following JavaScript code?
const obj = {prop: 12};
Object.preventExtensions(obj);
console.log( Object.isExtensible(obj));What will be the output of the following JavaScript code?
const object1 = {
property1: 20
};
console.log(Object.is(object1));What will be the output of the following JavaScript code?
const obj1 = { property1: ’10’};
const obj2 = Object.freeze(obj1);
obj2.property1 = ’20’;
console.log(obj2.property1);What will be the output of the following JavaScript code?
const obj1 =
{
property1: 21
}
const descriptor1 = Object.getOwnPropertyDescriptor(obj1, ‘property1’);
console.log(descriptor1.configurable);
console.log(descriptor1.enumerable);What will be the output of the following JavaScript code?
const object1 = {};
a = Symbol(‘a’);
b = Symbol.for(‘b’);
object1[a] = ‘harry’;
object1[b] = ‘derry’;
const objectSymbols = Object.getOwnPropertySymbols(object1);
console.log(objectSymbols.length);
Join The Discussion