Q:

Python program for not None test

0

Example:

Here, we have 3 variables ab and ca is being assigned with "Hello"b is being assigned with "None" and c is being assigned with 10.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

We are testing whether variables have a value or None, if they have values, we are printing their values.

# python code for not None test

# variable 1 with value
a = "Hello"

# variable 2 with None
b = None

# variable 3 with value 
c = 10

# performing is not None test 
if a is not None:
    print("value of a: ", a)
else:
    print("\'a\' contains None")

if b is not None:
    print("value of b: ", b)    
else:
    print("\'b\' contains None")

if c is not None:
    print("value of c: ", c)
else:
    print("\'c\' contains None")

Output

value of a:  Hello
'b' contains None
value of c:  10

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now