Question:

Analyze the following code fragments that assign a boolean value to the variable even?

number = 202
#Code1 
if number % 2 == 0:
    even = True
else: 
    even = False
print ("Code1: even := {}".format(even))

#Code2
even = True if number % 2 == 0 else False
print ("Code2: even := {}".format(even))

#Code3
even = number % 2 == 0
print ("Code3: even := {}".format(even))

Answers:


Keywords:

© 2017 QuizBucket.org