Python Basic 7 data types

Source: Internet
Author: User

int (integral type)
The number of integers is 32 bits and the value range is -2**31~2**31-1, which is -2147483648~2147483648

Long (integer)
Unlike the C language, Python's long integers do not refer to the positioning width, i.e. python length does not limit the size of long integer values,
But in fact, because of the limited machine memory, we use a long integer value can not be infinitely large.
Note that, since python2.2, if an integer overflow occurs, Python automatically converts the integer data to a long integer.
So now the long integer data without the letter L will not cause serious consequences.
Float (float type)
A floating-point number is used to process real numbers, which are numbers with decimals, similar to the double type in C, accounting for 8 bytes (64)
Where 52 bits represent the bottom, 11 bits represent the exponent, and the remaining one represents the symbol.
Type (a) A is a variable that can view the data type of variable A.
Boolean Boolean to discover the original state of the board operation, with a light bulb representing two states
True or False
1 or 0
String
The Evil + sign will re-open a space in memory every time it appears.
String formatting
Name = "Jiaao"
Print ("I am%s"% name)
#输出 I am JIAAO
PS: string is%s; integer is%d; floating-point number is%f

Name = input ("name") Age= Input (" Age") Job= Input ("Job")#the other two ways to print, the bottom + number is similar to the printing method JS inside. #Print ("Information of%s:\nname:%s\nage:%s\njob:%s"% (name,name,age,job))#Print ("Information of []:" + name + "\nname []:" + name + "\nage[]:" + Age + "\njob[]:" + Job + "")msg=" "information of%s:name:%s age:%s job:%s" "%(name,name,age,job)Print(msg)#Operation Result:Information of Jiaao:Name:jiaao Age:26Job:it
View Code
Youngage = 26 Age= Input ("Your Age:")#all data that is accepted by the input () function is the string str, which, even when entered as a number, is treated as a string#The string is not the same type as the number, and the two cannot manipulate the comparison, add and subtract, etc.#So when you define variables, or do both, you need to convert them to the same type, and then manipulateLastresult = Int (age)-Youngage#Convert the age variable to int, and then#int integer converts the string to int, using int (the converted string content)#STR string converts int (integer data) to STR, using STR (the converted int content)ifLastresult >=0:Print("I am%s"%(age))Else:    Print("Young,what is your job") Itjob= Input ("Is you a IT programer:")ifItjob = ="Yes":    Print("You be a IT progarmer,that is a good job")Else:    Print("So,what ' s your job?") Job= Input ("Please input your job:")    Print("oh,%s also is a good job"%(Job)) operation Result: your age:26I am26Is you a It programer:yesyou is a it progarmer,that isA good job
string Conversion type

Python Basic 7 data types

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.