python数据类型
致敬hello world!print("hello world!")print("hello again")print("this is the 3rd line, \n", "and this is also the 3rd line")print("this is the 3rd line, \ and this is also the 3rd line")expression-> numberoperator _> +-*/print(4-5)print(8+)110/12.97namingnumber_of_cars = 34x = 8if x < 7: print(x)if(x < 7):print("x is smaller than 7")Semanticsx = 8 if x < 7: print("x is smaller tahn 7") print("x is bigger than 7")variable names, and objectsvariable and valuespeed_of_liuxiang = 110/12.97distance = 1000time = distance/speed_of_liuxiangprint(time)print(time/60)assign new value, Mutablespeed_of_ydj= 110/10time = distance/speed_of_ydjprint(time)time = time -1print(time)data typeinterger + - * / % // how big is an int? 0b10 0o10 ox10float 98.5type(a) import math math.pi math.e math.floor(98.6)math.ceil(98.6) math.pow(2,3)math.sqrt(25)Boolean 1 < 2 (2< 1) or(1<2) not(2<1) type(a)Stringss = 'this is a string'type(s) print(s) ‘’‘this is the first line this is the second line’‘’typeconversionsa = str(98.6)atype(a)float('98.6')int('-123')1 + 2.0 True + 33.88 +"28" combine & duplicatetemplate = "my name is "name = "ydj"greeting = template + '' " + name+" ."print(greeting)
页:
[1]