Ethan H.

asked • 02/25/21

How to answer these questions

Chapter 3, Section 3.1 for Loop

Note: they use xrange in the book we will use range

Reading 3.1, Exercises 3.1

  1. Write the outputs of the following loops
  2. a.   for count In range(5):

         print count + 1

    b.  for count in range(1,4):

         print count

     c.  for count in range(1,6,2):

          print count

      d. for count in range(6,1,-1):

          print count

  1. Write a loop that prints your name 100 times. Each output should begin

   on a new line.

 3. Explain the role of the variable in the header of a for loop.

  1. Write a loop that prints the first 128 ASCII values followed by the

   corresponding characters (see the section on characters in Chapter 2).

  1. Assume that the variable testString returns to a string. Write a loop

   that prints each character in this string, followed by its ASCII value.


1 Expert Answer

By:

Patrick B. answered • 02/25/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.