💻
Albert's Til
GitHub
  • 매일매일 조금씩 성장하기
    • README
    • CS
      • Network
      • HTTP
        • NO-CACHE
      • 오류 코드
      • ORM 도구
      • Design Pattern
        • CQRS Pattern
          • Event Sourcing and CQRS pattern
        • Builder Pattern
    • DB
      • MySQL
        • Timeline
        • Pagination
        • Index
        • Database Performance Optimization Strategies
        • B+ tree
        • MySQL Connectors VS MySQL Shell(Scripting) VS MySQL Workbench
        • MySQL Storage Engine Architecture
      • Normalization & Denormalization
      • JPA
        • @Transactional
        • Why JPA?
        • About JPA
        • N+1 Issue
        • Index
        • ElementCollection&CollectionTable
        • orphanRemoval
        • CascadeType
        • Use Subselect
        • Dynamic Instance Creation
        • Paging
        • Order
        • Spefication
        • mappedBy
      • MongoDB
        • ObjectId
      • Why MySQL?
      • ACID properties of transactions
      • Between JPA and JDBC
      • Identifiers in Hibernate/JPA
    • Java
      • Jackson de/serialize
      • Collections.singletonList() vs List.of()
      • Manage dependencies in Gradle
      • Logging Level
      • Bean Validation
      • JVM Internals
        • Threads
          • Frame
        • Shared Between Threads
          • Classloader
            • Class Loader Hierarchy
            • Loading Linking Initialization
      • Java Collection Framework
      • Annotation
      • Generic
      • 디미터 법칙
    • Spring
      • Caching
      • Spring Integration Overview
        • ThreadPollTaskExecutor
        • Messaging Bridge
        • Channel Adapter
        • Poller
        • Configuration and @EnableIntegration
        • Message Endpoints
        • Message Channels
      • HATEOAS
      • @Autowired vs Constructor Dependency Injection
      • Spring Security
        • JWT 토큰 사용한 인가
        • OAuth 2 Login
        • OAuth 2 인증
        • 인가
        • 인증
        • PasswordEncoder
      • IoC Container
      • Filter,Interceptor,AOP,Argument Resolver
      • Spring Annotation
      • About Spring
    • Kafka
      • Error Channel
    • Infra
      • Scale Up || Scale Out
      • Docker
        • Dockerfile
        • Docker Hub Deploy
        • Command
      • Cloud 유형
        • Infrastructure as a Service
        • Platform as a Service
        • Software as a Service
      • 무중단 배포
        • 엔진엑스(Nginx)
      • 코드 자동 배포
        • Technical
      • AWS EC2
        • PEM(Privacy Enhanced Mail) 키
      • AWS RDS
      • AWS S3
    • CodeSquad
      • Spring Boot Project 1주차 회고
      • Spring Boot Project 2주차 회고
      • Spirng Boot Project 3주차 회고
      • Spring Boot Project 4주차 회고
    • Foody Moody 프로젝트
      • Query Performance Comparison
      • HeartCount Asynchronous Issue
      • DeferredResult
      • ResponseBodyEmitter
      • SseEmitter (Spring)
      • Server-Sent Events (SSE)
      • 기술 스택 적용 이유
      • NO-CACHE(HTTP)
      • Transactional
    • DDD
      • AggregateId
    • Test
      • RestAssured
    • Coding and Algorithmic Problems
      • 819. Most Common Word
      • 344. Reverse String
      • 125. Valid Palindrome
      • 937. Reorder Data in Log Files
    • Node
      • Async... Await...
      • Custom Transactional Decorator Challenger
    • Python
      • Python Basic Grammar
        • Comments and Input/Output
        • Variable
        • Data type
        • Operations and syntax
        • List,Tuple,Dictionary,Set
        • Function
        • Conditional statement
        • Loop
    • HTML
      • HTML Basic
      • HTML Basic Tags
      • HTML Form Tags
      • HTML Table Tags
    • CSS
      • CSS Basic
      • CSS Practice
Powered by GitBook
On this page
  • 조건문이란?
  • 삼항 연산자
  • match
  • if 조건문에서 참(True)과 거짓(False)으로 평가되는 다양한 표현식
  • 참조

Was this helpful?

  1. 매일매일 조금씩 성장하기
  2. Python
  3. Python Basic Grammar

Conditional statement

조건문

조건문이란?

조건문은 주어진 조건이 참(true)인지 거짓(false)인지를 평가한다.

if 조건:
    # 코드
elif 조건:
    # 코드
else:
    # 코드

삼항 연산자

X if 조건 else Y # 참이면 X, 거짓이면 Y

match

mactch 문법은 Python에 없는 switch처럼 사용한다.

match x:
    case 조건:
        # 코드
    case 조건:
        # 코드
    case _: # _ 는 와일드 카드로, 어떤 값과도 일치한다는 것을 나타낸다.
        # 코드

if 조건문에서 참(True)과 거짓(False)으로 평가되는 다양한 표현식

자료형
참(True)
거짓(False)

정수 (int)

0이 아닌 모든 값 (1, -1, 42, -99)

0

부동소수점 (float)

0.0이 아닌 모든 값 (0.1, -0.1, 3.14, -3.14)

0.0

복소수 (complex)

0이 아닌 모든 값 (1+1j, -1-1j, 2+0j)

0j

문자열 (str)

비어 있지 않은 문자열 ("hello", " ", "0")

빈 문자열 ("")

리스트 (list)

비어 있지 않은 리스트 ([1, 2, 3], [None], [0])

빈 리스트 ([])

튜플 (tuple)

비어 있지 않은 튜플 ((1, 2, 3), (None,), (0,))

빈 튜플 (())

셋 (set)

비어 있지 않은 셋 ({1, 2, 3}, {None}, {0})

빈 셋 (set())

딕셔너리 (dict)

비어 있지 않은 딕셔너리 ({"key": "value"}, {0: "zero"})

빈 딕셔너리 ({})

None

-

None

사용자 정의 객체

기본적으로 True, __bool__() 메서드가 True를 반환하거나

__bool__() 메서드가 False를 반환하거나

__len__() 메서드가 0이 아닌 값을 반환하는 경우

__len__() 메서드가 0을 반환하는 경우

불리언 (bool)

True

False

범위 (range)

요소가 있는 범위 (range(1), range(10))

요소가 없는 범위 (range(0), range(0, 0))

이터레이터 및 제너레이터

항목이 있는 경우 (iter([1, 2, 3]), 제너레이터가 항목을 생성할 때)

항목이 없는 경우 (iter([]), 제너레이터가 항목을 생성하지 않을 때)

참조

ChatGPT

Last updated 11 months ago

Was this helpful?

견고한 파이썬
https://www.geeksforgeeks.org/python-functions/