Python Strings Questions: Python Programming MCQs

Python Strings Questions. Multiple Choice Questions on Python Strings. For the complete String topic and other Python topics see Python MCQs

 

Python Strings Questions

 

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

print(‘{:#}’.format(1112223334))

a) 1,112,223,334
b) 111,222,333,4
c) 1112223334
d) Error

 

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

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

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

 

What will be the output of the following Python ??

print(‘{:$}’.format(1112223334))

a) 1,112,223,334
b) 111,222,333,4
c) 1112223334
d) Error

 

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

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

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

 

Python Strings Questions

 

What will be the output ??

print(‘{:,}’.format(‘1112223334’))

a) 1,112,223,334
b) 111,222,333,4
c) 1112223334
d) Error

 

What will be the output of the following ??

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

a) Hello foo and bin
b) Hello bin and foo
c) Error
d) None of the mentioned

 

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

print(‘{:,}’.format(1112223334))

a) 1,112,223,334
b) 111,222,333,4
c) 1112223334
d) Error

 

What will be the output of the following ??

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

a) Hello foo and bin
b) Hello {0} and {1} foo bin
c) Error
d) Hello 0 and 1

 

Python Strings Questions

 

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

print(‘The sum of {0:b} and {1:x} is {2:o}’.format(2, 10, 12))

a) The sum of 2 and 10 is 12
b) The sum of 10 and a is 14
c) The sum of 10 and a is c
d) Error

 

What is the output of the code ??

print(“ccdcddcd”.find(“c”))

a) 4
b) 0
c) Error
d) True

 

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

print(‘The sum of {0} and {1} is {2}’.format(2, 10, 12))

a) The sum of 2 and 10 is 12
b) Error
c) The sum of 0 and 1 is 2
d) None of the mentioned

 

What is the output of the following line ??

print(“abcdef”.find(“cd”))

a) True
b) 2
c) 3
d) None of the mentioned

 

Python Strings Questions

 

What will be the output of the following ??

print(“Hello {0[0]} and {0[1]}”.format((‘foo’, ‘bin’)))

a) Hello foo and bin
b) Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
c) Error
d) None of the mentioned

 

What will be the output of the following Python code?

print(“abcdef”.find(“cd”) == “cd” in “abcdef”)

a) True
b) False
c) Error
d) None of the mentioned

 

What will be the output of the following Python code?

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

a) Hello foo and bin
b) Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
c) Error
d) None of the mentioned

 

Read More

Leave a Comment

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

error: Content is protected !!