Home / CSE MCQs / Python MCQs :: Discussion

Discussion :: Python MCQs

  1. What is the output of the code shown?

    x=3.3456789
    '%f | %e | %g' %(x, x, x)
  2. 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'

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    The %f %e and %g format specifiers represent floating point numbers in different ways. %e and %E are the same, except that the exponent is in lowercase. %g chooses the format by number content. Hence the output of this code is: '3.345679 | 3.345679e+00 | 3.34568'.


Be The First To Comment