在python中,如果我为x(x = 1)分配一个1,那么那个1是否每次都被视为一个字符串?
我不明白为什么数字不被视为数字并且必须转换为可识别的整数以进行数学运算。不断地来回更改变量值似乎很麻烦。
谢谢你
第 2 部分:圆程序区域的一些代码:
def chooseDim ( ):
**choice = input ('Do you need to find radius or area? ')
if choice == 'A' or 'a':
area = 0 [This part of the prog is the culprit, specifically the
area = int(area) "choice" variable prior to the If conditional. The If
areaSol ( )** keeps reading the condition as True no matter what value
"choice" is. It has to do w/the "or" condition. When I let
"choice" be one value, it's fine, but if I code
"if choice = 'A' or 'a'" the prog evals the If as True
every time. Am I not coding the "or" statement right?]
elif choice == 'R' or 'r':
radSol ( )
else:
print ('Please enter either A/a or R/r.')
chooseDim ( )