Similar Collections


    No collections found

questions

Title
What is the output of the code snippet shown below

What is the output of the code snippet shown below?

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

  1. 00000hi
  2. 000hi
  3. hi000
  4. Error
discuss
Consider the snippet of code shown below and predict the output

Consider the snippet of code shown below and predict the output.

X=”compsci-bits”
print(“%56s”,X)

  1. 56 blank spaces before compsci-bits
  2. 56 blank spaces before compsci and bits
  3. 56 blank spaces after compsci-bits
  4. no change
discuss
What is the output of the following expression if x=456

What is the output of the following expression if x=456?

print("%-06d"%x)

  1. 000456
  2. 456000
  3. 456
  4. error
discuss
What is the output of the following expression if X=345

What is the output of the following expression if X=345?

print(“%06d”%X)

  1. 345000
  2. 000345
  3. 000000345
  4. 345000000
discuss
Which of the following formatting options can be used in order to add ‘n’ blank spaces after a given string ‘S’

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)
discuss
What is the output of this expression if X= -122

What is the output of this expression if X= -122?

print("-%06d"%x)

  1. -000122
  2. 000122
  3. –00122
  4. -00122
discuss
What is the output of the following expression if the value of x is 34

What is the output of the following expression if the value of x is 34?

print(“%f”%x)

  1. 34.00
  2. 34.0000
  3. 34.000000
  4. 34.00000000
discuss
What is the result of the expression shown below if x=56.236

What is the result of the expression shown below if x=56.236?

print("%.2f"%x)

  1. 56.00
  2. 56.24
  3. 56.23
  4. 0056.236
discuss
What is the output of this expression if x=22.19

What is the output of this expression if x=22.19?

print("%5.2f"%x)

  1. 22.1900
  2. 22.00000
  3. 22.19
  4. 22.20
discuss
State true or false

The expression shown below results in an error. 

print("-%5d0",989)

  1. True
  2. False
  3. May be
  4. Can't Say
discuss
The output of the snippet of code shown below is

The output of the snippet of code shown below is:

 '%d %s %g you' %(1, 'hello', 4.0)

  1. Error
  2. 1 hello you 4.0
  3. 1 hello 4 you
  4. 1 4 hello you
discuss
The output of which of the codes shown below will be: “There are 4 blue birds.”

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
discuss
What is the output of the code shown below if the system date is 18th August, 2016

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

  1. ‘integers:…1234…1234 …001234’
  2. ‘integers…1234…1234…123400’
  3. ‘integers:… 1234…1234…001234’
  4. ‘integers:…1234…1234…001234’
discuss
What is the output of the code shown

What is the output of the code shown?

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’
discuss
What is the output of the code shown below

What is the output of the code shown below?

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+’
discuss
What is the output of the code shown

What is the output of the code shown?

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

  1. Error
  2. (‘3.3456789’, ‘3.3456789’)
  3. (3.3456789, 3.3456789)
  4. (‘3.3456789’, 3.3456789)
discuss
What is the output of the code shown

What is the output of the code shown?

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

  1. Error
  2. No output
  3. ‘1 more foods’
  4. ‘1 more spam’
discuss
What is the output of the code shown

What is the output of the code shown?

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
discuss
The output of the code shown below is

The output of the code shown below is:

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
discuss
What is the output of the code shown

What is the output of the code shown?

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

  1. mumbai kolkata & delhi
  2. Error
  3. No output
  4. ‘mumbai, kolkata & delhi’
discuss
total MCQs: 51

MCQs

51

Views

200

Best Answers

299

Points

5