1.8 functions
Pow (x, y) x^y
ABS (x) The absolute value of the take number
Round (x) rounds a floating-point number to the nearest integer
Floor (x) to take down the entire function, but first import the math module
1.9 Modules
Importing modules with import to extend Python's functionality
(1) Import module then use: module. function
(2) The From module import function then use: function
(3) Use a variable to assign a value, and then use the function, such as: Foo=math.floor () foo (12.9)
Math module and Cmath module
(1) math.sqrt can only handle floating-point numbers, cannot handle complex numbers, i.e. math.sqrt (-1) is meaningless
(2) cmath.sqrt can handle complex numbers, i.e. cmath.sqrt ( -1) =1j
The Python language itself supports support for complex numbers
1.10 Saving and executing a program
To run the program:
In the idle edit box, write the code and save, and run to execute
Or, under the cmd command line, assume that there is a file hello.py cmd under Python hello.py
Let the Python script normal program do the same
Linux under: #! /usr/bin/env python
Under Windows: Click on the file directly, but will jump off immediately.
Comments
# HHDAHFHH
1.11 String
Single-quote strings and transfer quotes
>>> "Hello" >>> ' hello ' are all correct
If you encounter "or" in the middle, you can use a backslash \
Python Basic Tutorial Notes--1th Chapter