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 somthird
? Gem resultatet i variablenfirst_comparison
. - Er produktet af
first * second
mindre end produktet afthird * first
? Gem resultatet i variablensecond_comparison
.
Løsning
99
1
2
3
4
5
6
7
8
9
10
11
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?
Tak for dine kommentarer!
Sektion 3. Kapitel 2
99
1
2
3
4
5
6
7
8
9
10
11
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
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat