Skip to main content

Handling Exceptions 1 | hacker rank solution

 #!/bin/python3


import math
import os
import random
import re
import sys



#
# Complete the 'Handle_Exc1' function below.
#
#

def Handle_Exc1():
    a=int(input())
    b=int(input())
    if a>150 or b<100:
        raise ValueError ("Input integers value out of range.") 
    if a+b>400:
        raise ValueError("Their sum is out of range")
    print("All in range")
    # Write your code here

if __name__ == '__main__':
    try:
        Handle_Exc1()
    except ValueError as exp:
        print(exp)

Comments

Popular posts from this blog

Magic constant generator -python3/hacker rank solution / tcs fresco play

  def   generator_Magic ( n1 ):      # the value starts from 3 and m is formula for constant,      #for generator  yield should use      for   a   in   range ( 3 , n1 + 1 ):          m = a * ( a ** 2 + 1 ) / 2          yield   m               # Write your code here if   __name__  ==  '__main__' :

Handling Exceptions 4 | Library| hacker rank solution

#!/bin/python3 import   math import   os import   random import   re import   sys # # Complete the 'Library' function below. #   def   Library ( memberfee , installment , book ):      if   installment > 3 :          raise   ValueError ( "Maximum Permitted Number of Installments is 3" )      #amount=memberfee/installment      elif   installment == 0 :          raise   ZeroDivisionError ( "Number of Installments cannot be Zero." )      else :          amount = memberfee / installment          print ( "Amount per Installment is  " + str ( amount ))      available = [ "philos...