Python Learning variables operations and basic data types

Source: Internet
Author: User

A variable ( This article uses python3.5):
#变量: is an area of computer memory where variables can store values within a specified range, and variables can change
There is no obvious type of variable #在python中变量是计算机内存中数据的引用 python, which is based on the actual data stored in the computer's memory. You can use type (variable name) to get the type of the variable
#在python中数据的存储是以值 (data), a numeric variable stored in the computer's memory is just a reference to the data
#DemoA=1;#a pointing in memory 1Print(ID (a));#address of the printed data 1497427760Print(a);#1a=2;#the point of a is re-specified. A points to memory 2Print(ID (a));#1497427792Print(a);#2#the same value (memory space) in Python can point to multiple variablesA=5;Print(ID (a));#1497427888B=5;Print(ID (b));#1497427888

Second, operator

########################### #算术运算符 ##########################Print(+);Print(3-2);Print(2*5);Print(4/2);Print(3/2);Print(3//2);#The divisible result is an integer (non-rounded integer)Print(17%6);#Take surplusPrint(3**2);#Square of 3Print(3**3);#Cubic of 3#The order of arithmetic operations is consistent with the order of operations in mathematics############################## #关系运算 Table Judging ####################################Print(1&LT;2);#TruePrint(1&GT;2);#FalsePrint(1!=2);#TruePrint(1==2);#FalsePrint(1==1.0);#True################################ #逻辑运算符 #####################################Print("######## #逻辑运算符 ############")Print(1>2 and2&GT;3);#FalsePrint(1<2or2&GT;3);#TruePrint( not1&LT;2);#False

III. Basic data types

#Config=utf-8###################### #数据类型 ##############################shaping int integer floating-point (float) complex number (complex)num1=100;Print(Type (NUM1));#<class ' int ' > before python3.0 result is <type ' int ' >num2=99999999999999999999999999999999999999999;Print(Type (num2));#<class ' int ' > python3.5 before python3.0 <type ' long ' >f1=9.0;Print(Type (F1));#<class ' float ' >f2=3.14j;Print(Type (F2));#<class ' complex ' >#Character TypeStr="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 break \ nPrint(mail); Mail2="""tom:i am Jack Goodbye""";Print(MAIL2);#"" " record text Format

Python Learning variables operations and basic 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.