Multiple choice quiz about Python - Part 6

To help readers add to their knowledge of Python's built-in functions, the Network Administrator will send you multiple choice questions on this topic. Please try.
  1. Question 1: Which of the following functions is a built-in function in Python
    1. seed ()
    2. sqrt ()
    3. factorial ()
    4. print ()
    Explanation: seed () is a random module function, sqrt () and factorial () of the math module and print () is a built-in function that prints a value directly at the system output.
  2. Question 2: What is the result of the following expression?
     round(4.576) 
    1. 4.5
    2. 5
    3. 4
    4. 4.6
    Explanation: round () is a built-in function to round decimal numbers. The above expression does not specify the decimal place to be rounded up so the default program rounds to an integer, so the output here is 5.
  3. Question 3: The function pow (x, y, z) is interpreted as:
    1. (x ** y) ** z
    2. (x ** y) / z
    3. (x ** y)% z
    4. (x ** y) * z
    Explanation: The built-in function pow () can have two or three parameters. If pow () has only two parameters, they are interpreted as (x ** y), and in the case of three parameters, the result is (x ** y)% z.
  4. Question 4: What is the result of the following function?
     all([2,4,0,6]) 
    1. Lỗi
    2. True
    3. False
    4. 0
    Explanation: The all () function returns False when one of the iterable elements is 0 and returns True if they are different from 0. Therefore the output of this expression is False.
  5. Question 5: What is the result of the following expression?
     round(4.5676,2) 
    1. 4.5
    2. 4.6
    3. 4.57
    4. 4.56
    Explanation: The round () function is used to round the decimal point to the specified decimal place. In this case, the number must be rounded to two decimal places so the output will be 4.57.
  6. Question 6: What is the output of the following function?
     any([2>8, 4>2, 1>2]) 
    1. Lỗi
    2. True
    3. False
    4. 4> 2
    Explanation: Any () function returns True if any element of an iterable is True (different from 0). If no True element is present, any () function will return False.
  7. Question 7: What is the output of the representation function below?
     import math 
    abs(math.sqrt(25))
    1. Lỗi
    2. -5
    3. 5
    4. 5.0
    Explanation: The abs () function returns the absolute value of the passed argument. For example: abs (-5) = 5. Therefore, in this case, abs (5.0) = 5.0.
  8. Question 8: What are the results of the function shown below?
     sum(2,4,6) 
    sum([1,2,3])
    1. Error, 6
    2. 12, Error
    3. 12, 6
    4. Lỗi, Lỗi
    Explanation: The first function will have an error because sum () is used to find the sum of iterable numbers. Therefore, the result will be Error and 6 respectively.
  9. Question 9: Output of the following function is:
     all(3,0,4.2) 
    1. True
    2. False
    3. Lỗi
    4. 0
    Explanation: The all () function returns True when iterable elements are different from zero. In the above case, the values ​​are not iterable, so an error will occur.
  10. Question 10: What is the result of the following expression?
     min(max(False,-3,-4), 2,7) 
    1. 2
    2. False
    3. -3
    4. -4
    Explanation: The max () function is used to find the maximum value in three values ​​-3, -4 and false. 'false' is treated as a value of 0, so the other expression is min (0, 2, 7), so the result will be 0 (false)
4.3 ★ | 12 Vote