Q.1.
What is “Hello”.replace(“l”, “e”)?
Q.2.
To retrieve the character at index 3 from string s=”Hello” what command do we execute (multiple answers allowed)?
Q.3.
To return the length of string s what command do we execute?
Q.4.
If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.
Q.5.
To check whether string s1 contains another string suse ________
Q.6.
Suppose i is 5 and j isi + j is same as ________
Q.7.
What will be the output of the following Python code? class Count: def __init__(self, count = 0): self.__count = count c1 = Count(2)c2 = Count(2)print(id(c== id(c2), end = " ") s1 = "Good"s2 = "Good"print(id(s== id(s2))
Q.8.
What will be the output of the following Python code? class Name: def __init__(self, firstName, mi, lastName): self.firstName = firstName self.mi = mi self.lastName = lastName firstName = "John"name = Name(firstName, 'F', "Smith")firstName = "Peter"name.lastName = "Pan"print(name.firstName, name.lastName)
Q.9.
What function do you use to read a string?
Q.10.
Suppose x is 345.what is format(x, “10.3f”) (_ indicates space).