We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Python
  3. Errors and Exceptions
  4. Exceptions
  5. Discussions

Exceptions

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 360 Discussions, By:

recency

Please Login in order to post a comment

  • ndunguzack13
    20 hours ago+ 0 comments

    Simplest method

    #number of test cases
    test_cases = int(input())
    
    for i in range(test_cases):
        a,b = input().split(" ")
        try:
            ans = int(a)//int(b)
            print(ans)
        except Exception as e:
            print(f'Error Code: {e}')
     
    
    0|
    Permalink
  • agentkaumal88
    2 weeks ago+ 0 comments
    N = int(input())
    
    for _ in range(N):
        isOkay = True
        a, b = input().split()
        try:
            i = int(a)
            j = int(b)
        except ValueError as e:
            isOkay = False
            print("Error Code:", e)
        
        if isOkay:
            try:
                print(int(int(a)/int(b)))
            except ZeroDivisionError:
                print("Error Code:", 'integer division or modulo by zero')
    
    0|
    Permalink
  • thainguyen2893
    2 weeks ago+ 1 comment
    for _ in range(int(input())):
        try:
            a, b = list(map(int, input().split()))
            try:
                print(int(a//b))
            except ZeroDivisionError as e:
                print("Error Code:", e)
        except ValueError as e:
            print("Error Code:", e)
    
    0|
    Permalink
  • hamzae2tan
    3 weeks ago+ 0 comments

    N = int(input()) for _ in range(N): b = input().split() try : res = int(b[0]) // int(b[1])
    print(res)
    except ValueError as e: print("Error Code:", e) except ZeroDivisionError as e: print("Error Code:" , e )

    0|
    Permalink
  • travis_earl_1985
    3 weeks ago+ 0 comments

    n = int(input())

    for i in range(n): try: a, b = map(int, input().split()) print(a//b) except ZeroDivisionError as e: print("Error Code: integer division or modulo by zero") except ValueError as e: print("Error Code:", e)

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy