Computer Science
What will be the output of following program ?
def display():
print("Hello", end='')
display()
print("there!")
Python
Python Functions
7 Likes
Answer
Hellothere!
Working
The function display prints "Hello" without a newline due to the end='' parameter. When called, it prints "Hello". Outside the function, "there!" is printed on the same line due to the absence of a newline.
Answered By
2 Likes
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 following program ?
num = 1 def myfunc(): global num num = 10 return num print(num) print(myfunc()) print(num)
Predict the output of the following code :
a = 10 y = 5 def myfunc(): y = a a = 2 print("y =", y, "a =", a) print("a + y =", a + y) return a + y print("y =", y, "a =", a) print(myfunc()) print("y =", y, "a =", a)
What is wrong with the following function definition ?
def addEm(x, y, z): return x + y + z print("the answer is", x + y + z)