Monday, 27 May 2019

bool data type

4. bool

Ex:
a=True
b=False
c=true # Error because it is not bool data type and we gave lower case letter 't'
d=false #Error because we gave lower case letter 'f'
type(a) # Find the type of a
output:
<class 'bool'>


We can use this data type to represent Boolean (True/False) values. It only allows True or False
Internally Python stores True as 1 and False as 0 (Zero) in the memory.

Example:

b=True
type(b)->bool

Ex2:
 a=10
 b=20
 c=a>b
 print(c)

"""output"""
False

5. None Data type:

In python, None means nothing or No value associated. The ‘None’ datatype represents an object that doesn’t contain any value. In java/c it is called ‘null’. It is used for as a default value.

Where do we use None data type?
If the value is not available, then to handle such type of situation None is used.

Example program on None
def ex():
   a=10

print(ex())
 None

Youtube channel click here to see this video

Next Topic:      None data type
Previous Topic: Python Numbers

No comments:

Post a Comment

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(...