Ex 01
result1 - 5 까지의 값을 출력하는 코드를 작성하고, 그 결과값을 comment로 기재하라.
a = 15
b = 4
result1 = a + b
result2 = a - b
result3 = a * b
result4 = a / b
result5 = a // b
Ex 02
result1 - 3 까지의 값을 출력하는 코드를 작성하고, 그 결과값을 comment로 기재하라.
a = 17
b = 5
result1 = a % b
result2 = a ** 2
result3 = b ** 3
Ex 03
최종 x의 값은?
x = 10
x += 5
x *= 2
x //= 3
x %= 4
Ex 04
result의 값은?
result = 2 + 3 * 4 ** 2 - 8 / 4
Ex 05
result1-4 의 데이터 타입과 값을 출력하는 코드를 작성하고, 그 결과값을 comment로 기재하라.
a = 5
b = 2.5
result1 = a + b
result2 = a * b
result3 = a / b
result4 = int(a / b)
Ex 06
result값을 구해볼 것.
a = 27
b = -5
c = -13
d = -b
step1 = a % b # 27 % -5
step2 = b % c # -5 % -13
step3 = c % d # -13 % 5
result = step1 + step2 + step3
같이 보면 좋은 자료
https://dsaint31.tistory.com/516
[Python] Arithmetic in Python and Augmented Assignment
1. Precedence of Arithmetic OperationsHigher ** > -(negation) > * = / = // = % > + = -(subtraction) Lower우선순위를 기억하는 것도 중요하지만, 헷갈리면 그냥 parentheses로 묶어주면 된다. (가독성을 위해서도
dsaint31.tistory.com
'Python' 카테고리의 다른 글
[Py] Bitwise Operator (0) | 2025.03.26 |
---|---|
[Py] 객체(object)에 대한 정보 확인하기 (0) | 2025.03.19 |
[PyTorch] dtype 단축메서드로 바꾸기 (0) | 2025.03.14 |
[PyTorch] in-place 연산이란? (0) | 2025.03.13 |
[PyTorch] flattenning - Tensor's methods (0) | 2025.03.13 |