Create a set of numbers
Python has the following built-in numeric types:
int, integral type, for example: 1,-2, 598;
float, floating point type, for example: 0.0,-3.5, 18.55;
BOOL, Boolean, which is true and false two keywords, but their values are actually 1 and 0, so they can be added and minus oh;
Complex, complex numbers (complex numbers are mathematical terms), expressed in A+BJ or complex (a, b), are floating-point types. For example: 3.5j, 5-2j.
To perform arithmetic on a number
Numeric operations? Some students say this is not subtraction (+-*/), of course, yes!
But here is another little bit of knowledge, that is, in Python's numerical operations, we also need to know the following points:
In integer division, Division/always returns a floating-point number, and if you want only the result of an integer, discard the fractional part that may exist, you can use the divisible operator//;
You can use the * * operation to perform power operations;
The result is a floating-point number for different types of number blending operations.
Type conversions
In the previous knowledge point, the mixed data type of the numeric operation, the result will return to float type, if you want to get a clear integer, then use the type conversion.
Of course, it can also be turned into other types, Python's various type conversion syntax such as:
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/85/7B/wKiom1elPNXiyVC1AADxfCLz_pc493.png-wh_500x0-wm_3 -wmp_4-s_4283929171.png "title=" 5.png "width=" "height=" 634 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:450px; height:634px; "alt=" Wkiom1elpnxiyvc1aadxfclz_pc493.png-wh_50 "/>
After digesting the above content, let's think about a problem ~
Small test skills: the use of the Pythagorean theorem and the power operation to find a right triangle hypotenuse-known conditions are two right-angled edges of 3 and 4, respectively.
The answer is 5, but how to use the power of the code to achieve it?
_______ Thinking Line _______
_______ Thinking Line _______
_______ Thinking Line _______
_______ Thinking Line _______
_______ Thinking Line _______
The answer is this:
Learn more and go to Http://www.mayacoder.com/lesson/index
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/85/7B/wKioL1elPOTiSbJaAAA-Vfr8geA351.png-wh_500x0-wm_3 -wmp_4-s_2623260310.png "title=" 6.png "alt=" Wkiol1elpotisbjaaaa-vfr8gea351.png-wh_50 "/>
Python Novice Learning basic data type--number type