Beginner's mind Continental-----Python Bible Chapter III

Source: Internet
Author: User
Tags square root cmath

First ramble two sentences, just catch up with the week of 6th, and the object has been planned in advance, to go to Beidaihe, travel, although the time is short, but the play is very happy. If you go to Beidaihe, suggest to live in the city, I live in the tourist area, housing is cheap, but the nearby restaurant is really not flattering. To pigeon nest play or good, can catch crabs, small fish, shrimp, play the joy, with a tired body back home, rest, ready to work the next day.

Continue before the story, open the computer input

print Hello World python

Entered the beginner's mind continent beyond me, then the last book to Learn, conquer the beginner's mind continent, towards the front of the departure.

The last time I said input long strings. How long is it?

You can use three quotation marks instead of normal quotes.

Quickly experiment, all play crazy, do not give the new school to the small P teacher.

>>> "

Print SADF

Asdf

Asdf


‘‘‘

' \n\tprint sadf\n\tasdf\n\tasdf\n\n '---to output a bunch of things we wrote.

Wah Wah, there are hints, so good, generally this situation is to have good things to tell us.

Normal strings can also span lines, and if the last line is a character backslash, the line break itself is escaped. It is ignored.

So high-end, just my IQ can learn it?

Test it again.

>>> print "Hello \

world! "

Hello world!

>>>

>>> 1 +

4 + 5

12

>>>

>>> print \

' Hello world! '

Hello world!

>>>

Seemingly not very difficult, it seems that I despise themselves, have not started to underestimate their own first. It is not difficult to keep a positive attitude, to continue learning, to control one side of the world.

Original string, what is this, the original Tianzun created? Did he cross over too?

Ah Xiu, who, forget or continue to study,

How does it have to do with the backslash, you say there is not passion.

The original string for the use of backslashes is not too picky, it seems that he is true love.

In a normal string, the backslash has a special effect, and he escapes, and can add to the string the content that normally cannot be added directly. For example, the line break can be written \ n, and can be put into a string, yes, you can also try to experiment.

>>> print ' Hello,\nworld '

Hello

World

>>>

Looks good, change the line, but also can be placed in any place \ n Line

Another remark, remind me again.

Sometimes this is not the desired result, such as adding top N to a string, for example: C:\nwhere

>>> path = ' C:\nwhere '

>>> Path

' C:\nwhere '

>>> Print Path

C:

where

>>>

I go, really can't ah, took out, the data is not what I want.

>>> print ' C:\\nwhere '

C:\nwhere

>>>

I have just learned that can be converted with a backslash, difficult to me, this is the data I want.

Can think of a problem, if it is a very long path inside there are a lot of anti-diagonal This can be, so lazy I am not to be exhausted, have this time is better than watching the two-level TV series. Hey

Depressed, and then looked down.

Hey!!!!!! This is a good feature, eh,

>>> print R ' C:\nwhere '

C:\nwhere

>>>

Have you found anything different, yes, I added a little r in front without entering a backslash.

>>> print R ' let ' s go! '

Syntaxerror:invalid syntax

>>> print R ' let\ ' s go! '

Let\ ' s go!

>>>

It can be seen that you can put any character in the original string, but also to escape the same as usual,

>>> print R ' let ' s go! '

Syntaxerror:invalid syntax

>>> print R ' let\ ' s go! '

Let\ ' s go!

>>>

However, the result of the output contains the backslash used for escaping.

There is also a string that needs to be understood under the Unicode string.

I do not know very well, the book also said not clear, why the whole, Baidu under it.

Summary of the previous study of the content: Forget not to write, every day to see the blog I sent, too journal do not want to write.

The function class can be noted,

For example:

ABS (number) returns the absolute value of a digit

CMATH.SQRT (number) returns the square root and can also be used for negative numbers

Float (object) converts a string and a number to floating-point numbers

Input (Prompt) provides interactive help------can only enter strings such as ' fffff ' cannot be missing '

Int (object) converts strings and numbers to integers

Long (object) converts a string and a number to a long integer type such as Long (22L) more than a l

Math.ceil (number) returns the count of the top integer for example

>>> Math.ceil (3.2)

4.0

>>> Math.ceil (4.4)

5.0

>>> Math.ceil (4.55)

Math.floor (number) Returns the value of the drop-down integer that is the type of the float

>>> Math.floor (4.5)

4.0

>>> Math.floor (2.9)

2.0

>>>

MATH.SQRT (number) returns the square root and does not apply to negative numbers. Similar to CMATH.SQRT

Pow (x, y) returns the Y power of X

Raw_input (Prompt) Gets the user input, the returned type is a string

A string representation of the return value of the Repr (object)

Round (number[, ndigits]) rounding a number based on a given precision

>>> Round (4.6)

5.0

>>> Round (4.2)

4.0

>>>

Str (object) Converts the value to a string.

The first big chapter has been finished. Have you mastered it?

Is the basis, I think I can master 80, the remaining 20 should be practical operation and a variety of novel topics

Let's see what we need to know next.

The following is a data structure, not a simple value (such as a number) to deal with. is to learn how to store values in complex structures, into lists and dictionaries, and also to drill down into strings.



What did a long time I play is the first grade of the problem is, ah, who let just to beginner's mind mainland, slowly come, remember just to the mainland of beginner's mind?


Insist, early control good beginner's mind the mainland refueling.


Beginner's mind Continental-----Python Bible Chapter III

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.