Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Python Workshop
Logo
Python Workshop
  • Agenda
  • Introduction
  • Tooling
  • Python Features
    • Python is a scripting language
    • Python comes with rich and powerful libraries
    • Python uses indentation instead of curly braces to structure code
    • Python supports functional and object oriented programming
    • Python variables are typeless
  • Python Basics
    • The Simplest Python Script
    • Run Code in the Python Interpreter Directly
    • Variables
    • Types
      • None
      • Boolean
      • Numbers
      • Strings and Bytes
      • Tuples
      • Lists
      • Dict
  • Python In Depth
    • Strings
      • Defining a string
      • Concatenating
      • Built in functionality
      • Length
      • Index access
      • Slicing
      • f-Strings
    • Lists
      • Concatenating
      • Append
      • Insert
      • Pop
      • Length
      • Index access
      • Slicing
      • Deleting
    • Dicts
      • Getting an item
      • Adding and updating items
      • Deleting an item
      • Keys
      • Values
      • Items
    • Functions
      • Functions with Arguments
      • Functions with Keyword Arguments
      • Functions with default Arguments
      • Functions have return values
      • Functions with requiring Arguments as Keywords
    • Control Structures
      • Conditionals
        • Boolean Operators
        • not Operator
        • in Operator
        • if Statement
        • if/else Statement
        • if/elif/else Statement
      • While Loop
      • For Loop
        • List Sequence
        • Tuple Sequence
        • String Sequence
        • While Example Simplified
    • Classes
      • Class Variables
      • Everything in Python is a class
      • Instances of Classes
      • Constructors
      • Methods
      • Methods (2)
      • Class Example
      • Adding Class Inheritance
      • Extending the Example
      • More (unreal) Example
      • Last bot not least Example
      • Python’s Special Methods
      • Summary
    • Modules and Packages
      • Modules
      • Packages
  • Next
Back to top
View this page
Edit this page

Conditionals¶

Python uses boolean logic to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.

Example:

x = 2

print(x == 2)  # prints out True
print(x == 3)  # prints out False
print(x != 3)  # prints out True
print(x < 3)  # prints out True

Next:

  • Boolean Operators
  • not Operator
  • in Operator
  • if Statement
  • if/else Statement
  • if/elif/else Statement
Next
Boolean Operators
Previous
Control Structures
Copyright © 2025, Björn Ricks
Made with Sphinx and @pradyunsg's Furo