alternative
  • Home (current)
  • About
  • Tutorial
    Technologies
    C#
    Deep Learning
    Statistics for AIML
    Natural Language Processing
    Machine Learning
    SQL -Structured Query Language
    Python
    Ethical Hacking
    Placement Preparation
    Quantitative Aptitude
    View All Tutorial
  • Quiz
    C#
    SQL -Structured Query Language
    Quantitative Aptitude
    Java
    View All Quiz Course
  • Q & A
    C#
    Quantitative Aptitude
    Java
    View All Q & A course
  • Programs
  • Articles
    Identity And Access Management
    Artificial Intelligence & Machine Learning Project
    How to publish your local website on github pages with a custom domain name?
    How to download and install Xampp on Window Operating System ?
    How To Download And Install MySql Workbench
    How to install Pycharm ?
    How to install Python ?
    How to download and install Visual Studio IDE taking an example of C# (C Sharp)
    View All Post
  • Tools
    Program Compiler
    Sql Compiler
    Replace Multiple Text
    Meta Data From Multiple Url
  • Contact
  • User
    Login
    Register

Python - Datatype - None & Boolean Tutorial

None Datatype

None Keyword is used to define null value. It is a datatype of class 'NoneType' Object. It is not the same as Zero, False, or an empty String.

For example-

x=None
y=None

print(type(x))
print(type(y))

print(id(x))
print(id(y))

Output-

<class 'NoneType'>
<class 'NoneType'>
139650864453248
139650864453248

 

When we assign a variable with a value None, we are resetting the variable to its original state. Any variable assigned with a value None will have the same identity, i.e they point to the same object.

Boolean Datatype

Boolean Datatype is used to define the truth value of an expression. It is represented with one of the two values i.e True or False. We can evaluate values and expressions using the python bool() function.

False & True is a datatype of class bool.

print('Printing type of False & True')
f1=False
t1=True
print(type(f1))
print(type(t1))

Output-

Printing type of False & True
<class 'bool'>
<class 'bool'

Condition on which variable of a different datatype is represented as True or False.

  • In integer 0 is False, rest all integer value is True
  • In float 0.0 is False, rest all float value is True
  • In String, only empty string is False
  • In complex 0+0j is False, rest all complex value is True
  • Variable with value None is also a False
  • Empty List, empty tuple, empty dictionary, empty set are false and rest all are True

For example-

print('Value whose boolean type is False')
f1=None
f2=0
f3=0.0
f4=""
f5=0+0j

print(bool(f1))
print(bool(f2))
print(bool(f3))
print(bool(f4))
print(bool(f5))

print('Value whose boolean type is True')
#In integer 0 is False, rest all integer value is True
t1=-1
t2=2

#In float 0.0 is False, rest all float value is True
t3=3.4

#In String , only empty string is False
t4='fresherbell'

#In complex 0+0j is False, rest all complex value is True
t5=0+3j
t6=1+5j

print(bool(t1))
print(bool(t2))
print(bool(t3))
print(bool(t4))
print(bool(t5))
print(bool(t6))

Output-

Value whose boolean type is False
False
False
False
False
False
Value whose boolean type is True
True
True
True
True
True
True

 

Python

Python

  • Introduction
  • Installation and running a first python program
    • How to install Python ?
    • Running 1st Hello World Python Program
    • How to install Pycharm ?
  • Things to know before proceed
    • Escape Characters/Special Characters
    • Syntax ( Indentation, Comments )
    • Variable
    • Datatype
    • Keyword
    • Literals
    • Operator
    • Precedence & Associativity Of Operator
    • Identifiers
    • Ascii, Binary, Octal, Hexadecimal
    • TypeCasting
    • Input, Output Function and Formatting
  • Decision control and looping statement
    • if-else
    • for loop
    • While loop
    • Break Statement
    • Continue Statement
    • Pass Statement
  • Datatype
    • Number
    • List
    • Tuple
    • Dictionary
    • String
    • Set
    • None & Boolean
  • String Method
    • capitalize()
    • upper()
    • lower()
    • swapcase()
    • casefold()
    • count()
    • center()
    • endswith()
    • split()
    • rsplit()
    • title()
    • strip()
    • lstrip()
    • rstrip()
    • find()
    • index()
    • format()
    • encode()
    • expandtabs()
    • format_map()
    • join()
    • ljust()
    • rjust()
    • maketrans()
    • partition()
    • rpartition()
    • translate()
    • splitlines()
    • zfill()
    • isalpha()
    • isalnum()
    • isdecimal()
    • isdigit()
    • isidentifier()
    • islower()
    • isupper()
    • isnumeric()
    • isprintable()
    • isspace()
    • istitle()
  • Python Function
    • Introduction
  • Lambda Function
    • Lambda Function
  • Python Advanced
    • Iterators
    • Module
    • File Handling
    • Exceptional Handling
    • RegEx - Regular Expression
    • Numpy
    • Pandas

About Fresherbell

Best learning portal that provides you great learning experience of various technologies with modern compilation tools and technique

Important Links

Don't hesitate to give us a call or send us a contact form message

Terms & Conditions
Privacy Policy
Contact Us

Social Media

© Untitled. All rights reserved. Demo Images: Unsplash. Design: HTML5 UP.

Toggle