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/06/17 19:32:21
![Python 3 中 int代表什么 有一道题不太明白这道题:What will be printed when the following Python3 program runs?a =](/uploads/image/z/14907735-63-5.jpg?t=Python+3+%E4%B8%AD+int%E4%BB%A3%E8%A1%A8%E4%BB%80%E4%B9%88+%E6%9C%89%E4%B8%80%E9%81%93%E9%A2%98%E4%B8%8D%E5%A4%AA%E6%98%8E%E7%99%BD%E8%BF%99%E9%81%93%E9%A2%98%EF%BC%9AWhat+will+be+printed+when+the+following+Python3+program+runs%3Fa+%3D+%225%E2%80%9Cb+%3D+ac+%3D+b+%2A+4print%28c%29c+%3D+int+%28c%29print+%28+c+%2A+2%29%E7%AD%94%E6%A1%88%E6%98%AF555511110%E4%BB%80%E4%B9%88%E5%8E%9F%E7%90%86%7E%7E%7Ec%E4%B8%8D%E5%BA%94%E8%AF%A5%E6%98%AF5+%2A+4+%3D+20%E5%90%97%3F)
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