Discuss / Python / 怎么修改

怎么修改

Topic source

天将python

#1 Created at ... [Delete] [Delete and Lock User]

a=input('145-39=') a=int(a) if a>106: print('out') if a<106: print('out') else: print('pass')

如果输入比106大的数字,输出为 out pass

怎么改

无愠无殇

#2 Created at ... [Delete] [Delete and Lock User]

改变的是第二个if 处,改为elif

use TAB

a = input('145-39 = ') a = int(a) if a > 106: print('out') elif a < 106: print('out') else: print('pass')

a=int(input('多少fem')) 还可以这样子

a=raw_input('145-39=') a=int(a) if 107>a>106: print('out') else: print('pass')

1011we

#5 Created at ... [Delete] [Delete and Lock User]

我有一个问题,麻烦各位大哥大姐解答一下: a=input('145-39=') a=int(a) if a>106: print('out') if a<106: print('out') else: print('pass')

如果输入比106大的数字,输出为 out pass 这个中间有两个if语句,我想问下 如果if已经得到正确结论了,并且已经print了,还会再走else吗,为什么???

eapol

#6 Created at ... [Delete] [Delete and Lock User]

明显不会啊,if-else语句结构是这样的

妖颜惑众

#7 Created at ... [Delete] [Delete and Lock User]

a = float(input('145-39=')) if a > 106 or a < 106: print('out ') else: print('pass')

这样不管小数整数还是负数都可以了。


  • 1

Reply