Challenge: Working with the While Loop
Uppgift
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
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 5. Kapitel 2
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Suggested prompts:
Sammanfatta detta kapitel
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 1.67
Challenge: Working with the While Loop
Svep för att visa menyn
Uppgift
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
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 5. Kapitel 2
single