Home  >  Article  >  Backend Development  >  Guibs Python Learning_Numbers

Guibs Python Learning_Numbers

黄舟
黄舟Original
2017-01-20 16:28:531288browse

Guibs’ Python Learning_Numbers

# 数字
# 整数
# 在 Python 中, 可对整数进行加(+) 减(-) 乘(*) 除(/) 模除(%)[求余] 乘方(**)
print(2 + 3)
print(2 - 3)
print(2 * 3)
print(2 / 3) # 注: Python 2 中, 整数除法的结果只包含整数部分, 小数部分直接舍弃. 若要保留小数部分, 则运算数必须包含浮点数
print((1 + 3) % 3)
print(2 ** 3)
# 浮点数
print(0.1 + 0.1)
# 注意: 结果包含小数位数可能是不确定的
print(0.2 + 0.1) 
# 0.30000000000000004
# 使用 str() 转换数字为字符串
# print("hello guibs" + 82) x
print("hello guibs" + str(82))

The above is the content of Guibs’ Python Learning_Numbers. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn