What is the two’s complement of -44?
1. 1011011
2. 11010100
3.11101011
4.10110011
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)
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’
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’
What will be the output of the following Python expression if X = -122? print("-%06d"%x)
1. -000122
2.000122
3.–00122
4.-00122
What will be the output of the following Python expression? bin(29)
1.‘0b10111’
2.‘0b11101’
3.‘0b11111’
4.‘0b11011’
What will be the value of the following Python expression? bin(10-2)+bin(12^4)
1. 0b10000
2.0b10001000
3.0b1000b1000
4.0b10000b1000
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
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
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
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
The one’s complement of 110010101 is:
1.001101010
2.110010101
3.001101011
4.110010100
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
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)
What is the value of the following Python expression? bin(0x8)
1.‘0bx1000’
2. 8
3.1000
4. ‘0b1000’
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
What will be the output of the following Python code snippet if x=1? x<<2
1. 8
2. 1
3. 2
4. 4
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’
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
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
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+’
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’
What will be the output of the following Python code snippet? X=â€hi†print(“05dâ€%X)
1.00000hi
2.000hi
3.hi000
4. error
What will be the output of the following Python code snippet? ['hello', 'morning'][bool('')]
1. error
2.no output
3.hello
4.morning
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
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
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]’
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’
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
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’]
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’
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
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
What will be the output of the following Python code? ['f', 't'][bool('spam')]
1.t
2.f
3.No output
4.error control
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
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
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
What will be the output of the following Python expression if X=345? print(“%06dâ€%X)
1. 345000
2.000345
3.000000345
4. 345000000
What will be the output of the following Python expression if x=456? print("%-06d"%x)
1.000456
2.456000
3. 456
4. error
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
What will be the output of the following Python expression? 0x35 | 0x75
1.115
2.116
3.117
4.118
What will be the output of the following Python expression? 4^12
1.2
2. 4
3.8
4.12
What will be the output of the following Python expression? int(1011)?
1.1011
2.11
3. 13
4. 1101
What will be the output of the following Python expression? ~100?
1.101
2. -101
3.100
4.-100
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
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)
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
Which of the following expressions results in an error?
1.int(1011)
2. int(‘1011’,23)
3. int(1011,2)
4.int(‘1011’)
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)
Which of the following represents the bitwise XOR operator?
1.&
2. ^
3. |
4. !