Python 3 中 int代表什么 有一道题不太明白这道题:What will be printed when the following Python3 program runs?a = "5“b = ac = b * 4print(c)c = int (c)print ( c * 2)答案是555511110什么原理~~~c不应该是5 * 4 = 20吗?
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 09:10:50
Python 3 中 int代表什么 有一道题不太明白这道题:What will be printed when the following Python3 program runs?a = "5“b = ac = b * 4print(c)c = int (c)print ( c * 2)答案是555511110什么原理~~~c不应该是5 * 4 = 20吗?
Python 3 中 int代表什么 有一道题不太明白
这道题:
What will be printed when the following Python3 program runs?
a = "5“
b = a
c = b * 4
print(c)
c = int (c)
print ( c * 2)
答案是
5555
11110
什么原理~~~
c不应该是5 * 4 = 20吗?
Python 3 中 int代表什么 有一道题不太明白这道题:What will be printed when the following Python3 program runs?a = "5“b = ac = b * 4print(c)c = int (c)print ( c * 2)答案是555511110什么原理~~~c不应该是5 * 4 = 20吗?
a = "5“ ''给a赋值,字符5
b = a ''给b赋值,b值等于a值,即字符5
c = b * 4 ’‘b*4指四个b值相加,因为是字符所以结果是5555,其结果为字符串
print(c) ’‘输出c
c = int (c) ’‘赋值c为整形,即5千5百5十5
print ( c * 2) ’‘c*2即指数值c乘以2,即5555x2的值11110