type of data
type | illustrate | example |
plastic surgery | integer | 2345 |
floating point | decimal | 3.14 |
Boolean | true or false | True、False |
character type | sequence of strings | "python", "datatype" |
operator
operator | illustrate | example | result |
+ | addition | 2+3 | 5 |
- | subtraction | 10-5 | 5 |
* | multiplication | 5*6 | 30 |
/ | floating point division | 7/2 | 3.5 |
// | Integer division (rounding) | 7//2 | 3 |
% | Modulo (remainder) | 7%2 | 1 |
** | power | 2**4 | 16 |
Conversion between integers:
a=eval(input('请输入要转换的十进制数:'))
# 十进制转二进制 (bin)
b=bin(a)
print('十进制转换为二进制是:',b)
# 十进制转换为八进制 (oct)
c=oct(a)
print('十进制转换为八进制是',c)
# 十进制转换为十六进制 (hex)
d=hex(a)
print('十进制转换为十六进制是',d)