Find the division remainder of a number

前端 未结 12 1248
刺人心
刺人心 2020-11-28 07:30

How could I go about finding the division remainder of a number in Python?

For example:
If the number is 26 and divided number is 7, then the division remainder

12条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 08:17

    Modulo would be the correct answer, but if you're doing it manually this should work.

    num = input("Enter a number: ")
    div = input("Enter a divisor: ")
    
    while num >= div:
        num -= div
    print num
    

提交回复
热议问题