Challenge: Using the Range Function
Tehtävä
Swipe to start coding
You are creating a list of numbers with specific conditions. Your goal is to store the numbers from 1 to 9 (including 9) in a list called result.
- Use a
forloop and therangefunction to generate numbers from 1 to 9. - If the number is even, square it before adding it to the list.
- To check if a number is even, use an
ifstatement with the conditioni % 2 == 0. - Add each processed number to the
resultlist.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 5. Luku 6
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Suggested prompts:
Tiivistä tämä luku
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 1.67
Challenge: Using the Range Function
Pyyhkäise näyttääksesi valikon
Tehtävä
Swipe to start coding
You are creating a list of numbers with specific conditions. Your goal is to store the numbers from 1 to 9 (including 9) in a list called result.
- Use a
forloop and therangefunction to generate numbers from 1 to 9. - If the number is even, square it before adding it to the list.
- To check if a number is even, use an
ifstatement with the conditioni % 2 == 0. - Add each processed number to the
resultlist.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 5. Luku 6
single