Computer Science, asked by reddyarchitha01, 4 months ago

if(print("hello")):
print("hi")
else:
print("bye")
Find the output of the above Program?
Select one or more:
A. Syntax Error
B. hello
hi
C. hello
bye
D. hi​

Answers

Answered by yoyomohinisharma
4

Answer:

C. Hello And Bye

.

..............

....

Answered by MotiSani
0

The output of the code:

if(print("hello")):

   print("hi")

else:

   print("bye")

hello

bye

Hence C is correct.

  • In the first statement in the given code block, print statement is written inside if, so print statement is executed first and "hello" is printed.
  • print function in python always return an empty line after its execution.
  • Empty line equivalents to false, so the condition inside if evaluates to false.
  • Since the condition inside if evaluates to false, else block is executed.
  • Inside else block, we have a print statement, which is executed, and "bye" is printed.
  • Hence, the output of the given code is:

        hello

        bye

        Hence, option C is correct.

#SPJ3

Similar questions