<gh_stars>0
#!/usr/bin/python3
#Usage: error-handling.py
#Author: <NAME> <<EMAIL>>
#Version: 1.0

# division by 0 error
# print(5/0)

# file not found
# file = open("file","r")

# data type error int / string
# int('1.2b')

# int('1.2')

# division by 0 error
# a = 5/0
# print("after error")


try:
    a = 5/0
except Exception as e:
    print(e)

try:
    n = int(input("Enter an Integer: "))
except ValueError:
    print("That is not an integer")


try:
    sum = 0
    file = open('number.txt','r')
    for number in file:
        sum = sum + 1.0/int(number)
    print(sum)
except ZeroDivisionError:
    print("Number in file equal to zero!")
except IOError:
    print("File not exist")
finally:
    print(sum)
    #file.close()


a = 1

def RaiseException(a):
    if type(a) !=  type('a'):
        raise ValueError("This is not string")

try:
    RaiseException(a)
except ValueError as e:
    print(e)



def TestCase(a, b):
    assert a < b, "a is greater than b"

try:
    TestCase(2,1)
except AssertionError as e:
    print(e)

#!/usr/bin/python3
#Usage: error-handling.py
#Author: <NAME> <<EMAIL>>
#Version: 1.0

# division by 0 error
# print(5/0)

# file not found
# file = open("file","r")

# data type error int / string
# int('1.2b')

# int('1.2')

# division by 0 error
# a = 5/0
# print("after error")


try:
    a = 5/0
except Exception as e:
    print(e)

try:
    n = int(input("Enter an Integer: "))
except ValueError:
    print("That is not an integer")


try:
    sum = 0
    file = open('number.txt','r')
    for number in file:
        sum = sum + 1.0/int(number)
    print(sum)
except ZeroDivisionError:
    print("Number in file equal to zero!")
except IOError:
    print("File not exist")
finally:
    print(sum)
    #file.close()


a = 1

def RaiseException(a):
    if type(a) !=  type('a'):
        raise ValueError("This is not string")

try:
    RaiseException(a)
except ValueError as e:
    print(e)



def TestCase(a, b):
    assert a < b, "a is greater than b"

try:
    TestCase(2,1)
except AssertionError as e:
    print(e)
#!/usr/bin/python3 #Usage: error-handling.py #Author: <NAME> <<EMAIL>> #Version: 1.0 # division by 0 error # print(5/0) # file not found # file = open("file","r") # data type error int / string # int('1.2b') # int('1.2') # division by 0 error # a = 5/0 # print("after error") #file.close()