First, common functions
1.input function
The value received by the input () function is all string type, and if you want to compare it with the int type, you must use INT () to convert the string to int type to compare
2. Print () function
# Print (1/2)
# print (1//2) #地板除, is automatic rounding, will not be rounded, directly erase the decimal part
#在python2里面, so the arithmetic print (1/2), the result is not correct, because in the python2 inside
#int和int类型运算会自动取整, there's no problem in Python3.
#if判断时候, both true and false, that is, true and false.
#记住一句话, not 0 is true, non-empty is true
difference between IS and = =
Objects in Python contain three elements: ID "memory Address", type, value
Where the ID is used to uniquely identify an object, type identifies the object, and value is the object's
is determines whether a object is a B object and is judged by its ID.
= = Determines whether the value of a object is equal to the value of the B object, as determined by value.
The following code may help you to understand.
#is Determine the memory address is the same
# name1 = ' Zhangsan '
# Print (ID (name1)) #查看内存地址
# name2 = ' Zhangsan '
# Print (ID (name1)) #查看内存地址
# print (name1 is name2)
Three, string
1. String format:
Example: A = ' username '
2. String specificity
A. strings can be searched by subscript
Perform a print result of
B. String cannot be changed
"Include conversion string type" error when executing changes
C. Convert to string with STR ()
Execution Result:
Python Learning record One