Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What do you mean by string in Python ?

Answer» Strings are amongst the most popular types in Python. We can create them simply by characters in quotes. Python treats single quotes the same as double quotes. Creating strings is as simple as assigning a value to a variable. For example :

var1 = ‘Waltons Technology!’

var2 = “Python Programming”
2.

What do you mean by endswith(suffix, beg=0, end=len(string))

Answer»

The method endswith( ) returns True if the string ends with the specified suffix, otherwise return False

3.

Explain Parameters of str.startswith(str, beg=0,end=len( string) );

Answer»

str — This is the string to be checked.

beg — This is the optional parameter to set start index of the matching boundary. 

end — This is the optional parameter to set end index of the matching boundary. 

4.

Describe index(str, beg=0, end=len(string)) with example

Answer»

The method index( ) determines if string str occurs in string or in a substring of string if starting indexbeg and ending index end are given. This method is same as 

find( ), but raises an exception 

if sub is not found.

Syntax 

str.index(str, beg=0 end=len(string))

Example 

# !/usr/bin/python

str = “this is string example….wow!!!”;

str = “exam”; 

print str.index(str); 

print str.index(str, 10); 

print str.index(str, 40);

OUTPUT 

15 

15 Traceback (most recent call last): 

File “test.py”, line 8, in

print str.index(str, 40); 

ValueError: substring not found 

shell returned 1

5.

Describe the count(str, beg=0,end= len(string))

Answer»

The method count( ) returns the number of occurrences of substring sub in the range [start, end].

6.

Explain Parameters of str.rjust(width[, fillchar])

Answer» width — This is the string length in total after padding.

fillchar — This is the filler character, default is a space.