题目
题目

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道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!