Home  >  Article  >  Backend Development  >  Python basics

Python basics

巴扎黑
巴扎黑Original
2017-06-26 09:14:551996browse

Mathematical operators

##**exponent2 ** 38%Get the remainder22 % 8 6##///##*Multiplication3 * 515-Subtraction5 - 23 +Addition2 + 24
Operators Operations Example evaluates to
Quotient rounding 22 // 8 2
Division 22 / 8 2.75

## characters String Operator

OperatorString copyString concatenation
Operation Example Evaluates to *
'a' * 3 'aaa' +
'a' + 'b' 'ab'

3 basic data types and their conversions Function

Data typeint()float()str()
Conversion function Function return value Type int
Integer float
Floating point type str
String

Other functions

FunctionStringIntegerIntegerInteger typeInteger typeInteger type/Floating point type
Function return value type Function print()
Text output (to screen) input()
Text input (via keyboard) len()
Get the number of characters in a string round()
Find approximate number range(start value, end value, Step length)
Generate sequence random.randint(integer, integer)
Select a random integer sys.exit()
Terminate/Exit the program abs()
Find the absolute value

##

The above is the detailed content of Python basics. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn