Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Udfordring: Arbejde med Sammenligningsoperatorer | Betingede Udsagn i Python
Introduktion til Python

book
Udfordring: Arbejde med Sammenligningsoperatorer

Opgave

Swipe to start coding

Du har fået variablerne first, second og third. Brug sammenligningsoperatorer til at kontrollere følgende:

  • Har first samme værdi som third? Gem resultatet i variablen first_comparison.
  • Er produktet af first * second mindre end produktet af third * first? Gem resultatet i variablen second_comparison.

Løsning

first = -5
second = 10
third = -50

# Write your code here
first_comparison = first == third
second_comparison = first * second < third * first

# Testing
print("The result of the first comparison:", first_comparison)
print("The result of the second comparison:", second_comparison)
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 2
first = -5
second = 10
third = -50

# Write your code here
first_comparison = ___
second_comparison = ___

# Testing
print("The result of the first comparison:", first_comparison)
print("The result of the second comparison:", second_comparison)

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