# Revisiting Python Basics - Numbers

Learn Python easily 2022-11-08 04:26:23 阅读数:471

revisitingpythonbasicsnumbers

## 1、整数

``````a=3
b=4
print(a+b)
print(a-b)
print(a*b)
print(a/b)
print(a**b)
``````

``````7
-1
12
0.75
81
``````

## 2、浮点数

PythonConvert all numbers with decimals to floats.There is no need to consider its behavior when working with floating point numbers.Just enter the number you want to use,Python通常会按照你期望的方式处理它们：

``````a=3.5
b=4.9
print(a+b)
print(a-b)
print(a*b)
print(a/b)
print(a**b)
``````

``````8.4
-1.4000000000000004
17.150000000000002
0.7142857142857142
463.37587307179774
``````

The number of decimal places the result contains cannot be determined,The book says don't worry,This is the case in all languages.It can be processed later by means of extra decimal places.

## 3、整数和浮点数

``````a=10
b=2
print(a/b)
``````

#运行结果

``````5.0
``````

## 4、数中的下划线

When writing large numbers, use underscores to group them.

``````a=100_000_000_0
print(a)
``````

``````1000000000
``````

When printing such an underlined number,and will not print underscores.Because of the storage time of this number,Python会忽略其中的下划线.

``````a=10
b=12
c=9
print(a,b,c)
a,b,c=0,5,0
print(a,b,c)
``````

``````10 12 9
0 5 0
``````

Python零基础入门全套教程

Python进阶全套教程

Python实战100例