Sail E0 Webinar

MCQs

Total Questions : 18 | Page 2 of 2 pages
Question 11. What is the output of the following?def to_upper(k):    k.upper()x = ['ab', 'cd']print(list(map(to_upper, x)))
  1.    ['AB', 'CD'].
  2.    ['ab', 'cd'].
  3.    none of the mentioned
  4.    error
 Discuss Question
Answer: Option C. -> none of the mentioned


A list of Nones is printed as to_upper() returns None.


Question 12. What is the output of the following code, if the time module has already been imported?def num(m): t1 = time.time() for i in range(0,m): print(i) t2 = time.time() print(str(t2-t1))     num(3)
  1.    123The time taken for the execution of the code
  2.    3The time taken for the execution of the code
  3.    123UTC time
  4.    3UTC time
 Discuss Question
Answer: Option A. -> 123The time taken for the execution of the code


The code shown above will return the numbers 1, 2, 3, followed by the time taken in the execution of the code. Hence option (a) shows the output correctly.


Question 13. What is the output of the code shown below?l=[-2, 4]m=map(lambda x:x*2, l)print(m)
  1.    [-4, 16]
  2.    Address of m
  3.    Error
  4.    -416
 Discuss Question
Answer: Option B. -> Address of m


The code shown above returns the address of m. Had we used the statement: print(list(m)), the output would have been: [-4, 16].


Question 14. Is the output of the function abs() the same as that of the function math.fabs()?
  1.    sometimes
  2.    always
  3.    never
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> sometimes


math.fabs() always returns a float and does not work with complex numbers whereas the return type of abs() is determined by the type of value that is passed to it.


Question 15. What is the output of the following?x = abcdprint(list(map(list, x)))
  1.    ['a', 'b', 'c', 'd'].
  2.    ['abcd'].
  3.    [['a'], ['b'], ['c'], ['d']].
  4.    none of the mentioned
 Discuss Question
Answer: Option D. -> none of the mentioned


NameError, we have not defined abcd.


Question 16. What is the default base used when math.log(x) is found?
  1.    e
  2.    10
  3.    2
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> e


The natural log of x is returned by default.


Question 17. What is returned by math.isfinite(float('nan'))?
  1.    True
  2.    False
  3.    None
  4.    error
 Discuss Question
Answer: Option B. -> False


float('nan') is not a finite number.


Question 18. What does os.getlogin() return?
  1.    name of the current user logged in
  2.    name of the superuser
  3.    gets a form to login as a different user
  4.    all of the above
 Discuss Question
Answer: Option A. -> name of the current user logged in


It returns the name of the user who is currently logged in and is running the script.


Latest Videos

Latest Test Papers