Summary

You learned some very important skills in this chapter. You investigated the for loop, which is used to repeat code a certain number of times. You also looked at how a while loop can be used when the code must repeat an undetermined number of times. You investigated the string object and used some of its methods and properties to do interesting things with text, such as capitalization, searching for a phrase, and determining the length of a string. Finally, you learned how to use the STAIR process to plan a program. In the next chapter, you’ll begin to create your own objects.

NOTE

CHALLENGES

  • Write a program that simulates a 10-lap race. Have the program print out the lap time each time through the loop.

  • Write a program that asks a user how many dice to roll, rolls a six-sided die that many times, and returns the total and average roll.

  • Modify the Math Game from Chapter 2 so that it generates five questions of each type.

  • Modify the Math Game so that each question is repeated until the user gets the correct response.

  • Create a cartoon simulator that emulates the speech pattern of a cartoon character by replacing all r’s with w’s so that You crazy rabbit becomes You cwazy wabbit.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.141.27