Q. 1

What is the output of the following code ?

>>> "asd".isalpha(), "".isalpha(), "asd123".isalpha()

 

Options:

Explanation

Correct answer is : C

isalpha() - Return true if all characters in the string are alphabetic and there is at least one character, false otherwise

 

Discuss It

Q. 2

What is the output of the following code ? 

>>> "asd".isascii(), "".isascii(), "asd123".isascii(), "ß".isascii()

 

Options:

Explanation

Correct answer is : A

isascii() - Return true if the string is empty or all characters in the string are ASCII

Discuss It

Q. 3

What is the output of the following code ? 

>>> "123".isdecimal(), "asd".isdecimal(), "".isdecimal(), "asd123".isdecimal(), "123.13".isdecimal()

Options:

Explanation

Correct answer is : C

Return true if all characters in the string are decimal characters and there is at least one character, false otherwise

>>> "123".isdecimal(), "asd".isdecimal(), "".isdecimal(), "asd123".isdecimal(), "123.13".isdecimal()
(True, False, False, False, False)

Discuss It

Q. 4

What is the output of the following code ? 

>>> "½¼".isnumeric(), "½¼".isdigit(), "½¼".isdecimal()

 

Options:

Q. 5

What is the output of the following code ?

>>> "12a".islower(), "12aA".islower()

 

Options:

Explanation

Correct answer is : B

Return true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.

In "12aA".islower() , A is an uppercase letter

Discuss It

Q. 6

What is the output of the following code ? 

>>> "This Is Title".istitle(), "This'Is1Title".istitle()

 

Options:

Explanation

Correct answer is : A

str.istitle()- Return true if the string is a titlecased string and there is at least one character, for example uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return false otherwise.

"This Is Title".istitle() give True

For this "This'Is1Title".istitle() -> title() considers This, Is and Title as separate words and provides True

Discuss It

Q. 7

What is the output of the following code ?

>>> s = "This is Python and it is easy"
>>> s.find('is'), s.rfind('is')

Options:

Explanation

Correct answer is : A

find() gives lowest index and rfind() gives highest index of "is" respectively 

Discuss It

Q. 8

What is the output of the following code ?

>>> 'ismississippi'.lstrip('ipz'), 'ismississippi'.rstrip('ipz')

 

Options:

Explanation

Discuss It

Q. 9

What is the output of the following code ?

>>> s = "This is Python and it is easy"
>>> s.partition("py")

 

Options:

Explanation

Discuss It
Submit Your Answers

Interview Questions

on
Data Types

Tutorial

on
Data Types

Programs

on
Data Types
Click any Link
to navigate to certain page easily
Write a line to us
Your Email
Title
Description