Python learn how the zero-based integer type definition digital int int () converts the size range

This article is about the theme of digital python python int type integer with the methods and techniques. It is not a data type of the variable, and some properties of the string is the same, attention is an integer not plastic Oh.

There are many types of digital Python int: int int, long integer, boolean bool, float float, complex complex, on the basis of pre-python learning process as long integer and Boolean understand it.

Int int creation, declaration

Create a new integer variable and assign values ​​to variables is the same process

a = 123 b = -123 or equal sign on the left is a variable name, the right is the value to be assigned, is that simple.

Integer features

Since it is a natural integer assigned when the data have to be integers job, understood as a simple integer (positive and negative integers)

Arithmetic operators, and integer variable between methods

python currently supported before the integer data type variable operators: plus (+), subtract (-), multiply (*), divide (/) and power (**)

 

 

If you want to quote quote again after the results obtained between two variables, remember to important assignment.

For example, to quote the results of a + b pictures to do other operations, you have to give the result of a + b is assigned to a new variable job oh. c = a + b the result is c = 13, then this time you do other variables c operation on it.

Conversion between integer and string

python integer string has a common, they are immutable data types. So let the two different data types like to mutual cooperation should be how does it work?

Existing variables a = '222' b = 1, or 223 wants '2221' to how to operate?

 

 

If you do not cooperate with each type conversion happen? System will complain.

Two things to note here:

1), and because the python int string data type is immutable, where int () and str () method refers only to the primary data corresponding to the variable, rather than the type of original variables changed.

2), the same as integers and strings are immutable data type, the result can be referenced must be obtained after re-assignment.

Well, today's share to end here, if you need more technical article, you can visit the official website Marco education directly! Disclaimer: The content and images from the network, belongs to original author, if your original copyright infringement, please inform, we will remove the content as soon as possible!

Guess you like

Origin www.cnblogs.com/woshijiuke/p/11927273.html