이 내용은 기본적이지만 중요합니다. 코드에서 괄호를 쓰지 않고 올바른 결과를 얻을 수 있더
라도, 복잡한 표현식에서는 괄호를 사용해 연산 순서를 제어하는 것이 좋습니다.
[예제
1
-
2
]는 표현식의 분수 부분을 괄호로 묶어 나머지 표현식과 구분했습니다.
예제
1-2
파이썬에서 괄호를 사용해 명확하게 표현하기
my_value =2*((3+2)**2/5)-4
print(my_value)# 6.0
두 예제 모두 기술적으로 맞지만, 연산 순서를 혼동하기 쉬운 사람에게는 후자가 더 명확합니
다. 괄호를 사용하면 자기 자신이나 다른 사람이 코드를 변경할 때 작업 순서를 쉽게 파악할 수
있습니다. 또한 코드를 변경할 때, 버그를 방지하는 데에도 도움이 됩니다.
1.3
변수
파이썬이나 다른 프로그래밍 언어로 스크립트를 작성해본 적이 있다면 변수가 무엇인지 알고
있을 것입니다. 수학에서
변수
variable ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.