def quyu(shu,chushu): if shu==chushu: print('余数是0') elif shu<chushu: print('余数是:%s'%shu) elif chushu==0: print('除数不能为0') else: for i in range(0,shu): if shu-i*chushu>chushu: i+=1 elif shu-i*chushu==chushu: print('余数是0') break elif shu-i*chushu==0: print('余数是0') break else: print((shu-i*chushu)) break quyu(10,3)
思路,for循环,if循环 用乘法来判断,