Home > Articles

This chapter is from the book

Chapter 4 Suggested Problems

  1. Print a matrix of 20 × 20 stars or asterisks (*). From within IDLE, demonstrate the slowest possible means of doing this task and the fastest possible means. (Hint: Does the fastest way utilize string concatenation of the join method?) Compare and contrast. Then use a decorator to profile the speeds of the two ways of printing the asterisks.

  2. Write a generator to print all the perfect squares of integers, up to a specified limit. Then write a function to determine whether an integer argument is a perfect square if it falls into this sequence—that is, if n is an integer argument, the phrase n in square_iter(n) should yield True or False.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.