Question
python
print (num=, num) 12. (2) The following loop should print the squares of the odd numbers never ends. What is the error and
0 0
Add a comment Improve this question Transcribed image text
Answer #1

In case of any query do comment. Please rate answer as well. Thanks

Note: Image is half cut so last part of the sentence is not visible. But It seems like it is printing the squares of odd numbers till 12. Please do let me know what is the other part.

Answer: This loop never ends here because num is started with 1 and adding 2 after each iteration and so it will never be 12. It will enter in infinite loop.

You can code as below to print squares of odd number till 12:

num = 1
while num <=12:
print(num**2)
num +=2

main.py 1 num = 1 2 while num <=12: print(num**2) num +=2 121 ... Program finished with exit code o Press ENTER to exit conso

Add a comment
Know the answer?
Add Answer to:
python print ("num=", num) 12. (2) The following loop should print the squares of the odd...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT