Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Boolean data type | Conditional statements
Learn Python from Scratch
course content

Зміст курсу

Learn Python from Scratch

Learn Python from Scratch

1. The basics
2. Arithmetic operations
3. Common data types
4. Conditional statements
5. Other data types
6. Loops
7. Functions

Boolean data type

Another data type in Python - is boolean, or logical. It can take only 2 values - True or False or in terms of numbers 1 or 0 respectively. This data type is used when we need to check some logical condition and depends on that continue.

There are next logical operators you can use in comparison:

  • == equal
  • != not equal
  • > greater than
  • < less than
  • >= greater-equal than
  • <= less-equal than

While using these operators you will receive output as a boolean value: True if the condition holds or False otherwise. For example, let's check some expressions

123456
# check if 1 equals True print(1 == True) # check if "abc" equals "aBc" print("abc" == 'aBc') # check if 87*731 greater equal than 98*712 print(87*731 >= 98*712)
copy

Завдання

Check the following statements and print the respective result

  1. Is 2 not equal to False?
  2. Is 982*37 greater than 354*98?
  3. Is string "abcd" greater than "abc"?

Завдання

Check the following statements and print the respective result

  1. Is 2 not equal to False?
  2. Is 982*37 greater than 354*98?
  3. Is string "abcd" greater than "abc"?

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 4. Розділ 1
toggle bottom row

Boolean data type

Another data type in Python - is boolean, or logical. It can take only 2 values - True or False or in terms of numbers 1 or 0 respectively. This data type is used when we need to check some logical condition and depends on that continue.

There are next logical operators you can use in comparison:

  • == equal
  • != not equal
  • > greater than
  • < less than
  • >= greater-equal than
  • <= less-equal than

While using these operators you will receive output as a boolean value: True if the condition holds or False otherwise. For example, let's check some expressions

123456
# check if 1 equals True print(1 == True) # check if "abc" equals "aBc" print("abc" == 'aBc') # check if 87*731 greater equal than 98*712 print(87*731 >= 98*712)
copy

Завдання

Check the following statements and print the respective result

  1. Is 2 not equal to False?
  2. Is 982*37 greater than 354*98?
  3. Is string "abcd" greater than "abc"?

Завдання

Check the following statements and print the respective result

  1. Is 2 not equal to False?
  2. Is 982*37 greater than 354*98?
  3. Is string "abcd" greater than "abc"?

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 4. Розділ 1
toggle bottom row

Boolean data type

Another data type in Python - is boolean, or logical. It can take only 2 values - True or False or in terms of numbers 1 or 0 respectively. This data type is used when we need to check some logical condition and depends on that continue.

There are next logical operators you can use in comparison:

  • == equal
  • != not equal
  • > greater than
  • < less than
  • >= greater-equal than
  • <= less-equal than

While using these operators you will receive output as a boolean value: True if the condition holds or False otherwise. For example, let's check some expressions

123456
# check if 1 equals True print(1 == True) # check if "abc" equals "aBc" print("abc" == 'aBc') # check if 87*731 greater equal than 98*712 print(87*731 >= 98*712)
copy

Завдання

Check the following statements and print the respective result

  1. Is 2 not equal to False?
  2. Is 982*37 greater than 354*98?
  3. Is string "abcd" greater than "abc"?

Завдання

Check the following statements and print the respective result

  1. Is 2 not equal to False?
  2. Is 982*37 greater than 354*98?
  3. Is string "abcd" greater than "abc"?

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Another data type in Python - is boolean, or logical. It can take only 2 values - True or False or in terms of numbers 1 or 0 respectively. This data type is used when we need to check some logical condition and depends on that continue.

There are next logical operators you can use in comparison:

  • == equal
  • != not equal
  • > greater than
  • < less than
  • >= greater-equal than
  • <= less-equal than

While using these operators you will receive output as a boolean value: True if the condition holds or False otherwise. For example, let's check some expressions

123456
# check if 1 equals True print(1 == True) # check if "abc" equals "aBc" print("abc" == 'aBc') # check if 87*731 greater equal than 98*712 print(87*731 >= 98*712)
copy

Завдання

Check the following statements and print the respective result

  1. Is 2 not equal to False?
  2. Is 982*37 greater than 354*98?
  3. Is string "abcd" greater than "abc"?

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 4. Розділ 1
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt