Python String Quiz: Python Programming Quiz

Python String Quiz. This set has 15 Multiple Choice Questions on the topic of Strings in Python Language. For all Python-related MCQs visit Python MCQs

 

Python String Quiz

 

 

What will be the output of the following Python code ??

print(“ab\tcd\tef”.expandtabs(‘+’))

a) ab+cd+ef
b) ab++++++++cd++++++++ef
c) ab cd ef
d) none of the mentioned

 

What will be the output of the following Python code ??

print(“Hello {0!r} and {0!s}”.format(‘foo’, ‘bin’))

a) Hello foo and foo
b) Hello ‘foo’ and foo
c) Hello foo and ‘bin’
d) Error

 

What will be the output of the following Python statement ??

print(“ab\tcd\tef”.expandtabs(4))

a) ab  cd  ef
b) abcdef
c) ab\tcd\tef
d) ab cd ef

 

What will be the output of the following Python ??

print(“Hello {name1} and {name2}”.format(name1=’foo’, name2=’bin’))

a) Hello foo and bin
b) Hello {name1} and {name2}
c) Error
d) Hello and

 

Python String Quiz

 

What will be the output of following code ??

print(“ab\tcd\tef”.expandtabs())

a) ab  cd  ef
b) abcdef
c) ab\tcd\tef
d) ab cd ef

 

What will be the output of the following Python code snippet?

print(‘Hello World’.istitle())

a) True
b) False
c) None
d) Error

 

What will be the output of the following Python code ??

print(‘__foo__’.isidentifier())

a) True
b) False
c) None
d) Error

 

What will be the output of the following Python code ??

print(‘HelloWorld’.istitle())

a) True
b) False
c) None
d) Error

 

Python String Quiz

 

What will be the output of the following Python statement ??

print(‘my_string’.isidentifier())

a) True
b) False
c) None
d) Error

 

What will be the output of the print statement ??

print(‘\t’.isspace())

a) True
b) False
c) None
d) Error

 

What will be the output of the following Python code ??

print(”.isdigit())

a) True
b) False
c) None
d) Error

 

What will be the output of the following Python expression ??

print(”””.isspace())

a) True
b) False
c) None
d) Error

 

Python String Quiz

 

What will be the output of the following Python expression ??

print(‘0xa’.isdigit())

a) True
b) False
c) None
d) Error

 

What will be the output of the following Python code ??

print(‘1@ a’.isprintable())

a) True
b) False
c) None
d) Error

 

What will be the output of the following Python code ??

print(‘a B’.isalpha())

a) True
b) False
c) None
d) Error

 

Read More

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!