Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: The Not Statement | Mastering Boolean Logic in Python
Data Types in Python

book
Challenge: The Not Statement

Aufgabe

Swipe to start coding

Sometimes in accounting, we need to check if something is not true — for example, if a report was not approved or not rejected. Let's practice that!

Replace ___ with either True or False so that:

  1. The variable report_is_incorrect equals False – this means either the report was not rejected, or some other check passed.

  2. The variable report_is_ready equals True – this means the report was approved and not flagged as invalid.

Lösung

# This should be `False`: the report is not rejected, and the other condition is also false
report_is_incorrect = not True or False

# This should be `True`: the report is approved, and not marked as invalid
report_is_ready = True and not False

print("Variable report_is_incorrect equals:", report_is_incorrect)
print("Variable report_is_ready equals:", report_is_ready)
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 5
# This should be `False`: the report is not rejected, and the other condition is also false
report_is_incorrect = not True or ___

# This should be `True`: the report is approved, and not marked as invalid
report_is_ready = ___ and not False

print("Variable report_is_incorrect equals:", report_is_incorrect)
print("Variable report_is_ready equals:", report_is_ready)

Fragen Sie AI

expand
ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

some-alt