Challenge 1: Check Divisibility by 3 and 4

This lesson will test your knowledge of functions through a challenge.

Problem Statement

Write a function test_divisibility_by_3_4 which will check whether a given integer number is divisible by 3 or 4.

  • If the number is divisible by both return 0
  • If the number is divisible by 3 only return 1
  • If the number is divisible by 4 only return 2
  • If the number is not divisible by both, return -1

Input

    integer

Output

The output can be any of the following:

    0 , 1 , 2 ,-1

Sample Input

    12 , 9 , 16 , 19

Sample Output

    0 , 1 , 2 , -1

Coding Exercise

Write your code below. It is recommended​ that you try solving the exercise yourself before viewing the solution.

Note: There is a test_divisibility_by_3_4 function given in the code for testing purposes. Do not modify it.

Good luck!🤞

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy