Computer Science
What will be the output of the following program?
def display():
print ("Hello",)
display()
print("bye!")
Answer
Hello
bye!
Working
def display():— This line defines a function nameddisplaywith no parameters.print("Hello",)— Inside thedisplayfunction, it prints the string "Hello".display()— This line calls thedisplayfunction, which then prints "Hello" due to the print statement inside the function.print("bye!")— This line prints "bye!" on a new line.
Related Questions
What will be the output of following program ?
num = 1 def myfunc(): num = 10 return num print(num) print(myfunc()) print(num)What will be the output of the following program?
num = 1 def myfunc(): global num num = 10 print (num) print (myfunc()) print (num)What is wrong with the following function definition ?
def addEm(x, y, z): return x + y + z print("the answer is", x + y + z)Predict the output of the following code:
a = 10 y = 5 def myfunc (a) : y = a a = 2 print ("y=",y, "a=", a) print ("a+y", a + y) return a + y print ("y=",y, "a=", a) print (myfunc (a)) print ("y=", y, "a=", a)