

MCQOPTIONS
Saved Bookmarks
This section includes 1007 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
901. |
What is the output of the code shown below? '%s' %((1.23,),) |
A. | ‘(1.23,)’ |
B. | 1.23, |
C. | (,1.23) |
D. | ‘1.23’ |
Answer» B. 1.23, | |
902. |
What is the output of the code shown below? '%.2f%s' % (1.2345, 99) |
A. | ‘1.2345’, ‘99’ |
B. | ‘1.2399’ |
C. | ‘1.234599’ |
D. | 1.23, 99 |
Answer» C. ‘1.234599’ | |
903. |
The output of the code shown below is: '{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456) |
A. | Error |
B. | ‘1.234560, 1.22345, 1.23’ |
C. | No output |
D. | ‘1.234560, 1.234560, 01.23’ |
Answer» E. | |
904. |
What is the output of the code shown below? 'The {} side {1} {2}'.format('bright', 'of', 'life') |
A. | Error |
B. | ‘The bright side of life’ |
C. | ‘The {bright} side {of} {life}’ |
D. | No output |
Answer» B. ‘The bright side of life’ | |
905. |
What is the output of the code shown below? D=dict(p='san', q='foundry') '{p}{q}'.format(**D) |
A. | Error |
B. | sanfoundry |
C. | san foundry |
D. | {‘san’, ‘foundry’} |
Answer» C. san foundry | |
906. |
What is the output of the code shown below? '{a}{b}{a}'.format(a='hello', b='world') |
A. | ‘hello world’ |
B. | ‘hello’ ‘world’ ‘hello’ |
C. | ‘helloworldhello’ |
D. | ‘hello’ ‘hello’ ‘world’ |
Answer» D. ‘hello’ ‘hello’ ‘world’ | |
907. |
What is the output of the following code? hex(255), int('FF', 16), 0xFF |
A. | [0xFF, 255, 16, 255] |
B. | (‘0xff’, 155, 16, 255) |
C. | Error |
D. | (‘0xff’, 255, 255) |
Answer» E. | |
908. |
Fill in the blanks: The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field. |
A. | first, right |
B. | second, left |
C. | first, left |
D. | second, right |
Answer» C. first, left | |
909. |
What is the output of the code shown below? l=list('HELLO') p=l[0], l[-1], l[1:3] 'a={0}, b={1}, c={2}'.format(*p) |
A. | Error |
B. | “a=’H’, b=’O’, c=(E, L)” |
C. | “a=H, b=O, c=[‘E’, ‘L’]” |
D. | Junk value |
Answer» D. Junk value | |
910. |
What is the output of the code shown? l=list('HELLO') 'first={0[0]}, third={0[2]}'.format(l) |
A. | ‘first=H, third=L’ |
B. | ‘first=0, third=2’ |
C. | Error |
D. | ‘first=0, third=L’ |
Answer» B. ‘first=0, third=2’ | |
911. |
What is the output of the code shown below? '{0:.2f}'.format(1.234) |
A. | ‘ff, 255’ |
B. | 255, 255’ |
C. | ‘15f, 15f’ |
D. | Error |
Answer» B. 255, 255’ | |
912. |
What is the output of the code shown? '{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2]) |
A. | Error |
B. | ‘2.5, 10, [1, 2]’ |
C. | 2.5, 10, 1, 2 |
D. | 10, 2.5, [1, 2]’ |
Answer» C. 2.5, 10, 1, 2 | |
913. |
What is the output of the code shown below? t = '%(a)s, %(b)s, %(c)s' t % dict(a='hello', b='world', c='universe') |
A. | hello, world, universe’ |
B. | ‘hellos, worlds, universes’ |
C. | Error |
D. | hellos, world, universe |
Answer» B. ‘hellos, worlds, universes’ | |
914. |
What is the output of the code shown? s='%s, %s & %s' s%('mumbai', 'kolkata', 'delhi') |
A. | mumbai kolkata & delhi |
B. | Error |
C. | No output |
D. | mumbai, kolkata & delhi’ |
Answer» E. | |
915. |
The output of the code shown below is: s='{0}, {1}, and {2}' s.format('hello', 'good', 'morning') |
A. | hello good and morning’ |
B. | ‘hello, good, morning’ |
C. | hello, good, and morning’ |
D. | Error |
Answer» D. Error | |
916. |
What is the output of the code shown? a='hello' q=10 vars() |
A. | {‘a’ : ‘hello’, ‘q’ : 10, ……..plus built-in names set by Python….} |
B. | {……Built in names set by Python……} |
C. | {‘a’ : ‘hello’, ‘q’ : 10} |
D. | Error |
Answer» B. {……Built in names set by Python……} | |
917. |
What is the output of the code shown? x=3.3456789 '%s' %x, str(x) |
A. | Error |
B. | (‘3.3456789’, ‘3.3456789’) |
C. | (3.3456789, 3.3456789) |
D. | (‘3.3456789’, 3.3456789) |
Answer» C. (3.3456789, 3.3456789) | |
918. |
What is the output of the code shown below? x=3.3456789 '%-6.2f | %05.2f | %+06.1f' %(x, x, x) |
A. | ‘3.35 | 03.35 | +003.3’ |
B. | ‘3.3456789 | 03.3456789 | +03.3456789’ |
C. | Error |
D. | ‘3.34 | 03.34 | 03.34+’ |
Answer» B. ‘3.3456789 | 03.3456789 | +03.3456789’ | |
919. |
What is the output of the code shown? x=3.3456789 '%f | %e | %g' %(x, x, x) |
A. | Error |
B. | ‘3.3456789 | 3.3456789+00 | 3.345678 |
C. | 3.345678 | 3.345678e+0 | 3.345678’ |
D. | 3.345679 | 3.345679e+00 | 3.34568’ |
Answer» E. | |
920. |
What is the output of the code shown below if the system date is 18th August, 2016? x=1234 res='integers:...%d...%-6d...%06d' %(x, x, x) res |
A. | ‘integers:…1234…1234 …001234’ |
B. | ‘integers…1234…1234…123400’ |
C. | integers:… 1234…1234…001234’ |
D. | ‘integers:…1234…1234…001234’ |
Answer» B. ‘integers…1234…1234…123400’ | |
921. |
The output of which of the codes shown below will be: “There are 4 blue birds.”? |
A. | There are %g %d birds.’ %4 %blue |
B. | There are %d %s birds.’ %(4, blue) |
C. | ‘There are %s %d birds.’ %[4, blue] |
D. | There are %d %s birds.’ 4, blue |
Answer» C. ‘There are %s %d birds.’ %[4, blue] | |
922. |
The expression shown below results in an error. State whether this statement is true or false. print("-%5d0",989) |
A. | Error |
B. | 1 hello you 4.0 |
C. | 1 hello 4 you |
D. | 1 4 hello you |
Answer» D. 1 4 hello you | |
923. |
What is the output of this expression if x=22.19? print("%5.2f"%x) |
A. | 22.1900 |
B. | 22.00000 |
C. | 22.19 |
D. | 22.20 |
Answer» D. 22.20 | |
924. |
What is the result of the expression shown below if x=56.236? print("%.2f"%x) |
A. | 56.00 |
B. | 56.24 |
C. | 56.23 |
D. | 0056.236 |
Answer» C. 56.23 | |
925. |
What is the output of this expression if X= -122? print("-%06d"%x) |
A. | -000122 |
B. | 000122 |
C. | –00122 |
D. | -00122 |
Answer» D. -00122 | |
926. |
Which of the following formatting options can be used in order to add ‘n’ blank spaces after a given string ‘S’? |
A. | print(“-ns”%S) |
B. | print(“-ns”%S) |
C. | print(“%ns”%S) |
D. | print(“%-ns”%S) |
Answer» E. | |
927. |
What is the output of the following expression if X=345? print(“%06d”%X) |
A. | 345000 |
B. | 000345 |
C. | 000000345 |
D. | 345000000 |
Answer» C. 000000345 | |
928. |
What is the output of the following expression if x=456? print("%-06d"%x) |
A. | 000456 |
B. | 456000 |
C. | 456 |
D. | error |
Answer» E. | |
929. |
Consider the snippet of code shown below and predict the output. X=”san-foundry” print(“%56s”,X) |
A. | 56 blank spaces before san-foundry |
B. | 56 blank spaces before san and foundry |
C. | 56 blank spaces after san-foundry |
D. | no change |
Answer» B. 56 blank spaces before san and foundry | |
930. |
What is the output of the code snippet shown below? X=”hi” print(“05d”%X) |
A. | 00000hi |
B. | 000hi |
C. | hi000 |
D. | error |
Answer» E. | |
931. |
The output of the line of code shown below is: not(10<20) and not(10>30) |
A. | True |
B. | False |
C. | Error |
D. | No output |
Answer» C. Error | |
932. |
Which of the following Boolean expressions is not logically equivalent to the other three? |
A. | not(-6<0 or-6>10) |
B. | -6>=0 and -6<=10 |
C. | not(-6<10 or-6==10) |
D. | not(-6>10 or-6==10) |
Answer» E. | |
933. |
What is the output of the code shown below? if (9 < 0) and (0 < -9): print("hello") elif (9 > 0) or False: print("good") else: print("bad") |
A. | error |
B. | hello |
C. | good |
D. | bad |
Answer» D. bad | |
934. |
What is the output of the code shown below? l=[1, 0, 2, 0, 'hello', '', []] list(filter(bool, l)) |
A. | Error |
B. | [1, 0, 2, 0, ‘hello’, ”, []] |
C. | [1, 0, 2, ‘hello’, ”, []] |
D. | [1, 0, 2, ‘hello’, ”, []] |
Answer» E. | |
935. |
What is the output of the code shown? ['f', 't'][bool('spam')] |
A. | t |
B. | f |
C. | No output |
D. | Error |
Answer» B. f | |
936. |
What is the output of the code shown below? not(3>4) not(1&1) |
A. | True True |
B. | True False |
C. | False True |
D. | False False |
Answer» C. False True | |
937. |
What is the output of the snippet of code shown below? ['hello', 'morning'][bool('')] |
A. | error |
B. | no output |
C. | hello |
D. | morning |
Answer» D. morning | |
938. |
The output of the snippet of code shown below? bool(‘False’) bool() |
A. | True True |
B. | False True |
C. | False False |
D. | True False |
Answer» E. | |
939. |
What is the value of the expression: ~100? |
A. | 101 |
B. | -101 |
C. | 100 |
D. | -100 |
Answer» C. 100 | |
940. |
What is the two’s complement of -44? |
A. | 1011011 |
B. | 11010100 |
C. | 11101011 |
D. | 10110011 |
Answer» C. 11101011 | |
941. |
Which of the following expressions can be used to multiply a given number ‘a’ by 4? |
A. | a<<2 |
B. | a<<4 |
C. | a<<4 |
D. | a>>4 |
Answer» B. a<<4 | |
942. |
What is the value of this expression: bin(10-2)+bin(12^4) |
A. | 0b10000 |
B. | 0b10001000 |
C. | 0b1000b1000 |
D. | 0b10000b1000 |
Answer» E. | |
943. |
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. |
A. | 10 |
B. | 2 |
C. | 1 |
D. | 0 |
Answer» D. 0 | |
944. |
The result of the expression shown below is: 4^12 |
A. | 2 |
B. | 4 |
C. | 8 |
D. | 12 |
Answer» D. 12 | |
945. |
Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are 1. |
A. | OR |
B. | AND |
C. | XOR |
D. | NOT |
Answer» D. NOT | |
946. |
The one’s complement of 110010101 is: |
A. | The one’s complement of 110010101 is: |
B. | 110010101 |
C. | 001101011 |
D. | 110010100 |
Answer» B. 110010101 | |
947. |
What is the result of the expression: 0x35 | 0x75 |
A. | 115 |
B. | 116 |
C. | 117 |
D. | 118 |
Answer» D. 118 | |
948. |
What is the value of this expression? bin(0x8) |
A. | ‘0bx1000’ |
B. | 8 |
C. | 1000 |
D. | ‘0b1000’ |
Answer» E. | |
949. |
Which of the following represents the bitwise XOR operator? |
A. | & |
B. | ^ |
C. | | |
D. | ! |
Answer» C. | | |
950. |
What is the result of the expression if x=15 and y=12: x & y |
A. | b1101 |
B. | 0b1101 |
C. | 12 |
D. | 1101 |
Answer» D. 1101 | |