Python learning variable operations and basic data types, python Data Types
One variable:
# Variable: A zone in the computer memory. variables can store values within the specified range, and variables can be changed.
# In python, there is no obvious type for the variables that reference data in computer memory. The specific type is determined based on the data actually stored in computer memory. You can use the type (variable name) get the type of the Variable
# In python, data is mainly stored as values (data). in computer memory, the stored value variable is just a reference to data.
# Demoa = 1; # a points to 1 print (id (a) in the memory; # print the data address 1497427760 print (a); # 1a = 2; # re-specify a's point to now a points to 2 print (id (a) in the memory; #1497427792 print (a); #2 # the same value in python (memory space) it can point to multiple variables a = 5; print (id (a); # 1497427888b = 5; print (id (B); #1497427888
Ii. Operators
############################ Arithmetic Operators ########## ############### print (1 + 1 ); print (3-2); print (2*5); print (4/2); print (3/2); print (3 // 2 ); # The result of the Division is an integer (non-rounded integer) print (17% 6); # obtain the remainder print (3 ** 2 ); #3 square print (3 ** 3 ); #3 cubes # The arithmetic operation sequence is the same as that in mathematics ########################## ##### relational operation table judgment ############################### ##### print (1 <2 ); # Trueprint (1> 2); # Falseprint (1! = 2); # Trueprint (1 = 2); # Falseprint (1 = 1.0 ); # True ################################# logical operators ### ################################## print ("### ###### logical operators ############") print (1> 2 and 2> 3); # Falseprint (1 <2 or 2> 3); # Trueprint (not 1 <2); # False
III. Basic Data Types
# Config = UTF-8 ####################### data type ########### ################## float) complex (complex) num1 = 100; print (type (num1); # <class 'int'> before python3.0, the result is <type 'int'> num2 = 99999999999999999999999999999999999999999; print (type (num2); # <class 'int'> python3.5 <type 'long'> f1 = 9.0; print (type (f1) before python3.0 )); # <class 'float'> f2 = 3.14j; print (type (f2); # <class 'compule'> # character type str = "123 "; print (type (str); # <class 'str'> str1 = "let's go"; print (str1 ); # let's gostr2 = "let's \" go \ ""; # Escape \ print (str2); # let's "go" mail = "tom: \ n hello \ n I am jack "; # line feed \ nprint (mail); mail2 =" "tom: I am jack goodbye"; print (mail2 ); # "record text format