Multiple choice quiz about Python - Part 9

How much do you know about Python functions? Keep testing your knowledge with Quantrimang through the following multiple choice questions!
  1. Question 1: Choose the right answer: Which statements are correct when talking about Python functions?
    1. The function can be reused in the program.
    2. Using functions has no positive impact on modules in the program.
    3. Cannot create own program writers' functions.
    4. All of the above answers are correct.
  2. Question 2: Which keyword is used to start the function?
    1. Fun
    2. Define
    3. Def
    4. Function
  3. Question 3: What is the output of the program below?
     def sayHello(): 
    print('Hello World!')
    sayHello()
    sayHello()
    1. Hello World!
      Hello World!
    2. 'Hello World!'
      'Hello World!'
    3. Hello
      Hello
    4. There is no right answer
  4. Question 4: What is the output of the program below?
     def printMax(a, b): 
    if a > b:
    print(a, 'is maximum')
    elif a == b:
    print(a, 'is equal to', b)
    else:
    print(b, 'is maximum')
    printMax(3, 4)
    1. 3
    2. 4
    3. 4 is maximum
    4. There is no right answer
  5. Question 5: What is the output of the program below?
     x = 50 
    def func(x):
    print('Giá trị của x là', x)
    x = 2
    print('Giá trị của x được thay đổi thành', x)
    func(x)
    print('Giá trị hiện tại của x là', x)
    1. The current value of x is 50
    2. The current value of x is 100
    3. The current value of x is 2
    4. There is no right answer
  6. Question 6: What is the output of the program below?
     x = 50 
    def func():
    global x
    print('Giá trị của x là', x)
    x = 2
    print('Giá trị của x được thay đổi thành', x)
    func()
    print('Giá trị hiện tại của x là', x)
    1. The value of x is 50
      The value of x is changed to 2
      The current value of x is 50
    2. The value of x is 50
      The value of x is changed to 2
      The current value of x is 2
    3. The value of x is 50
      The value of x is changed to 50
      The current value of x is 50
    4. There is no right answer
  7. Question 7: What is the output of the program below?
     def say(message, times = 1): 
    print(message * times)
    say('Hello')
    say('World', 5)
    1. Hello
      WorldWorldWorldWorldWorld
    2. Hello
      World 5
    3. Hello
      World, World, World, World, World
    4. Hello
      HelloHelloHelloHelloHello
  8. Question 8: What is the output of the program below?
     def func(a, b=5, c=10): 
    print('a bằng', a, 'và b bằng', b, 'và c bằng', c)
     func(3, 7) 
    func(25, c = 24)
    func(c = 50, a = 100)
    1. a equals 7 and b equals 3 and c equals 10
      a equals 25 and b equals 5 and c equals 24
      a equals 5 and b equals 100 and c equals 50
    2. a equals 3 and b equals 7 and c equals 10
      a equals 5 and b equals 25 and c equals 24
      a equals 50 and b equals 100 and c equals 5
    3. a equals 3 and b equals 7 and c equals 10
      a equals 25 and b equals 5 and c equals 24
      a equals 100 and b equals 5 and c equals 50
    4. There is no right answer
  9. Question 9: What is the output of the program below?
     def maximum(x, y): 
    if x > y:
    return x
    elif x == y:
    return 'Các số bằng nhau'
    else:
    return y
     print(maximum(2, 3)) 
    1. 2
    2. 3
    3. The numbers are equal
    4. There is no right answer
  10. Question 10: Choose the correct answer: Which statement is correct when talking about Docstring in Python?
    1. Docstring is the first string immediately after the function title
    2. Docstring is optional but should be in a function
    3. Docstring is accessed by the __doc__ attribute on the object
    4. All of the above answers are correct.
4 ★ | 7 Vote