๐Ÿ“—
JunegLee's TIL
  • TIL
  • python
    • class
    • String Basic
    • regularExpression
    • String function
    • Generator
    • String format
    • getset
    • module
    • while
    • numpy
    • print()
    • matplotlib
    • for
    • Boolean
    • tuple
    • package
    • input(variable)
    • list
    • if
    • file
    • type()
    • pandas
    • function
    • dictionary
    • ๊ตฌ๋ฌธ ์˜ค๋ฅ˜์™€ ์˜ˆ์™ธ
    • builtinFunction
    • Constructor
  • algorithm
    • sort
      • mergeSort
      • insertionSort
      • bubbleSort
      • heapSort
      • quickSort
      • selectionSort
    • recursion
    • Greedy
    • DepthFirstSearch
    • basic
      • DataStructure
    • hash
    • BreadthFirstSearch
  • tensorflow
    • keras
      • layers
        • Flatten
        • Flatten
        • Dense
        • Dense
        • Conv2D
        • Conv2D
    • tensorflow1x
    • tensorflow2x
  • DB
    • setting
    • join
    • subQuery
    • overview
  • deep-learning
    • neuralNetwork
    • perceptron
    • neuralNetworkLearning
    • convolution neural network
    • Gradient Descent
    • Linear Regression
    • backPropagation
    • logistic regression
    • overview
  • textPreprocessing
    • overview
  • java
    • basics
      • generic
      • Variable
      • String
    • theory
      • Object Oriented Programing
  • NLP
    • Embedding
    • Natural Language Processing
Powered by GitBook
On this page
  • Boolean
  • ๋ถˆ ๋งŒ๋“ค๊ธฐ : ๋น„๊ต ์—ฐ์‚ฐ์ž
  • ๋ถˆ ์—ฐ์‚ฐํ•˜๊ธฐ : ๋…ผ๋ฆฌ ์—ฐ์‚ฐ์ž (and ์™€ or )
  • x in s, x not in s

Was this helpful?

  1. python

Boolean

Boolean

๋ถˆ ๋งŒ๋“ค๊ธฐ : ๋น„๊ต ์—ฐ์‚ฐ์ž

print(10 == 100) # False
print(10 != 100) # True
print(10 < 100) # True
print(10 > 100) # False
print(10 <= 100) # True
print(10 >= 100) # False
print("๊ฐ€๋ฐฉ" == "ํ•˜๋งˆ") # True
print("๊ฐ€๋ฐฉ" != "ํ•˜๋งˆ") # True
print("๊ฐ€๋ฐฉ" < "ํ•˜๋งˆ") # True
# ์‚ฌ์ „ ์ˆœ์„œ๋กœ ๊ฐ€๋ฐฉ์ด ํ•˜๋งˆ๋ณด๋‹ค ์•ž์— ์žˆ์œผ๋ฏ€๋กœ ์ž‘์€ ๊ฐ’์„ ๊ฐ–๋Š”๋‹ค.
print("๊ฐ€๋ฐฉ" > "ํ•˜๋งˆ") # False

๋ถˆ ์—ฐ์‚ฐํ•˜๊ธฐ : ๋…ผ๋ฆฌ ์—ฐ์‚ฐ์ž (and ์™€ or )

  • and : a์™€ b True ์ผ ๋•Œ๋งŒ True ์ด๋‹ค

    a

    b

    x

    0

    0

    0

    0

    1

    0

    1

    0

    0

    1

    1

    1

    print(True and True) #True 
    print(True and False) #False
    print(False and True) #False
    print(False and False) #False
  • or : a์™€ b๊ฐ€ ํ•˜๋‚˜๋ผ๋„ True๋ผ๋ฉด True์ด๋‹ค

    a

    b

    x

    0

    0

    0

    0

    1

    1

    1

    0

    1

    1

    1

    1

    print(True or True) #True 
    print(True or False) #True
    print(False or True) #True
    print(False or False) #False

x in s, x not in s

in

not in

x in ๋ฆฌ์ŠคํŠธ

x not in ๋ฆฌ์ŠคํŠธ

x in ํŠœํ”Œ

x not in ํŠœํ”Œ

x in ๋ฌธ์ž์—ด

x not in ๋ฌธ์ž์—ด

  • in์˜ ๋œป์ธ "~์•ˆ์—"๋ผ๋Š” ๊ฒƒ ์ฒ˜๋Ÿผ ์•ˆ์— ์žˆ๋Š” ๋ฌธ์žฅ์ธ์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค

>>> 1 in [1, 2, 3]
True
>>> 1 not in [1, 2, 3]
False

>>> 'a' in ('a', 'b', 'c')
True
>>> 'j' not in 'python'
True
PreviousforNexttuple

Last updated 3 years ago

Was this helpful?