Data types of Python study notes day1

Integer
  Hexadecimal and octal use 0 as a prefix, such as 0x12f, 010
floating point number
  can use scientific notation to represent very large or small floating point number, such as 1.23x10^9 can be written as 1.23e9 or 12.3e8, 0.000012 can be written as 1.2e-5.

##Integer operations are always exact (including division!), while floating-point operations may have rounding errors.
# Accuracy of integer division:
# There are two kinds of division in Python
# The first one is //, the result of the division is a floating-point number, and if the result is evenly divided, that is also the result of a floating-point number.
# 10/3 = 3.333333333
# 9/3 = 3.0
# The second is // floor division, the division of two integers is still integer, inexact
# 10//3 = 3
#
# Remainder
# 10%3 == 1



String
  Any text that can be expanded with '' or "". To express single or double quotes, you need to use \ to escape.

  Escape characters
  1. Not much to say about \n \t and the like
  2. Not much to say about \\ and \' and the like, just like the regular expressions of the shell.
  3. r"" or r''
    will not escape the specified string by default, such as print(r'\\\\n\\')
  4. ''' (three single quotes)
    If there are many newlines in the string, the readability of using multiple \n is not good. In order to simplify, you can use a pair of three single quotes to indicate multiple lines, such as
      print('''line1
      line2
      line3
      . ..lineN''')
    Pro test, if you directly use regular single quotes in the py file to wrap the line, an error will be reported when it is finally executed, haha.

Boolean
    and , or , not operations. Commonly used in conditional judgment.
  1.and operation If
    both are True, it is True
  2.or operation
    If one is True, it is True
  3.not operation
    True to False, False to True
  Python can directly use True and False to represent Boolean values, pay attention to case.

Empty value is
  represented by None, pay attention to case.

List
  (subsequent learning supplement)
dictionary
  (subsequent learning supplement)
custom data type
  (subsequent learning supplement)

variable
  Python is a dynamic language, and you do not need to define a variable type when defining a variable.
Constants
  are variables that cannot be changed. It is customary to use all uppercase variable names to represent constants.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324845564&siteId=291194637