Question

Python programming: Write a while loop that prints a. All squares less than n. For example,...

Python programming: Write a while loop that prints a. All squares less than n. For example, if n is 100, print 0 1 4 9 16 25 36 49 64 81. b. All positive numbers that are divisible by 10 and less than n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90 c. All powers of two less than n. For example, if n is 100, print 1 2 4 8 16 32 64.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
n = 100

#Code a
i = 0
while(i*i<n):
    print(i*i)
    i+=1
print()


#Code b
i = 10
while(i<n):
    print(i)
    i+=10
print()


#Code c
i = 1
while(i<n):
    print(i)
    i*=2
print()

Add a comment
Know the answer?
Add Answer to:
Python programming: Write a while loop that prints a. All squares less than n. For example,...
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