Questions
Questions

ICS3U - Donnelly - S3 Unit 3 Online Quiz

Single choice

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

View Explanation

View Explanation

Verified Answer
Please login to view
Step-by-Step Analysis
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

Log in for full answers

We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!