Challenge: Working with the While Loop
Oppgave
Swipe to start coding
You are given the variable i for iterating through the list and the list squares, which should store the squares of numbers from 1 to 10.
- Use
a**bto raise the numberato the power ofb. - Assign the value 1 to the variable
iin order to start the iteration. - Create a
whileloop that will iterate through the numbers from 1 to 10, inclusive. - Inside the
whileloop, write the square ofi(iraised to the power of 2) into thesquareslist using the.append()method. - Increment
iby 1 to continue iterating through the loop.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 5. Kapittel 2
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 1.67
Challenge: Working with the While Loop
Sveip for å vise menyen
Oppgave
Swipe to start coding
You are given the variable i for iterating through the list and the list squares, which should store the squares of numbers from 1 to 10.
- Use
a**bto raise the numberato the power ofb. - Assign the value 1 to the variable
iin order to start the iteration. - Create a
whileloop that will iterate through the numbers from 1 to 10, inclusive. - Inside the
whileloop, write the square ofi(iraised to the power of 2) into thesquareslist using the.append()method. - Increment
iby 1 to continue iterating through the loop.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 5. Kapittel 2
single