题解 | #被8整除的数字#
被8整除的数字
http://www.nowcoder.com/practice/50abf52eda1b438aa8ba0663865ca86f
NP36 被8整除的数字
思路:
step1:在不同的条件下输出对应的语句;
代码如下:
while True:
try:
active = True
print("Please enter a positive integer!\nEnter 'quit' to end the program.")
n = input()
if n == 'quit':
active = False
if active == False:
break
else:
n = int(n)
if n%8 == 0:
print('{} is a multiple of 8.'.format(n))
else:
print('{} is not a multiple of 8.'.format(n))
except:
break