Python/ Sample Test,Sample questions

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

print("abcdef".center(10, '12'))

1. 12abcdef12

2. abcdef1212

3.1212abcdef

4.error

Posted Date:-2021-12-30 07:53:34


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

print("Hello {1} and {0}".format('bin', 'foo'))

1.Hello foo and bin

2.Hello bin and foo

3. Error

4.none of the mentioned

Posted Date:-2021-12-30 08:02:23


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

print("xyyzxyzxzxyy".count('xyy', -10, -1))

1.2

2. 0

3. 1

4.error

Posted Date:-2021-12-30 07:56:16


Question:
hat will be the output of the following Python code snippet?

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

1.The sum of 2 and 10 is 12

2. The sum of 10 and a is 14

3.The sum of 10 and a is c

4.Error

Posted Date:-2021-12-30 08:05:42


Question:
What is the default value of encoding in encode()?

1.ascii

2.qwerty

3.utf-8

4.utf-16

Posted Date:-2021-12-30 07:57:13


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

print('	'.isspace())

1.True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:17:29


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

print('__foo__'.isidentifier())

1.True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:13:06


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

print('{:,}'.format('1112223334'))

1.1,112,223,334

2. 111,222,333,4

3.1112223334

4. error

Posted Date:-2021-12-30 08:06:56


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

print('{:,}'.format(1112223334))

1. 1,112,223,334

2. 111,222,333,4

3.1112223334

4.error

Posted Date:-2021-12-30 08:06:06


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

print('{:#}'.format(1112223334))

1.1,112,223,334

2.111,222,333,4

3. 1112223334

4. 1112223334

Posted Date:-2021-12-30 08:08:04


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

print('{:$}'.format(1112223334))

1. 1,112,223,334

2. 111,222,333,4

3.1112223334

4.error

Posted Date:-2021-12-30 08:07:19


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

print(''.isdigit())

1.True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:12:17


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

print(''''''.isspace())

1.True

2. False

3.None

4. Error

Posted Date:-2021-12-30 08:17:05


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

print('0xa'.isdigit())

1.True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:11:55


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

print('1.1'.isnumeric())

1. True

2.False

3. None

4.Error

Posted Date:-2021-12-30 08:16:10


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

print('1@ a'.isprintable())

1. True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:16:37


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

print('11'.isnumeric())

1. True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:15:50


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

print('a@ 1,'.islower())

1.True

2.False

3.None

4. error

Posted Date:-2021-12-30 08:15:28


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

print('abc'.islower())

1. True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:15:06


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

print('for'.isidentifier())

1.True

2.False

3.None

4. Error

Posted Date:-2021-12-30 08:14:37


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

print('HelloWorld'.istitle())

1.True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:18:58


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

print('my_string'.isidentifier())

1.True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:12:40


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

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

1.The sum of 2 and 10 is 12

2.Error

3.The sum of 0 and 1 is 2

4.none of the mentioned

Posted Date:-2021-12-30 08:05:18


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

print('{0:.2}'.format(1/3))

1. 0.333333

2.0.33

3.0.333333:.2

4.Error

Posted Date:-2021-12-30 08:08:47


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

print('a B'.isalpha())

1.True

2.False

3. None

4.Error

Posted Date:-2021-12-30 08:11:29


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

print('ab,12'.isalnum())

1. True

2.False

3.None

4.error

Posted Date:-2021-12-30 08:10:29


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

print('ab'.isalpha())

1.True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:10:55


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

print('ab12'.isalnum())

1.True

2. False

3.None

4.error

Posted Date:-2021-12-30 08:10:03


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

print('abc'.encode())

1.abc

2. ‘abc’

3.b’abc’

4.h’abc’

Posted Date:-2021-12-30 07:56:42


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

print("ab	cd	ef".expandtabs())

1. ab  cd  ef

2.abcdef

3.ab cd ef

4.ab cd ef

Posted Date:-2021-12-30 07:59:31


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

print("ab	cd	ef".expandtabs('+'))

1. ab+cd+ef

2. ab++++++++cd++++++++ef

3.ab cd ef

4.none of the mentioned

Posted Date:-2021-12-30 08:00:24


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

print("ab	cd	ef".expandtabs(4))

1.ab  cd  ef

2.abcdef

3.ab cd ef

4.ab cd ef

Posted Date:-2021-12-30 07:59:57


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

print("abcdef".center(7, '1'))

1.1abcdef

2. abcdef1

3. abcdef

4. error

Posted Date:-2021-12-30 07:52:18


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

print("abcdef".center(7, 1))

1.1abcdef

2.abcdef1

3. abcdef

4.error

Posted Date:-2021-12-30 07:51:54


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

print("abcdef".find("cd") == "cd" in "abcdef")

1.True

2. False

3.Error

4.none of the mentioned

Posted Date:-2021-12-30 08:00:46


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

print("abcdef".find("cd"))

1.True

2.2

3. 3

4.none of the mentioned

Posted Date:-2021-12-30 08:01:09


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

print("ccdcddcd".find("c"))

1.4

2. 0

3.Error

4.True

Posted Date:-2021-12-30 08:01:32


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

print("Hello {} and {}".format('foo', 'bin'))

1. Hello foo and bin

2.Hello {} and {}

3.Error

4. Hello and

Posted Date:-2021-12-30 08:02:43


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

print("Hello {0!r} and {0!s}".format('foo', 'bin'))

1.Hello foo and foo

2.Hello ‘foo’ and foo

3.Hello foo and ‘bin’

4.Error

Posted Date:-2021-12-30 08:04:20


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

print("Hello {0} and {1}".format(('foo', 'bin')))

1. Hello foo and bin

2. Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)

3. Error

4.None of the mentioned

Posted Date:-2021-12-30 08:04:45


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

print("Hello {0} and {1}".format('foo', 'bin'))

1.Hello foo and bin

2. Hello {0} and {1} foo bin

3. Error

4.Hello 0 and 1

Posted Date:-2021-12-30 08:01:56


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

print("Hello {name1} and {name2}".format('foo', 'bin'))

1. Hello foo and bin

2. Hello {name1} and {name2}

3. Error

4.Hello and

Posted Date:-2021-12-30 08:03:10


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

print("Hello {name1} and {name2}".format(name1='foo', name2='bin'))

1.Hello foo and bin

2.Hello {name1} and {name2}

3.Error

4. Hello and

Posted Date:-2021-12-30 08:03:54


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

print("xyyzxyzxzxyy".count('xyy', 0, 100))

1.2

2.0

3.1

4. error

Posted Date:-2021-12-30 07:55:29


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

print("xyyzxyzxzxyy".count('xyy', 2, 11))

1. 2

2.0

3.1

4.error

Posted Date:-2021-12-30 07:55:54


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

print("xyyzxyzxzxyy".count('yy', 1))

1. 2

2. 0

3. 1

4.none of the mentioned

Posted Date:-2021-12-30 07:54:34


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

print("xyyzxyzxzxyy".count('yy', 2))

1. 2

2.0

3.1

4.none of the mentioned

Posted Date:-2021-12-30 07:55:00


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

print("xyyzxyzxzxyy".count('yy'))

1. 2

2. 0

3.error

4.none of the mentioned

Posted Date:-2021-12-30 07:54:10


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

print("xyyzxyzxzxyy".endswith("xyy", 0, 2))

1. 0

2. 1

3.True

4.False

Posted Date:-2021-12-30 07:57:59


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

print("xyyzxyzxzxyy".endswith("xyy"))

1. 1

2.True

3.3

4. 2

Posted Date:-2021-12-30 07:57:35


More MCQS

  1. help4info.com
  2. help4info.com
  3. help4info.com
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!