Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Basic knowledge of python 04 basic knowledge of mathematics

Shulou Source: shulou.com Published: 2022-06-03 07:15:29 10月03日 Update

The basic knowledge of three numbers in the course

Python console can be executed as a calculator to perform arithmetic such as [root@flink-slave5] # ipythonPython 3.7.4 (default, Aug 13 2019, 20:35:49) Type 'copyright',' credits' or 'license' for more informationIPython 7.8.0-- An enhanced Interactive Python in the python console. Type'?' For help.In [1]: 2 + 3 Out [1]: 5In [2]: 2 + 3 * 2 Out [2]: 8 supports addition, subtraction, multiplication and division. Focus on the division because except for some special * (base) C:\ Users\ Administrator > pythonPython 3.7.3 (default) Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)]:: Anaconda, Inc. On win32Type "help", "copyright" "credits" or "license" for more information. > > 2 + 3 * 517 > 5.3/22.65In [1]: 5 / 2 Out [1]: 2.5In [2]: 5 / / 2 Out [2]: 2In [3]: 4 / 2 Out [3]: 2.0In [4]: 4 / / 2 Out [4]: 2 Out / Division (/) both numerator and denominator results in floating-point numbers The characteristic of the first knowledge point positive division operator (/ /) py is that it only takes the integer part > 5Compact 22 > 4Compact 22 > / if the integer is divisible (both the numerator and denominator are integers), then the result is an integer if only one of the numerators and denominators is a floating point number, but the result is floating point number > > 5.2pm 22.0. Note: in py, only integer and floating point power operators (* *) > the third power of integer and floating point operators (%) / / the remainder (%) / / can be taken from both integers and floating point numbers > 5Compact 22.5 > 5% 21 > 5.2%21.2000000000000002python supports / / +-* /% / * * ()-3 / / represents the symbol in negative 3python. Parentheses second exponentiation third sign (-) fourth * / /% fifth +-example: # coding:utf-8print (2 + 4) print (12654) print (20 + 4 * 5) print ((20 + 4) * 5) print (4x2) print (4Univer 2) print (3Univer 2) print (3lap2) print (5. 2) print (5.2) print (4) print (3 + 2 *-3 * * 3-- 3 * * 2) x = 4y = 5l = 2.4print (x + y * l) / / the result is 6-528401202.0211.562.0256-4216.0

Tags: Integers points results numerators denominators operations knowledge priority console symbols operators control support basics basics highest special addition subtraction multiplication and division remainder examples Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology Apple Microsoft OPPO Reno