Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Boolean variables in Python

Boolean variable can hold either True or False, and the type ‘bool’ represents a Boolean type.

 

Example

is_raining = True
is_raining = False

Please note that the first letter starts with capital case where T in True, F in False

 

boolean_variables.py

is_raining = True

if is_raining:
    print('It is raining')
else:
    print('It is not raining')

is_raining = False

if is_raining:
    print('It is raining')
else:
    print('It is not raining')


print('type of is_raining : ', type(is_raining))

In the above example, we define a variable ‘is_raining’ to specify whether it is raining or not.

 


Output

It is raining
It is not raining
type of is_raining :  


 

 

Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Boolean variables in Python

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×