# Python/Python Mcq Set 2 Sample Test,Sample questions

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)

1.â€˜1â€™

2. â€˜1.234â€™

3.â€˜1.23â€™

4.â€˜1.2â€™

1.â€˜1â€™

2. â€˜1.234â€™

3.â€˜1.23â€™

4.â€˜1.2â€™

1. -000122

2.000122

3.â€“00122

4.-00122

1.â€˜0b10111â€™

2.â€˜0b11101â€™

3.â€˜0b11111â€™

4.â€˜0b11011â€™

1. 0b10000

2.0b10001000

3.0b1000b1000

4.0b10000b1000

1. 10

2.2

3.1

4. 0

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

1.first, right

2.second, left

3.first, left

4.second, right

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)

1.â€˜0bx1000â€™

2. 8

3.1000

4. â€˜0b1000â€™

1.10 20

2.10 10

3. 20 10

4.20 20

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

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â€™

1.00000hi

2.000hi

3.hi000

4. error

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

1.t

2.f

3.No output

4.error control

1.34.00

2.34.0000

3.34.000000

4.34.00000000

1.b1101

2.0b1101

3.12

4. 1101

1.22.1900

2.22.00000

3. 22.19

4.22.20

1. 345000

2.000345

3.000000345

4. 345000000

1.000456

2.456000

3. 456

4. error

1.56.00

2.56.24

3.56.23

4.0056.236

1.115

2.116

3.117

4.118

1.2

2. 4

3.8

4.12

1.1011

2.11

3. 13

4. 1101

1.101

2. -101

3.100

4.-100

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)

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)

1.&

2. ^

3. |

4. !

## More MCQS

##### Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite 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!