Knowledge Base‎ > ‎Programming‎ > ‎Python‎ > ‎Python Reference‎ > ‎

boolean


Related:

 Examples

 
 
student = True
graduated = False

 Description        

 
Creates a variables with the value of True. Booleans can only be True or False. They may then be used in if statements and other places where expressions are used.

 Syntax

 
 
name = value

 Parameters

 
name - a legal variable name (must start with a letter, and can have numbers and underscores in them)

value - the value to store in the variable, either True or False

 Interpreter

Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> student = True

>>> type(student)

<type 'bool'>

>>> if student:

...   print "hey, you're a student!"

...

hey, you're a student!




Comments