您在這裡

Exercises

1 九月, 2015 - 15:37

Exercise 2.2.Assume that we execute the following assignment statements:

width = 17 height = 12.0 delimiter = '.' 

For each of the following expressions, write the value of the expression and the type (of the value of the expression).

width/2 width/2.0 height/3 1+2*5 delimiter * 5 

Use the Python interpreter to check your answers.

Exercise 2.3.Practice using the Python interpreter as a calculator:

  1. The volume of a sphere with radius r is\frac{4}{3}\pi r^3. What is the volume of a sphere with radius 5? Hint: 392.7 is wrong!
  2. Suppose the cover price of a book is $24.95, but bookstores get a 40% discount. Shipping costs $3 for the first copy and 75 cents for each additional copy. What is the total wholesale cost for 60 copies?
  3. If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 per mile), then 3 miles at tempo (7:12 per mile) and 1 mile at easy pace again, what time do I get home for breakfast?