If Else in Python MCQs Exercise II


Ques 1 If Else


What is the output of the following Python Code?

p=1
q=2
if(p!=q) and (print("Hello")):
    print("scoder")
else:
    print("hello")

  a) Hello scoder
  b) hello
  c) scoder
  d) Hello hello


d is the correct option





Ques 2 If Else


What is the correct syntax for an if statement in Python?
  a) if x > y: print(x)
  b) if (x > y) { print(x) }
  c) if x > y then print(x)
  d) if x > y; print(x)


a is the correct option





Ques 3 If Else


Can an if statement in Python be used without an else?
  a) Yes
  b) No
  c) Only with elif
  d) None of these


a is the correct option