빅데이터/파이썬
파이썬 문법 간단하게 훑고 가기(if / indent / in / input / and or not)
메이져드컴싸
2020. 12. 30. 19:35
#If(조건문)
if 1 == 2 :
print('hello')
elif 1 < 2 :
print('hi')
else :
print('oh')
if / elif(else if) / else
#indent
파이썬에서 들어쓰기 할 때는 같은 방식으로 해줘야함
if 1 == 2 :
print('hello')
print('hi')
이런 식으로 2번째 줄에서는 Tab을 그 아래 줄에는 Space를 하면 오류가 난다.
#in
if 'hello' in 'hello world' :
print('hello')
'hello world' 라는 string에 'hello'가 들어 있냐는 뜻
#input
name = input('What is your name?')
print(name)
input을 통해서 입력 받을 수 있다.
#논리 연산자
and
=> True and True 일때만 True 나머지는 False
or
=> False or False 일때만 False 나머지는 True
not
=> not True이면 False / not False 이면 True