Beginner's mind Continental-----python treasure Book

Source: Internet
Author: User
Tags pow

Start with the determination to focus and eat python.

Open the door to Python.

Go to the Python command line first

>>> print "Hello come python World" typed in Enter

Hello come python World

>>>

Look at the effect looks good, good start, the computer know what I want to say to him, haha smile

Can I have a pleasant chat? I decided to create a simulation world (beginner's mind continent), the world is very simple role tentative is

Me: People crossing the beginner's mind continent

Teacher: Python, the original resident has a nice name: teacher P

In order to never stop learning new technology inadvertently touch the taboo command: Hello World python, so I came to the beginner's mind continent, here for me, nothing clear, in my extremely depressed, met the small P teacher, he gave me a peerless cheats, Python basic tutorial, I le a go, I do not want to fire, hurriedly open cheats study, first learn the basic things, can and small p teacher Happy chat say

What the algorithm is:

= 2?

In the beginner's mind continent originally really can ah, and my that world algorithm seems to be a meaning.

Let's do it in detail:

>>>

2

>>>

4

>>> 3+3

6

>>> 123+234

357

>>>

Looks really like the same ah, it seems that it is not difficult, I believe I will soon be able to grasp, ah ha ha, fantasy to stand on the peak of the beginner's mind continent is how carefree, good return to the story, and then look down.

>>> 1/2

0

>>>

Why did situation, 1 divided by 2 How to get 0, small p teacher is not head broken, gee!!! Here are some more notes:

An integer is divisible by another integer, the fractional part of the calculation demerit is truncated, leaving only the integer part, which looks good,

But I want my well-known division Ah, that can be the whole, small p teacher, a pair of watery big eyes look at the small P teacher: Hey! Then look down.

Ah, there is a new discovery, in the beginner's mind continent originally also called floating point number meaning, seemingly and my world definition is the same, haha seems not difficult well, if the normal division of two numbers in a number is a floating point, the result is also a floating point.

I'm going to try it on the actual fencing

>>> 1.0/2.0

0.5

>>> 1/2.0

0.5

>>>.

0.5

>>> 3/4.0

0.75

No, I don't believe it. Don't try the cheats again. Two integers out, okay, I know, division floating-point numbers and integers divide, in the beginner's mind continent still have this effect

>>> 3/4

0

>>>

Little P teacher, discuss a matter, I want to experience the world, the whole number in addition to the specific value can be ... A pair of watery big eyes, and once again looked at the past, Yi, suddenly the air ran to a string of what code: what, regardless of, first use and then look good to make:

>>> from __future__ Import Division

>>> 1/2

0.5

>>>

I take a go, really can ah, it seems that I am really a genius, but the specific is drifting out of what ah, completely do not know, at least understand that can be in addition to the integer can get the specific value.

Miss P, I don't want this anymore. I want the integer divided by the decimal point position help me to remove, yes, gee!!!

There's something new here, so hurry and see.

Double slash: What's this for?

Try again:

>>> 1/2

0.5

>>> 1./2

0.5

>>> 1//2

0

>>>

Really come back, how I want, cheats on all have, really everything has, don't say, look down

There is a doubt that just the division of the floating-point number is the same as my World division, and I want to divide the whole.
Hey!!!!! The original double slash floating point number can also be divided, try to try

>>> 1.0//2.0

0.0

>>> 1/2

0.5

>>> 1//2

0

>>>

Really good, I found that I am really a genius, I am closer to the peak of the beginner's mind continent.

Then look at my cheats:

There's an operator:% What's this for, looking familiar, I remember in my world it seems that I can use this character to calculate the remainder.

I'll try.

>>> 1%2

1

>>> 2%2

0

I'll take a go, really can, I can answer the answer.

The original beginner's mind continent is explained here (this is to take comodule except operator----x% y result is x divided by y remainder)

Oh oh, I know, it's the same with me, (arrogant mood, rising slowly), I'll try floating-point division

>>> 2.75% 0.5

0.25

>>>

More than 0.25, well, look at the thought is 250, small p teacher you do not scold me ...

Hey!!!!

There are operators, feel a little more, just my little head, can't remember!

Feel the contempt of my eyes in the look at me, although I am a person, is not a small p teacher, regardless of learning to say

>>> 2 * * 3

8

>>>-3 * * 2

-9

>>> (-3) * * 2

9

>>>

2 asterisks, what the hell, the original power operator, hello hello, haha, all kinds of giggling

Power operator What is this, looking at understanding seems to be the basis of the front, and the back is there to tell you there are several cardinality added

(-3) * * 2 What's this for? The original brackets 3 is to take the opposite meaning, into an integer 3, haha good interesting props.

You said if I owed someone in my account-1000000 change to (-1000000) * * 2 so much good, hahaha

Then yy down to see it, I have to go what so long the number 1000000000000000000000000000000L

What is this, quickly look at the notes, the baby is frightened.

What's the end of an L?

The original note, called a long integer, and ordinary integers, but will be at the end of the addition of L,

Hey!!!!!!! You say that since it's an integer, but there's an L why did at the end that can play with a regular integer.

Try it again.

>>> 100000000000L + 2

100000000002L

>>> 100000000000L + 2 + 10000000000000000000000000L

10000000000000100000000002L

>>>

There seems to be no problem, there are a lot of numbers, if I have so much money 0 how good. Just think about it, hahaha.

Then look, to the world feel good like, are a learning will, in the look

>>> 0xaf

175

>>> 010

8

>>>

What, a bunch of mysterious code, feel so strange, look for a note no, oh oh Oh the original 0xaf is a hexadecimal number

010 is the representative of the eight-system, found that they have a common, the first letter is 0 Ah, is not a base.

Don't make him mad, or go down.

Variable, what is a variable, is it a light bulb? It's very strange to have a glowing fever.

Let's see the explanation:

Oh oh oh oh oh, so it seems so much fun to explain why, just count the numbers,

Assuming that the small P teacher represents the number 3, I represent the number 1 so small p teacher plus I'm 4,!!!!!! What is Si?

Scared the baby. Does not seem to represent 1, I want to represent 2, haha is quite 2 ah.

How can I communicate with Xiao P teacher?

>>> x = 3

>>> y = 2

>>> x + y

5

>>>

Understand, the variable is the meaning of the representative, the meaning of the assignment, want to let who become a few become a few, you become 222222,

Ha ha

Try my Magic:

>>> x = 3

>>> y = 2

>>> x + y

5

>>> x = 222222

>>> x

222222

>>>

The original variable has the use of restrictions, what restrictions ah, do not limit the line is not ah, roaring roaring!!!!! What the hell is this still going to Thunder Ah, I told you I scare, I saw 2 calves in the chatter, restrictions on it,

Let's see what it is. Limit: (variable names can contain letters, numbers, and underscores (_). Variable cannot begin with a number) you see, the beginning can't start with numbers.

>>> 9XSS =2

File "<stdin>", line 1

9XSS =2

^

Syntaxerror:invalid syntax

>>> XSS9 = 2

>>> XSS9

2

>>>

I take a go, looks really not good, fortunately no thunder, or be hacked to death. It would be nice to start with no numbers.


>>> 9XSS =2

File "<stdin>", line 1

9XSS =2

^

Syntaxerror:invalid syntax

>>> XSS9 = 2

>>> XSS9

2

>>>

Statements, statements, words, I am not always talking about it, it seems not quite right, what is wrong, the statement is you control the key of the beginner's mind continent, how much can be opened to see you.

God horse, really, I can control beginner's mind mainland, think all excited. There is no gold, beauty.

。。。。 Infinite yy in

Keep looking.

Print statement, and an assignment statement. Originally they belong to the statement of one kind ah, I said let fill on the display my assignment statement x = 3 in the input x fill on the 3, really good 3 ah,

Originally I was laying the groundwork, similar to the small fireball, you want to learn the fire ball surgery, first to learn the small fireball, Xiu Xiu.

Learn it,

Focus: Content

Assignment statements are the most important types of statements that control beginner's mind continents, like pots and pans in the kitchen, so important, what can you do?

Is it an assignment output? Note: It is an assignment output, but when you get to the late, you know, I don't have to clearly assign what value

Also know that x * Y's demerit is the product of x and Y. So, there is no best spell, only the best user.

Then look at it, if you can accept it all, it's good to keep on studying the next day, what do you do to sleep?

Sleep, too bored, or study it, early master control beginner's mind the mainland method

Get user input: User, where is the user, I am the user name?

Can be used as a user, of course, beginner's mind mainland is to serve others. How do you feel like a waiter, or a service page that is not serious?

Take a serious look at it:

In the control of the beginner's mind continent, in order to reach the late, just said, we do not need the value of the variable is how much, beginner's mind the mainland will understand.

What are the instructions, Master learning:

>>> x = Input ("x:")

X:23

>>> y = input ("y:")

Y:32

>>> print x + y

55

>>>

Wow, a piece of print and assignment is used, and more than one input appears to be the legendary interactive keyword.

I upgraded the little Fireball, Level 2. I did not know how much the assigned value was calculated. That's a good combination.

What, I heard a good news, the little P teacher to do, he wants to beginner's mind mainland what?

If statement? What is this about? Condition to judge? I love you, I do not love you,

>>> if 1 = = 2:print ' one equals

...

>>> if 1 = = 1:print ' one equals one '

...

One equals one

>>>

The whole day is no use, or see how to explain it. Nothing happens when the condition is false and prints the print statement when the condition 1==1

Why I operate beginner's mind mainland, let me enter 2 spaces, this follow-up again.

Function: Does the mouth contain? It doesn't seem like you should keep studying.

The power we said before is that there is a function that can replace the operator, and that is the POW.

Yes, I'll try.

Looks like it's the same!

>>> 2 * * 3

8

>>> Pow (2,3)

8

>>> Pow (3,2)

9

>>>

The use of built-in functions (like POW's functions called built-in functions) enables a lot of amazing things to be achieved, as well as more complex content.

>>> + POW (2,3*15)/3.0

11728124029620.666

>>>

What else, what else, I want, and

Abs,round, etc.

Why don't you use it?

>>> ABS (-10)

10

>>> ABS (-100000)

100000

>>>

Oh oh oh, it turns out to be absolute.

>>> Round (1.0/2.0)

1.0

>>> 1./2

0.5

>>>

Round used to round up floating-point numbers, hehe.

There seems to be a problem, such as a person's age is 32.9 years old, but want to take the whole to 32 years old, this can be the whole. In fact, beginner's mind continent has such a function floor

How to use, how to use.

Try not to make it.

A pair of watery big eyes floated to the little P teacher, or look down.

Module?

What is the module: The original floor this function in the module named math, I want to call it,

Give it a try.

>>> Import Math

>>> Math.floor (32.9)

32.0

>>>

Really can ah, like good. It works, but why is there a 0 more? More than a 0 into a floating point.

Add an int and turn it into an integer.

>>> Int (Math.floor (32.9))

32

>>>

Yes, hahaha, it's here today, rest.


This article from the "Calm Water" blog, reproduced please contact the author!

Beginner's mind Continental-----python collection

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.