Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Udfordring: The Not Statement | Mastering Boolean Logic in Python
Datatyper i Python

book
Udfordring: The Not Statement

Opgave

Swipe to start coding

Nogle gange i regnskab skal vi kontrollere, om noget ikke er sandt — for eksempel, hvis en rapport ikke blev godkendt eller ikke blev afvist. Lad os øve os på det!

Erstat ___ med enten True eller False, så:

  1. Variablen report_is_incorrect er lig med False – dette betyder, at enten blev rapporten ikke afvist, eller en anden kontrol blev bestået.

  2. Variablen report_is_ready er lig med True – dette betyder, at rapporten blev godkendt og ikke markeret som ugyldig.

Løsning

# 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)
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 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)

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt