Daje naj
Podaj przykłady operatorów logicznych w Pythonie.



Odpowiedź :

Odpowiedź:

# Operatory logiczne

# and

x,y=1,2

if x<10 and y>=2:

    print("%d is lower than 10 and %d is greater or equal 2" %(x,y))

# or

x,y=9,10

if x<10 or y<10:

    print("x or y is lower than 10")

# in

x = 44

if x in [1,2,3,4,5]:

    print("x is in the list")

else:

    print("x is outside the list")

# not in

x = 4

if x not in [1,2,3,4,5]:

    print("x is not in the list")

else:

    print("x is in the list")    

# is / is not

x, y = 1,2

print(x is y)

print(x is not y)

not

print(not False)

print(not True)

Inne Pytanie