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

Python - Basic Concepts

編輯:Python

Turtle cartography :https://blog.csdn.net/qq_61206761/article/details/122583246

Stack memory and heap memory :id-> Address type-> type value-> value

identifier : Alphanumeric underline ( Cannot start with a number )

Don't use keywords ( as follows ):

False              class               from                or
None              continue          global             pass
True               def                  if                      raise
and                 del                  import             return
as                   elif                  in                    try
assert             else                is                    while
async              except           lambda           with
await               finally            nonlocal          yield
break               for                 not 

Basic operators :

+,-,*,( Floating point division )/,( Integer division )//,%,( Exponentiation )**

Tips:1. Integer and floating point operations = Floating point numbers

          2.divmod(a,b)= Quotient and remainder

Binary system :0b or 0B

octal :0o or 0O

Hexadecimal :0x or 0X

Forced type conversion (int):

Strings can only convert numeric strings .

int(3.54)=3

round(3.54)=4

Comparison operator :

==,!=,>,<,>=,<=

Logical operators :

or: x or y    x  by True, It doesn't count y, Go straight back to True;x by False, Then return to y

and:x and y    x by True, Then return to y;x by False, It doesn't count y, Go straight back to False

not:not x  It means No x

The same operator :

is: a is b if a and b Of id identical , return True; If different , return False

is not:a is not b    if a and b Of id identical , return False; If different , return True
Tips:1.== The judgment is value Are they the same?

           2.Python Cache only small integer objects ( The scope is [-5, 256]) cached , Not all integer objects . It should be noted that , This is just executed on the command line , And in the Pycharm Or other compilers or save it as a file , The result is different , This is because the interpreter does some optimization ( The scope is [-5, Arbitrary positive integer ]).


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