🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित पायथन कोड का आउटपुट क्या होगा?

What will be the output of the following Python code ?

def say(message, times = 1):
        print(message * times)
say('Hello')
say('World', 5)
A)
B)
C)
D)

Explanation:

The correct answer is:

(A) Hello WorldWorldWorldWorldWorld

Explanation:

  • In the function say(message, times=1), the default value for times is 1.
  • When say('Hello') is called, it prints the message 'Hello' only once because times is defaulted to 1.
  • When say('World', 5) is called, the message 'World' is printed 5 times because the times parameter is explicitly set to 5.

Output:

(A) Hello WorldWorldWorldWorldWorld

Latest Updates