이게 무슨 일이야!

[Python] 조건문, 반복문 본문

파이썬 데이터분석/Python

[Python] 조건문, 반복문

명동섞어찌개 2020. 10. 2. 17:10

1. 조건문

if 3 > 5:
    print('if 구문')
elif 3 > 4:
    print('elif 1 구문')
else:
    print('이것도 저것도 아니다')
    
    
# && 연산자    
if (0 < 1) and (0 < 2):
    print('모두 참')
else:
    print('거짓')
    
    
# || 연산자
if (10 < 1) or ( 1 < 0):
    print('하나라도 참')
else:
    print('둘다 아님')
    

 

 

2. 반복문

mylist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

for i in mylist:
    print(i)

 

 

3. 함수 정의

def my_func(a, b, c):
    return (a + b) * c

'파이썬 데이터분석 > Python' 카테고리의 다른 글

[Python] Boolean Indexcing  (0) 2020.10.02
[Python] 문자열 관련 함수  (0) 2020.10.02
[Python] List Comprehension  (0) 2020.09.13
Comments