Important Python Mcqs

To return the length of string s what command do we execute?

a) s.__len__()

b) len(s)

c) size(s)

d) s.size()

Answer:

a) s.__len__()

Explanation:

We usually use len(s) to print the length of the string. It works by calling an __len__ method behind the scene, thus a is the right choice!

Related MCQs

The main method header is written as?

a. public static void main(string[] args) b. public static void Main(string[] args) c. public static void main(Strings[] args) d. public static void main(String[] args) Answer:

A Java variable is the name of a

a. data value stored in memory that can change its value but cannot change its type during the program’s execution b. data type stored in

Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?