파이썬[Python]: keyword - not 키워드

내장함수 - not 키워드(keyword)


/// 설명

논리값을 부정합니다.(참->거짓, 거짓->참)

※ 형식
not

reference
https://docs.python.org/3/reference/expressions.html#not

/// 예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
= True
print(a)  # True
print(not a)  # False
 
= 'string'
print(b)  # string
print(not b)  # False
print(not not b)  # True
 
= ''
print(c)  #
print(not c)  # True
print(not not c)  # False
 
= 1
print(d)  # 1
print(not d)  # False
 
if b is not c:
    print('b is string')  # b is string
else:
    print('empty')
 
print('b is string' if b is not c else 'empty')  # b is string
 
print('s' in 'string')  # True
print('s' not in 'string')  # False
 
print('In' if 's' in 'string' else 'None')  # In
print('None' if 's' not in 'string' else 'In')  # In
 
cs

* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)


– 당신을 응원합니다. –

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

파이썬[Python]: 내장함수 - bit_length 메서드

C 언어: sin 함수, cos 함수, tan 함수