Conditional Statements Questions and Answers

Take Exam

Python Programming - Conditional Statements Questions with Answers help understand how decisions are made in code. These Python Conditional Statements Questions are vital for RRB, TCS, and SSC exams focusing on logical flow

Conditional Statements

Showing 10 of 25 questions

11. Which of these checks if a number is between 1 and 10 inclusive?

  • if 1 <= num <= 10:
  • if num >= 1 and num <= 10:
  • if num in range(1, 11):
  • All of the above
Show Answer Report

12. What will be the output of: x = 0; if x: print("Yes") else: print("No")

  • Yes
  • No
  • Error
  • 0
Show Answer Report

13. Which operator has the highest precedence in conditional expressions?

  • and
  • or
  • not
  • ()
Show Answer Report

14. What is the purpose of nested if statements?

  • To create loops
  • To check conditions within other conditions
  • To handle exceptions
  • To define functions
Show Answer Report

15. What will be the output of: x = "hello"; if x: print("Yes") else: print("No")

  • Yes
  • No
  • Error
  • hello
Show Answer Report

16. Which of these is NOT a valid way to check if a list is empty?

  • if not my_list:
  • if len(my_list) == 0:
  • if my_list == []:
  • if my_list == False:
Show Answer Report

17. What does the "pass" keyword do in an if statement?

  • Skips to the next condition
  • Does nothing, used as placeholder
  • Terminates the program
  • Continues to next iteration
Show Answer Report

18. What will be the output of: x = 10; if x > 5 and x < 15: print("In range")

  • In range
  • No output
  • Error
  • True
Show Answer Report

19. Which of these is the correct syntax for if-elif-else?

  • if-elseif-else
  • if-else if-else
  • if-elif-else
  • if-elsif-else
Show Answer Report

20. What is short-circuit evaluation in conditional expressions?

  • Using short variable names
  • Evaluating only until result is determined
  • Skipping else clauses
  • Using ternary operators
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test