Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Основи Булевих Значень | Булеві Значення та Порівняння
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Типи Даних у Python

bookОснови Булевих Значень

Every decision your program makes - whether to show a message, repeat a step, or validate input - relies on a Boolean: True or False. Learn how Booleans work and how regular Python values behave in conditional expressions.

What Is a Boolean?

A Boolean is a value that represents truth: True or False (note the capitalization). You'll often get Booleans from comparisons - age >= 18 yields True when the condition holds - and you'll use them directly in control flow, e.g. if is_adult:.

Truthiness in Practice

In if/while conditions, Python treats many objects as "truthy" or "falsey". Empty or zero-like values are considered false, everything else is true. This lets you write natural checks such as if items: or if name: without extra comparisons.

Common Falsey Values

  • False;
  • None;
  • 0, 0.0;
  • "" (empty string);
  • Empty containers: [], (), {}, set().

Non-empty strings are truthy - even "0" or "False".

12345678910
profile_complete = True user_name = "" messages_sent = 0 if profile_complete: print("Welcome to your dashboard!") # Printed because profile is complete print(bool(user_name)) # False → no name provided yet print(bool(messages_sent)) # False → user hasn't sent any messages print(bool("ok")) # True → any non-empty string counts as valid input
copy

1. Which value is falsey in Python?

2. What value will this code output?

3. Which if will not execute its body?

question mark

Which value is falsey in Python?

Select the correct answer

question mark

What value will this code output?

Select the correct answer

question mark

Which if will not execute its body?

Select the correct answer

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

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 1

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

bookОснови Булевих Значень

Свайпніть щоб показати меню

Every decision your program makes - whether to show a message, repeat a step, or validate input - relies on a Boolean: True or False. Learn how Booleans work and how regular Python values behave in conditional expressions.

What Is a Boolean?

A Boolean is a value that represents truth: True or False (note the capitalization). You'll often get Booleans from comparisons - age >= 18 yields True when the condition holds - and you'll use them directly in control flow, e.g. if is_adult:.

Truthiness in Practice

In if/while conditions, Python treats many objects as "truthy" or "falsey". Empty or zero-like values are considered false, everything else is true. This lets you write natural checks such as if items: or if name: without extra comparisons.

Common Falsey Values

  • False;
  • None;
  • 0, 0.0;
  • "" (empty string);
  • Empty containers: [], (), {}, set().

Non-empty strings are truthy - even "0" or "False".

12345678910
profile_complete = True user_name = "" messages_sent = 0 if profile_complete: print("Welcome to your dashboard!") # Printed because profile is complete print(bool(user_name)) # False → no name provided yet print(bool(messages_sent)) # False → user hasn't sent any messages print(bool("ok")) # True → any non-empty string counts as valid input
copy

1. Which value is falsey in Python?

2. What value will this code output?

3. Which if will not execute its body?

question mark

Which value is falsey in Python?

Select the correct answer

question mark

What value will this code output?

Select the correct answer

question mark

Which if will not execute its body?

Select the correct answer

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

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 1
some-alt