python数据类型

0
回复
5433
查看
[复制链接]

294

主题

20

回帖

1380

积分

专栏作家

积分
1380
来源: 2019-11-27 23:04:17 显示全部楼层 |阅读模式
致敬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-> number
operator _> +-*/
print(4-5)
print(8+)
110/12.97
naming
number_of_cars = 34
x = 8  if x < 7:
  print(x)
if(x < 7):
print("x is smaller than 7")
Semantics
x = 8
if x < 7:
  print("x is smaller tahn 7")
  print("x is bigger than 7")
variable names, and objects
variable and value
speed_of_liuxiang = 110/12.97
distance = 1000
time = distance/speed_of_liuxiang
print(time)
print(time/60)
assign new value, Mutable
speed_of_ydj= 110/10
time = distance/speed_of_ydj
print(time)
time = time -1
print(time)
data type
interger   + - * / % //   how big is an int?    0b10 0o10 ox10
float   98.5  type(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)
Strings  s = 'this is a string'  type(s)   print(s)   ‘’‘this is the first line
    this is the second line’‘’
type  conversions
a = str(98.6)
a
type(a)
float('98.6')
int('-123')
1 + 2.0
True + 3
3.88 +"28"
不满1.jpg
combine & duplicate
template = "my name is "
name = "ydj"
greeting = template + '' " + name+" ."
print(greeting)

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册
关注微信