Skip navigation
What is the output of following Python code?
0:00 / 0:30

What is the output of following Python code?

Python Coding

@clcoding656K followers

Visit on X
324 likesDownloadOriginal post

64,938 views

What is the output of following Python code?

10 Comments

Comments from the original post on X (Twitter)

  • JobFocus Services's profile picture

    @JobFocuService

    Indent error

    21 likes

  • Prem Prakash's profile picture

    @4EverPrem

    Wow!. As soon as if condition is met, it will break out of remaining checks & print wow!. If order is changed x = 1 if x < 2: print('Wow again!') elif x == 1: print('Wow!') else: print('No wow!'), result is Wow again!for the reason explained earlier.

    15 likes

  • CodingNerds COG's profile picture

    @CodingnerdsCog

    The correct answer would be 'A', as the execution of the if statement would occur and then immediately exit the if loop. Consequently, the answer is 'A'.

    12 likes

  • Coffee N Code's profile picture

    @coffeencode3000

    Indentation is important in Python.

    10 likes

  • .m0rph 👽's profile picture

    @m0rphisto

    If the indentation was correct, then it would print WOW, but like this, it gives an error. I had my experiences with that. :-D

    5 likes

  • Robert Rees's profile picture

    @RobertR67944613

    B If x =1 And if x is less than 2 It would be B ( wow again) I’m only new so that’s my thinking

    2 likes

  • Gauresh Alai's profile picture

    @GaureshAlai

    A. Wow! As in first condition met i.e x==1. So,the program ends there and the output is (Wow!)

    2 likes

  • Rajnish🇮🇳's profile picture

    @ganeshh__patel

    A

    2 likes

  • Tomaz Kastrun (tomaz@fosstodon.org)'s profile picture

    @tomaz_tsql

    IndentationError in Python world :)> Also in Python world with indentation A. Breaks w/ first TRUE.

    1 like

  • Shibli Hasan's profile picture

    @ShibliHasa1995

    A