Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære If/else expressions with multiple conditions (2/2) | Conditional statements
Learn Python from Scratch
course content

Kursinnhold

Learn Python from Scratch

Learn Python from Scratch

1. The basics
2. Arithmetic operations
3. Common data types
4. Conditional statements
5. Other data types
6. Loops
7. Functions

book
If/else expressions with multiple conditions (2/2)

Remember the task you completed two chapters ago. There you wrote if/else statement to check whether the number is even or odd. This time let's modify it so now it will detect zeros and negative numbers.

Oppgave

Swipe to start coding

Modify your code (from the exercise about checking if the number is even or odd) so it will detect zero and print the message "This is null" and negative numbers with message "This number is negative". Think carefully about the order of conditions.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 6
toggle bottom row

book
If/else expressions with multiple conditions (2/2)

Remember the task you completed two chapters ago. There you wrote if/else statement to check whether the number is even or odd. This time let's modify it so now it will detect zeros and negative numbers.

Oppgave

Swipe to start coding

Modify your code (from the exercise about checking if the number is even or odd) so it will detect zero and print the message "This is null" and negative numbers with message "This number is negative". Think carefully about the order of conditions.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 6
Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Vi beklager at noe gikk galt. Hva skjedde?
some-alt