Programming Challenge in HackerRank

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
  • 0 < T < 10
Output Format
  1. Print the value of . 
  2. In the case of ZeroDivisionError or ValueError, print the error code.
Solution:
===
num_of_cases = input()
for i in range(0,int(num_of_cases)):
try:
a, b = map(int, input().split())
print(a//b)
except (ZeroDivisionError, ValueError) as e:
print("Error Code:", e)

===

One thought on “Programming Challenge in HackerRank”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s