Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import reduce
- import logging as logs
- logs.basicConfig(
- filename="calc.log",
- level=logs.DEBUG,
- format="[%(asctime)s] %(lineno)d-%(name)s-%(levelname)s-%(message)s",
- )
- class cal_culator:
- def __init__(calc, user_name):
- try:
- logs.info("taking the username")
- calc.username = user_name
- logs.info(user_name)
- except Exception as e:
- logs.error(e)
- def add_tion(calc, *args):
- try:
- logs.info("taking the data from user to produce addition of numbers")
- logs.info("enterd data is %s", args)
- # logs.info('the sum is',sum(args))
- return calc.username, sum(args)
- except TypeError as t:
- logs.error(t)
- def sub_traction(calc, *args):
- try:
- logs.info("taking the data tpo produce the subtraction ")
- logs.info("enterd data is %s", args)
- # logs.info('the subtraction is',reduce(lambda a,b:a-b,args))
- return calc.username, reduce(lambda a, b: a - b, args)
- logs.info(args)
- except TypeError as t:
- logs.error(t)
- def multi_plication(calc, *args):
- try:
- logs.info("taking the data to produce multiplication of numbers")
- logs.info("enterd data is %s", args)
- # logs.info('the product is',reduce (lambda a,b:a*b,args))
- return calc.username, reduce(lambda a, b: a * b, args)
- logs.info(args)
- except TypeError as t:
- logs.error(t)
- def div_sion(calc, *args):
- try:
- logs.info("taking the data to produce division of numbers")
- logs.info("enterd data is %s", args)
- # logs.info('the product is',reduce (lambda a,b:a/b,args))
- return calc.username, reduce(lambda a, b: a / b, args)
- logs.info(args)
- logs.info(args)
- except Exception as e:
- logs.error(e)
- obj = cal_culator("sushant")
- print(obj.add_tion(*[1, 2, 3]))
- print(obj.sub_traction(*[1, 2, 3]))
- print(obj.multi_plication(*[1, 2, 3]))
- print(obj.div_sion(*[1, 2, 3]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement