Select Page

ABIOLA RASP – Raspberries for African School Projects

Wie können wir helfen?

< Alle Themen
Print

Python – Boolean “true” and “false”

no-170 au-03

Boolean

Boolean represents one of two value: True or False. In Python, Boolean variables are defined by the True and False keywords.

Please see the article “Python – First Program” how to open Thonny Python IDE and how to save your work.

  1. x is assigned True
  2. y is assigned False
  3. If x is True, prints “x is True”, else prints “x is False”
  4. If y is True, prints “y is True”, else prints “y is False”
  5. Click Run button.
  6. Here is the result.

Code:
x = True
y = False

if x:     
print(“x is True”)
else:   
print(“x is False”)     

if y:   
print(“y is True”)
else:   
print(“y is False”)

Inhaltsverzeichnis