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å:
-
Variablen
report_is_incorrect
er lig medFalse
– dette betyder, at enten blev rapporten ikke afvist, eller en anden kontrol blev bestået. -
Variablen
report_is_ready
er lig medTrue
– dette betyder, at rapporten blev godkendt og ikke markeret som ugyldig.
Løsning
9
1
2
3
4
5
6
7
8
# 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?
Tak for dine kommentarer!
Sektion 2. Kapitel 5
9
1
2
3
4
5
6
7
8
# 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
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat