程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

These Python tips you have to know

編輯:Python

CDA Data Analyst Produce

edit :Mika

Python The name of the variable

http://mpvideo.qpic.cn/

Hello everyone , This issue Python Tips , Let's talk about the naming of variables .

There are several rules you must pay attention to :

One 、 Do not start with a number .

You see, if it starts with a number , Running is wrong .

Two 、 There can be no spaces .

You see abc and 1 There must be no space between them , You must name it with at least one underline or horizontal line , Of course I recommend underlining .

3、 ... and 、 You cannot use built-in functions .

for instance print , It is a function of printing itself , Don't use it as a variable . After use , The printing function is gone .

Four 、 Keywords are not allowed .

image for Keywords such as... Cannot be used , Because it has been given the meaning it should have , Do you remember ?

Python To get the input

http://mpvideo.qpic.cn/

next , Let's talk about Python How to get the input content .

We use input This built-in function gets the input content .

You can see , So let's run this .

Enter the content you want to enter here , Write my name here david enter .

Now david This word has been copied to your name, So I'll put your name Print it out and have a look .

You see , david It shows here , therefore input Is a built-in method to get what you want to input .

Have you learned ?

Python And if loop

Hello everyone , stay Python There is a very important if Circulation requires us to master .

Let's talk about it today .

First of all, I have a x be equal to 10 , I'll write one first if x < 5, It would be print Age is less than 5 ,elif For if if If you're not satisfied , Next, continue to judge whether this is satisfied .

x Is it greater than or equal to 5 Less than 15 , If you are in this range, you will print Older than or equal to 5 Age less than 15 year .

Finally, if these two are not satisfied else ,print Older than 15 year .

Here we can have a look , If x be equal to 10, In this if The result of the loop is : Older than or equal to 5 Age less than 15 year .

If change to 20 , It will run with the result that it is older than 15 year .

This if Circulation is very important , Students need to master .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved