Python Programming : Divisible by 3 and 5

Example

Input 
enter the number 15
Output
Divisible by 3 and 5

Required to Know

Use of Variables, Use of different operators like assignment or arithmetic operators, Use of functions like print(), and input(), Use of If-else, and Use of Data types.

Steps

  • Take the number as an input from the user.

  • Check if the number is divisible by 3 and 5. If it is divisible by 3 and 5, print divisible. Otherwise, print it is not divisible.

Condition

if((num%3==0) and (num%5==0)):
    print("divisible")
else:
    print("not divisible")

Program

# The `if` statement checks if the number is divisible by both 3 and 5. If it is, the `print("divisible")` statement is executed. Otherwise, the `print("not divisible")` statement is executed.
num = int(input("enter the number"))
# This condition will check whether the number is divisible by 3 and 5
if (num % 3 == 0) and (num % 5 == 0):
    print("Divisible by 3 and 5")
else:
    print("Not divisible by 3 and 50")