Python/Python Mcq Set 2 Sample Test,Sample questions

Question:
 What is the two’s complement of -44?

1. 1011011

2. 11010100

3.11101011

4.10110011


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

x=3.3456789
'%s' %x, str(x)

1. Error

2.(‘3.3456789’, ‘3.3456789’)

3.(3.3456789, 3.3456789)

4.(‘3.3456789’, 3.3456789)


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

'{0:.2f}'.format(1.234)

1.‘1’

2. ‘1.234’

3.‘1.23’

4.‘1.2’


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

'{0:.2f}'.format(1.234)

1.‘1’

2. ‘1.234’

3.‘1.23’

4.‘1.2’


Question:
 What will be the output of the following Python expression if X = -122?

print("-%06d"%x)

1. -000122

2.000122

3.–00122

4.-00122


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

bin(29)

1.‘0b10111’

2.‘0b11101’

3.‘0b11111’

4.‘0b11011’


Question:
 What will be the value of the following Python expression?

 bin(10-2)+bin(12^4)

1. 0b10000

2.0b10001000

3.0b1000b1000

4.0b10000b1000


Question:
Any odd number on being AND-ed with ________ always gives 1. Hint: Any even number on being AND-ed with this value always gives 0.

1. 10

2.2

3.1

4. 0


Question:
Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are 1.

1.OR

2.AND

3.XOR

4. NOT


Question:
The expression shown below results in an error.

print("-%5d0",989)

1.Error

2.1 hello you 4.0

3. 1 hello 4 you

4.1 4 hello you


Question:
The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.

1.first, right

2.second, left

3.first, left

4.second, right


Question:
The one’s complement of 110010101 is:

1.001101010

2.110010101

3.001101011

4.110010100


Question:
The output of which of the codes shown below will be: “There are 4 blue birds.”?

1.‘There are %g %d birds.’ %4 %blue

2. ‘There are %d %s birds.’ %(4, blue)

3.There are %s %d birds.’ %[4, blue]

4.‘There are %d %s birds.’ 4, blue


Question:
To find the decimal value of 1111, that is 15, we can use the function:

1.int(1111,10)

2.int(‘1111’,10)

3. int(1111,2)

4. int(‘1111’,2)


Question:
What is the value of the following Python expression?

bin(0x8)

1.‘0bx1000’

2. 8

3.1000

4. ‘0b1000’


Question:
What will be the output of the following Python code if a=10 and b =20?

a=10
b=20
a=a^b
b=a^b
a=a^b
print(a,b)

1.10 20

2.10 10

3. 20 10

4.20 20


Question:
What will be the output of the following Python code snippet if x=1?

x<<2

1. 8

2. 1

3. 2

4. 4


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

'%(qty)d more %(food)s' %{'qty':1, 'food': 'spam'}

1.Error

2. No output

3. ‘1 more foods’

4. ‘1 more spam’


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

a='hello'
q=10
vars()

1. {‘a’ : ‘hello’, ‘q’ : 10, ……..plus built-in names set by Python….}

2.{……Built in names set by Python……}

3.{‘a’ : ‘hello’, ‘q’ : 10}

4. Error


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

not(10<20) and not(10>30)

1. True

2.False

3.Error

4.No output


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

x=3.3456789
'%-6.2f | %05.2f | %+06.1f' %(x, x, x)

1. ‘3.35 | 03.35 | +003.3’

2. ‘3.3456789 | 03.3456789 | +03.3456789’

3. Error

4.‘3.34 | 03.34 | 03.34+’


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

x=3.3456789
'%f | %e | %g' %(x, x, x)

1.Error

2.‘3.3456789 | 3.3456789+00 | 3.345678’

3. ‘3.345678 | 3.345678e+0 | 3.345678’

4.‘3.345679 | 3.345679e+00 | 3.34568’


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

X=”hi”
print(“05d”%X)

1.00000hi

2.000hi

3.hi000

4. error


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

['hello', 'morning'][bool('')]

1. error

2.no output

3.hello

4.morning


Question:
What will be the output of the following Python code snippet?
X=”san-foundry”
print(“%56s”,X)

1.56 blank spaces before san-foundry

2. 56 blank spaces before san and foundry

3.56 blank spaces after san-foundry

4. no change


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

'%x %d' %(255, 255)

1. ‘ff, 255’

2.‘255, 255’

3. ‘15f, 15f’

4.error control


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

'{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2])

1. Error

2. ‘2.5, 10, [1, 2]’

3.2.5, 10, 1, 2

4.’10, 2.5, [1, 2]’


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

l=list('HELLO')
'first={0[0]}, third={0[2]}'.format(l)

1.‘first=H, third=L’

2.‘first=0, third=2’

3. Error

4.‘first=0, third=L’


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

l=list('HELLO')
p=l[0], l[-1], l[1:3]
'a={0}, b={1}, c={2}'.format(*p)

1.Error

2.“a=’H’, b=’O’, c=(E, L)”

3.“a=H, b=O, c=[‘E’, ‘L’]”

4. Junk value


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

l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))

1.Error

2. [1, 0, 2, 0, ‘hello’, ”, []]

3.[1, 0, 2, ‘hello’, ”, []]

4.[1, 2, ‘hello’]


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

s='%s, %s & %s'
s%('mumbai', 'kolkata', 'delhi')

1.mumbai kolkata & delhi

2.Error

3.No output

4. ‘mumbai, kolkata & delhi’


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

s='{0}, {1}, and {2}'
s.format('hello', 'good', 'morning')

1. ‘hello good and morning’

2. ‘hello, good, morning’

3. ‘hello, good, and morning’

4. error


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

t = '%(a)s, %(b)s, %(c)s'
t % dict(a='hello', b='world', c='universe')

1. ‘hello, world, universe’

2. ‘hellos, worlds, universes’

3. Error

4.hellos, world, universe


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

['f', 't'][bool('spam')]

1.t

2.f

3.No output

4.error control


Question:
What will be the output of the following Python expression if the value of x is 34?

print(“%f”%x)

1.34.00

2.34.0000

3.34.000000

4.34.00000000


Question:
What will be the output of the following Python expression if x=15 and y=12?

x & y

1.b1101

2.0b1101

3.12

4. 1101


Question:
What will be the output of the following Python expression if x=22.19?

print("%5.2f"%x)

1.22.1900

2.22.00000

3. 22.19

4.22.20


Question:
What will be the output of the following Python expression if X=345?

print(“%06d”%X)

1. 345000

2.000345

3.000000345

4. 345000000


Question:
What will be the output of the following Python expression if x=456?

print("%-06d"%x)

1.000456

2.456000

3. 456

4. error


Question:
What will be the output of the following Python expression if x=56.236?

print("%.2f"%x)

1.56.00

2.56.24

3.56.23

4.0056.236


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

0x35 | 0x75

1.115

2.116

3.117

4.118


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

4^12

1.2

2. 4

3.8

4.12


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

int(1011)?

1.1011

2.11

3. 13

4. 1101


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

~100?

1.101

2. -101

3.100

4.-100


Question:
What will be the value of x in the following Python expression, if the result of that expression is 2?

x>>2

1. 8

2.4

3.2

4.1


Question:
Which of the following Boolean expressions is not logically equivalent to the other three?

1.not(-6<0 or-6>10)

2.-6>=0 and -6<=10

3.not(-6<10 or-6==10)

4.not(-6>10 or-6==10)


Question:
Which of the following expressions can be used to multiply a given number ‘a’ by 4?

1. a<<2

2. a<<4

3. a>>2

4. a>>4


Question:
Which of the following expressions results in an error?

1.int(1011)

2. int(‘1011’,23)

3. int(1011,2)

4.int(‘1011’)


Question:
Which of the following formatting options can be used in order to add ‘n’ blank spaces after a given string ‘S’?

1.print(“-ns”%S)

2. print(“-ns”%S)

3.print(“%ns”%S)

4. print(“%-ns”%S)


Question:
Which of the following represents the bitwise XOR operator?

1.&

2. ^

3. |

4. !


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
  51. Python MCQ Questions with Answer
  52. Python Practice Papers
  53. python mcq question and answer
  54. Test
Learn Python Mcq Set 2,Learn Python Objetive choice questions and answers,Python Multiple choice questions and answers,Python objective, Python questions , Python answers,Python MCQs questions and answer
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!