Aside: If you've programmed in certain other languages (like Java or C++), you might be noticing some things Python doesn't require us to do here:
we don't need to "declare" spam_amount before assigning to it
we don't need to tell Python what type of value spam_amount is going > to refer to. In fact, we can even go on to reassign spam_amount to > refer to a different sort of thing like a string or a boolean.
spam_amount = 0
print(spam_amount)
# Ordering Spam, egg, Spam, Spam, bacon and Spam (4 more servings of Spam)
spam_amount = spam_amount + 4
if spam_amount > 0:
print("But I don't want ANY spam!")
viking_song = "Spam " * spam_amount
print(viking_song)
Operator | Name | Description |
---|---|---|
a + b | Addition | Sum of a and b |
a - b | Subtraction | Difference of a and b |
a * b | Multiplication | Product of a and b |
a / b | True division | Quotient of a and b |
a//b | Floor division | Quotient of a and b, removing fractional parts |
a % b | Modulus | Integer remainder after division of a by b |
a ** b | Exponentiation | a raised to the power of b |
-a | Negation | The negative of a |
One interesting observation here is that, whereas your calculator probably just has one button for division, Python can do two kinds. "True division" is basically what your calculator does:
Min and Max
They return the mimimum and maximum of their arguments.
print(min(1, 2, 3))
print(max(1, 2, 3))
<Result>
1
3
arithmetic[U] 산수, 연산
encounter[VN] We encountered a number of difficulties in the first week.
conditional expression, ternary operator 조건 연산자, 삼항 연산자
binary 2진법
ternary 3진법
decimal 10진법
duodecimal 12진법
be prized 소중하게 여겨지다.
readability[U] 읽기 쉬움
simplicity[U] 간단함
curly braces 중괄호
accustomed 익숙한(익숙하게 하다)
multiply 곱하다(증식, 번식 시키다)
integer(int)
proportion [C]부분, (전체에서 차지하는)비율 [U]비(비율)
portion 나누기(몫), 1인분, 나누다
homage [U,C] 경의, 존경의 표시 The kings of France paid homage to no one.
removing fractional parts 소수 부분 제거
demystify 이해하기 쉽게 해 주다, 분명히 설명해 주다
straightforward(a) 간단한, 쉬운, 솔직한