Python core programming Second Edition 97th Page Chapter 5 exercises
I will share with you the answer to my core Python programming.
Because it is not from official resources, it is your own exercises. It may be wrong or not the best solution.
[Recommendation] share a programmer's book "A good book read"
Http://debug-sai.blogbus.com/logs/42178629.html
5-8.
Ry. Calculate the area and volume.
(A) Square and cube
(B) circles and balls
[Answer]
The Code is as follows:
A = float (raw_input ('Please input a numner :...'))
Print 'If this is a side length of a square ...'
Print '... the acreage of this square is % F' % (a *)
Print 'If this is a side length of a cube ...'
Print '... the cubage of this cube is % F' % (a *)
Print 'If this is a radii of a circularity ...'
Print '... the acreage of this circularity is % F' % (3.14159 *)
Print 'If this is a radii of a sphere ...'
Print '... the cubage of this sphere is % F' % (3.14159 X a * 4/3)
[Reference] Using Python for scientific computing
Http://hyry.dip.jp/pydoc/index.html #
An article recommending this website
Http://blog.sina.com.cn/s/blog_4b5039210100mrdl.html
How to Use Python to calculate the circumference Rate
Http://my.opera.com/yunt/blog/show.dml/295271
5-9.
To answer the following questions about the numerical format:
(A) Why is 17 + 32 equal to 49 in the following example, and 017 + 32 equal to 47,017 + 032 equal to 41?
>>> 17 + 32
49
>>> 017 + 32
47
>>> 017 + 032
41
(B) Why is the result of the following expression 134L instead of 1342?
>>> 56l + 78l
134L
[Answer]
(A) The number starting with 0 in Python indicates the octal number. The number of Octal numbers 017 indicates 15, and the number of Octal numbers 032 indicates 26. Therefore, you can obtain the answer as shown in the question.
(B) 561 plus 781 is 1342, while 56l plus 78l is 134L.