python学习_运算

时间:2023-03-09 04:10:17
python学习_运算

1.数据类型

1.1数字

整型int,如2

浮点型float,如3.14和314E-2

复数complex,如(-5+4)

1.2布尔值

真或假

1或0

1.3字符串

'hello world'

2.数据运算

http://www.runoob.com/python/python-operators.html

3.三元运算

result = 值1 if 条件 else 值2

如果条件为真:result = 值1
如果条件为假:result = 值2