Advertisement
naren_paste

Exception_%s

Mar 7th, 2024
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.16 KB | Source Code | 0 0
  1. from functools import reduce
  2. import logging as logs
  3.  
  4. logs.basicConfig(
  5.     filename="calc.log",
  6.     level=logs.DEBUG,
  7.     format="[%(asctime)s] %(lineno)d-%(name)s-%(levelname)s-%(message)s",
  8. )
  9.  
  10.  
  11. class cal_culator:
  12.     def __init__(calc, user_name):
  13.         try:
  14.             logs.info("taking the username")
  15.             calc.username = user_name
  16.             logs.info(user_name)
  17.         except Exception as e:
  18.             logs.error(e)
  19.  
  20.     def add_tion(calc, *args):
  21.         try:
  22.             logs.info("taking the data from user to produce addition of numbers")
  23.             logs.info("enterd data is %s", args)
  24.             # logs.info('the sum is',sum(args))
  25.             return calc.username, sum(args)
  26.  
  27.         except TypeError as t:
  28.             logs.error(t)
  29.  
  30.     def sub_traction(calc, *args):
  31.  
  32.         try:
  33.             logs.info("taking the data tpo produce the subtraction ")
  34.             logs.info("enterd data is %s", args)
  35.             # logs.info('the subtraction is',reduce(lambda a,b:a-b,args))
  36.             return calc.username, reduce(lambda a, b: a - b, args)
  37.             logs.info(args)
  38.         except TypeError as t:
  39.             logs.error(t)
  40.  
  41.     def multi_plication(calc, *args):
  42.         try:
  43.             logs.info("taking the data to produce multiplication of numbers")
  44.             logs.info("enterd data is %s", args)
  45.             # logs.info('the product is',reduce (lambda a,b:a*b,args))
  46.             return calc.username, reduce(lambda a, b: a * b, args)
  47.             logs.info(args)
  48.         except TypeError as t:
  49.             logs.error(t)
  50.  
  51.     def div_sion(calc, *args):
  52.         try:
  53.             logs.info("taking the data to produce division of numbers")
  54.             logs.info("enterd data is %s", args)
  55.             # logs.info('the product is',reduce (lambda a,b:a/b,args))
  56.             return calc.username, reduce(lambda a, b: a / b, args)
  57.             logs.info(args)
  58.             logs.info(args)
  59.         except Exception as e:
  60.             logs.error(e)
  61.  
  62.  
  63. obj = cal_culator("sushant")
  64. print(obj.add_tion(*[1, 2, 3]))
  65. print(obj.sub_traction(*[1, 2, 3]))
  66. print(obj.multi_plication(*[1, 2, 3]))
  67. print(obj.div_sion(*[1, 2, 3]))
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement