MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

SQL

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What would the value of the length variable be after this code is run?:length = len("Hello")
A
5
B
6
C
0
D
Would you like a toasted teacake?
Explanation: 

Detailed explanation-1: -The len() function returns the number of items in an object. When the object is a string, the len() function returns the number of characters in the string.

Detailed explanation-2: -The function len() is one of Python’s built-in functions. It returns the length of an object. For example, it can return the number of items in a list.

Detailed explanation-3: -Python len is one of the various magic methods in Python programming language, it is basically used to implement the len() function in Python because whenever we call the len() function then internally len magic method is called.

Detailed explanation-4: -Here, len(["hello", 2, 4, 6]) will give the output as 4 since there are 4 data items in the list.

There is 1 question to complete.