The answer is B. The condition 4 > 4
evaluates to False
, while the conditions 4 == 4
and 4 <= 4
both evaluate to True
. However because in our code the program would meet elif 4 == 4
first, it would execute the body contained in that branch. A program can only follow one branch in a conditional statement.
a = 5
b = 5.1
if abs(b - a) < 0.1 * abs(a):
print('True')
else:
print('False')
If you may have a different order of a
and b
from you neighbour then you may see different results with certain pairs of values.
vowels = 'aeiouAEIOU'
sentence = 'Mary had a little lamb.'
count = 0
for char in sentence:
if char in vowels:
count += 1
print("The number of vowels in this string is " + str(count))
.