题目
ICS3U - Donnelly - S3 Unit 3 Online Quiz
单项选择题
3. Given the following function def nPrint(message, n): while n > 0: print(message) n -= 1 What is k after invoking nPrint("A message", k)? k = 2 nPrint(n = k, message = "A message") A. 0 B. 1 C. 2 D. 3
查看解析
标准答案
Please login to view
思路分析
The question presents a function nPrint(message, n) that loops while n > 0, printing the message and then decrementing n by 1.
We are then asked what value k has after calling nPrint(n = k, message = "A message"). The key details are:
- The function uses a parameter n as the loop counter, which is a local variable within the function scope.
-......Login to view full explanation登录即可查看完整答案
我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。
类似问题
Given the following code snippet, what is considered an argument(s)?def mystery(num1, num2) : result = num1 ** num2 return resultmystery(10, 2)
Given the following code snippet, what is considered an argument(s)? def mystery(num1, num2) : result = num1 ** num2 return result mystery(10, 2)
A list cannot be passed as an argument to a function.
Which one of the following statements about inbuilt functions and arguments is true?
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!