CodeSolved

Solved Programming Questions & Exercises

Program for checking the divisibility of two numbers

Practice Easy 2456/ Download 38 Views New

Write a program that receives two input numbers and checks whether the first number is divisible by the second number or not. For example, if the inputs are 10 and 2, the output should show that 10 is divisible by 2.

1 Answers

def is_divisible(num1, num2):
    if num2 == 0:
        return "تقسیم بر صفر تعریف نشده است."
    return f"{num1} بر {num2} بخش‌پذیر است." if num1 % num2 == 0 else f"{num1} بر {num2} بخش‌پذیر نیست."

a = int(input())
b = int(input())
print(is_divisible(a, b))
Ai Download Python

Submit answer

Submitting answers is currently unavailable.

×
×
Close