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

Python (II)

編輯:Python

Calculation between different variables

  1. stay python in 、 Two numerical variables can be directly calculated
  2. If the variable is bool type , At the time of calculation true The corresponding number is 1,false The corresponding number is 2.

Use... Between string variables + String concatenation

for example :first1name=“ 3、 ... and ”

      last2name=“ Zhang ”

      first1name+last2name=“ Three sheets ”

String variables can be used with integers * Repeat concatenation of identical strings

for example :“-”*5

     Output :“-----”

Be careful : No other calculations can be performed between numeric variables and strings .

identifier :1、 Identifiers are made up of letters 、 Underline and numbers make up .

        2、 Cannot start with a number .

        3、 Cannot have the same name as the keyword .

Variable naming rule

Be careful :python Identifiers are case sensitive

  1. When you define variables 、 To ensure the code format ,= There should be a space on the left and right of each
  2. stay python in , If the variable name needs to be composed of two or more words , You can name... In the following way
  1. Use lowercase letters for each word
  2. Use underlined links between words

Hump nomenclature

When the variable name consists of two or more words , Use the hump nomenclature

Little hump style :

The first word begins with lowercase , The second word begins with a capital letter , for example :firstName.

Big hump :

The first letter of every word is capitalized , for example :FirstName.

Judgment statement -if sentence

Be careful :if The following four spaces are a if sentence .

Operator :

else

Logical operations :

  1. and: The two conditions are satisfied simultaneously as true, As long as there is one dissatisfaction is false.
  2. or: As long as there is one satisfaction true, Not satisfied is false.
  3. not: Satisfied, unsatisfied , If you are not satisfied, you will be satisfied .

elif

Be careful :elif and else Want to be with if Continuous use , Not to be used alone .


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