4.3 비교하기

color = 'puce'
if color == 'red':
print("It's a tomato")
elif color == "green":
print("It's a green pepper")
elif color == "bee purple":
print("i don't know what it is, but only bees can see it")
else:
print("I've never heard of the color", color)

I’ve never heard of the color puce

x = 7
print(x == 5)
print(x == 7)
print(x > 5)
print(x < 10)

False True True True

print(5 < x and x < 10)
print((5 < x) and (x < 10))

True True

print(5 < x or x < 10)
print(5 < x and x > 10)
print(5 < x and not x > 10)

True False True

5 < x < 10

True

5 < x < 10 < 999

True

4.3.1

some_list = []
if some_list:
print("There's something in here")
else:
print("hey, it's empty!")

hey, it’s empty!

Comments