Skip to Content
Head First Python, 개정판 : 스스로 질문하며 답을 찾는 파이썬 학습서(Python 3)
book

Head First Python, 개정판 : 스스로 질문하며 답을 찾는 파이썬 학습서(Python 3)

by 우정은, 폴 배리
December 2017
Beginner
624 pages
15h 38m
Korean
Hanbit Media, Inc.
Content preview from Head First Python, 개정판 : 스스로 질문하며 답을 찾는 파이썬 학습서(Python 3)
지금 여기예요
4
57
기초
‘if’ 문에서 ‘else’는 어떻게 사용되나요?
예제 프로그램에서 대부분의 코드를 분석했고 이제 코드 한 행만 더 분석하면 됩니다.
아주 긴 행의 코드는 아니지만 매우 중요합니다.
if
문이
False
값을 반환하면
실행되는
else
문으로,
else
문에 속한 코드 스위트가 실행됩니다.
우리 프로그램 코드에서
else
문을 좀 더 자세히 살펴보겠습니다.
else
문은
if
문의
위치와 같아야 하며 따라서 들여쓰기 하지 않습니다.
if right_this_minute in odds:
print("This minute seems a little odd.")
else:
print("Not an odd minute.")
콜론 보이시죠?
‘else’가 있다면 ‘else if’도 있어야
할 것 같은데, 파이썬에서는 이를
‘elseif’라고 하나요?
둘 다 아니에요. 파이썬에서는 elif라고 합니다.
파이썬에서
if
문으로 여러 가지 조건을 확인해야 하는
경우
else
외에
elif
도 사용할 수 있습니다.
elif
필요한 만큼 사용할 수 있어요.
다음은 간단한 예제로,
today
라는 변수에 입력되는
조건(요일)에 따라 그날의 상황을 표현하는 미리 지정된
문자열을 출력합니다.
if today == 'Saturday':
print(' ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’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
QuotationMarkI 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
QuotationMarkI’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
QuotationMarkI'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.
Mark W.
Embedded Software Engineer

You might also like

NGINX 쿡북 : 112가지 레시피로 배우는 고성능 부하분산, 보안, 서버 배포와 관리

NGINX 쿡북 : 112가지 레시피로 배우는 고성능 부하분산, 보안, 서버 배포와 관리

노승현, 데릭 디용기
몽고DB 완벽 가이드(3판): 실전 예제로 배우는 NoSQL 데이터베이스 기초부터 활용까지

몽고DB 완벽 가이드(3판): 실전 예제로 배우는 NoSQL 데이터베이스 기초부터 활용까지

김인범, 크리스티나 초도로우, 섀넌 브래드쇼, 오언 브라질

Publisher Resources

ISBN: 9791162240281