Python core programming version 2 Chapter 5 Exercise 2

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.