Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic operations in Python

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "what are the basic operations in Python". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the basic operations in Python"?

1. Basic operation > 6 # where the'#'is the annotation symbol, does not participate in the operation 6 > 66666666666666 # integer type, output as is 66666666666666666 > 3.14 # floating point type 3.14 > id (6) # id () function is used to view the memory address 1409471616 > help (id) # help () function can be used to view the function document Help on built-in function id in module builtins:id (obj, /) Return the identity of an object. This is guaranteed to be unique among simultaneously existing objects. (CPython uses the object's memory address.) > 5x 16 > 5.0cm 1 # where the operation result will be automatically converted to floating point 6.0> 10prime 25.0 > 10max 3 # because the computer converts the number into binary, the floating point conversion deviation caused by 3.33333333333335 > > 2.5 > 25.0 > > 2.5 inch 2 # symbol * * is calculated by index. For example, if you calculate 2.5 to the second power 6.25 > 5, you can calculate the result of division, and then rounding 2 > 5% 2 # to take the remainder, there is nothing to say: 1 > 5.0% 2 # floating-point number, same as 1.0 > > (5 + 6) * 2-2 * * 3 + 5 + 5% 3 # comprehensive calculation (expression calculation) 142. Variable and variable type > > axi6 # variable definition and assignment > > A6 > b = 3rooma # variable operation and assignment > b18 > type (a) # type function is used to detect variable type > b = True # Boolean type > c = 3.14 # floating point type > type (c) > d = 'www.jb51.net' > type (d) > > e = [' www.jb51.net' > > type (d) > > e = ['www.jb51.net' > > type (e)] # list type > Boolean (e) > > f = ( 'z') # tuple types > type (f) > > g = {'a 'type (g) > 3. Professional calculation module: mathsin (x) to find the sine of x cos (x) to find the cosine of x asin (x) to find the sine of x acos (x) to find the inverse cosine of x tan (x) to find the tangent of x atan (x) to find the cotangent of x, anti-tangent hypot (x) to find the oblique side length fmod (x) of right triangles. Y) find the remainder of x ceil (x) take the smallest integer not less than x (rounding up) floor (x) take the largest integer not greater than x (rounding down) fabs (x) find the absolute value exp (x) find the x power pow (x) of e Y) find the y power of x log10 (x), find the value of the square root pi pi of x with logarithm sqrt (x) based on 10 (constant) > abs (- 2) # find the absolute value (system function) 2 > pow (2pi 4) # calculate the 4th power of 2 (system function) 3 > > round (3.4) # round rounding operation (system function) 3 > > round (3.5) # round rounding operation 4 > import math # you can import the math module to perform operations using the import statement > dir (math) # View everything in the library ['_ _ doc__' '_ loader__',' _ name__','_ package__','_ spec__', 'acos',' acosh', 'asin',' asinh', 'atan',' atan2', 'atanh',' ceil', 'copysign',' cos', 'cosh',' degrees', 'factorial',' erf', 'erfc',' exp', 'expm1',' fabs', 'factorial' 'floor', 'fmod',' frexp', 'fsum',' gamma', 'gcd',' hypot', 'inf',' isclose', 'isfinite',' isinf', 'isnan',' ldexp', 'lgamma',' log', 'log10',' log1p', 'log2',' modf', 'nan',' pi', 'pow',' radians', 'sin',' sinh', 'sqrt' 'tan',' tanh', 'tau',' trunc'] > piTraceback (most recent call last): File ", line 1, in piNameError: name 'pi' is not defined > > math.pi3.141592653589793 > from math import * > > pi3.141592653589793 > sqrt (9) # sqrt calculates the square 3.0 > ceil (3.1) # ceil rounding up 4 > > floor (3.9) # floor rounding down 3 > > fmod (7pr 4) # fmod takes the remainder 3.0 thanks for your reading The above is the content of "what are the basic operations in Python". After the study of this article, I believe you have a deeper understanding of what basic operations are in Python, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report