🚀 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 display(b, n):
          while n>0:
print(b, end=””)
  n=n-1
    display(‘z’, 3)
A)
B)
C)
D)

Explanation:

Let's break down the code:

def display(b, n):
    while n > 0:
        print(b, end="")
        n = n - 1

display('z', 3)
  1. Function call: display('z', 3)
    • b = 'z' and n = 3.
  2. While loop: The loop runs while n > 0. In each iteration:
    • It prints b (which is 'z').

    • Decreases n by 1.

    • First iteration: n = 3, print 'z', n becomes 2.

    • Second iteration: n = 2, print 'z', n becomes 1.

    • Third iteration: n = 1, print 'z', n becomes 0. The loop stops.

So, the output will be 'zzz'.

Answer: (A) zzz

Latest Updates