Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 주피터노트북그래프
- 주피터노트북판다스
- 파이썬차트
- 파이썬알고리즘
- 팀플기록
- sql연습하기
- python수업
- sql연습
- 판다스그래프
- python알고리즘
- 데이터분석시각화
- 파이썬데이터분석주피터노트북
- 수업기록
- SQL
- 파이썬수업
- 파이썬
- SQL수업
- 파이썬크롤링
- 주피터노트북맷플롯립
- sql따라하기
- SQLSCOTT
- matplotlib
- 맷플롯립
- 주피터노트북
- python데이터분석
- 주피터노트북데이터분석
- 파이썬시각화
- Python
- 판다스데이터분석
- 파이썬데이터분석
Archives
- Today
- Total
IT_developers
Python 개념 및 실습 - 연산자 본문
# 산술 연산자 : +, -, *, /(실수), //(정수), %, **
a,b = 5,3
print(a+b,a-b,a*b,a/b,a//b,a%b,a**b)
s1, s2, s3 = "100","100.123","999999999"
print(s1+s2+s3) # + : 연결 => 100100.123999999999 문자로 인식
print(float(s1) +float(s2)+float(s3)) # 형변환 후 연산
# str + int는 안해줌. print(s1+1) =>TypeError: can only concatenate str (not "int") to str
print(int(s1)+1)
# 복합대입연산자 : +=, -+, *=, /=, //=, %=,**=
a = 10
a += 5
print("a",a)
a == 5
print("a",a)
a *= 5
print("a",a)
a /= 5
print("a",a)
a //= 5
print("a",a)
a %= 5
print("a",a)
a **= 5
print("a",a)
# 실습
# 화폐교환 : 777,777원을 5만원/1만원/5천원/1천원
money = 777777
m50000 = money // 50000
money %= 50000
m10000 = money // 10000
money %= 10000
m5000 = money // 5000
money %= 5000
m1000 = money // 1000
money %= 1000
print("50,000원 : %d 장" % m50000)
print("10,000원 : %d 장" % m10000)
print("5,000원 : %d 장" % m5000)
print("1,000원 : %d 장" % m1000)
print("나머지 돈 : %d" % money)
# 관계연산자 : ==, !=, >, <, >=, <=
a,b = 10,0
print(a==b, a!=b, a>b, a<b, a>=b, a<=b)
# 논리연산자 : and, or, not 기호 사용 불가
print(100 > 60 and 60 > 15)
# print(100 > 60 && 60 > 15) 사용 불가
print(100 > 60 or 60 < 15)
print(not 60 < 15)
print(not False)
print(not True)
#print(!True) 사용불가
# 비트연산자
print(10 & 7) # 2
print(10 | 7) # 15
print((100> 60) & (60 > 15)) # True & True => True
'Python' 카테고리의 다른 글
Python 개념 및 실습 - while (0) | 2022.09.03 |
---|---|
Python 개념 및 실습 - input (0) | 2022.09.03 |
Python 개념 및 실습 - escape, 변수 (0) | 2022.09.02 |
Python 개념 및 실습 - print(), format() (0) | 2022.09.01 |
Python 시작하기 (0) | 2022.09.01 |
Comments