Thursday, 18 June 2020

Files with Exception handling

#Ask the user to take two input integer values var a,b

try:

    a=int(input("enter any integer value:"))

    b=int(input("enter any integer value:"))

    f=open("knl.txt","w")

    c=a/b

    print(c)

    f.write("writing %d in knl file" %c)

    #creating a new file name:knl.txt

   

except ZeroDivisionError:

    print("Please give other than zero for b")

finally:

    f.close()


x

7 comments:

  1. The blog and data is excellent and informative as well. ExcelR Data Science Courses

    ReplyDelete
  2. APTRON's Python Institute in Gurgaon offers a tailored learning journey that equips you with the tools and knowledge needed to thrive in the ever-evolving field of technology. Offering a comprehensive platform to master the intricacies of Python programming.

    ReplyDelete
  3. Your post was exactly what I needed to read today. Thank you for your thoughtful content!

    AWS Training in Electronic City Bangalore

    ReplyDelete

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(...