Conditional Statements and Operators in Python Python Interpreted Language Python is an interpreted language This means that the code is executed line by line It does not need to be compiled before execution Binary and Interpretation Not covered in these notes Dictionaries and Data Structures Not covered in these notes Print Statements in Python Not covered in these notes Loops and Jump Statements Not covered in these notes Lists and Functions Not covered in these notes Conditional Statements and Operators Conditional Statements if statement elif statement else statement Used to test if a condition is true code to be executed if condition is true if statement Syntax if condition elif statement Syntax if condition1 Used to test if a condition is true if the previous conditions were not Used to specify a block of code to be executed if all previous conditions were false code to be executed if condition1 is true elif condition2 code to be executed if condition1 is false and condition2 is true code to be executed if all conditions were false else else statement Syntax if condition1 else code to be executed if condition1 is true code to be executed if condition1 is false Conditional Operators and operator or operator not operator and operator Syntax if condition1 and condition2 or operator Syntax if condition1 or condition2 not operator Syntax Returns True if both operands are true code to be executed if both condition1 and condition2 are true Returns True if at least one of the operands is true code to be executed if condition1 or condition2 is true Returns True if the operand is false
View Full Document