Zoom
  • Take a look at this example.
  • Notice how we are now combining conditional operators and If-statements.
  • Since conditional operators always evaluate to True or False, they are perfect for using in If-statements.
  • Run through this code and notice what happens at line 5.
  • black_number < cream_number will evaluate to True, so line 6 will be executed.
  • Now pay close attention to the variable data types on line 8. Notice that total_number is a String.
  • Since total_number is a String, the expression will evaluate to False.