Task
You are given two values  and .
Perform integer division and print .
Input Format
The first line contains , the number of test cases.
The next  lines each contain the space separated values of  and .
Constraints
Output Format
Print the value of .
In the case of ZeroDivisionError or ValueError, print the error code.

hackerrank exceptions problem solution in python programming

Problem solution in Python 3 programming language.

for i in range(int(input())):
    try:
        a,b = list(map(int, input().split()))
        print(a//b)
    except ZeroDivisionError as e:
        print('Error Code:',e)
    except ValueError as e:
        print('Error Code:',e)

Second solution

# Enter your code here. Read input from STDIN. Print output to STDOUT
for i in range(int(input())):
    try:
        a,b=map(int,input().split())
        print(a//b)
    except Exception as e:
        print("Error Code:",e)

Problem solution in Python 2 programming language.

for i in range(int(raw_input())):
    try:
        a,b = map(int, raw_input().split())
        print a/b
    except ZeroDivisionError as e:
        print 'Error Code:',e
    except ValueError as e:
        print 'Error Code:',e